In the deployProxyAndDistributeBySignature
method of the ProxyFactory
contract. The vulnerability allows any user to invoke the method by submitting a pre-signed message. However, the method's signature calculation overlooks the implementation parameter, enabling an attacker to exploit the contract by duplicating a previous signed message and triggering the deployment of another contract with bonus distribution.
The deployProxyAndDistributeBySignature
method verifies the user-provided contestId
, data
, and organizer
to ensure that the invoked signature is only applicable for the combination of this organizer+contestId
, with the calldata parameter fixed for the function call.
However, upon closer examination of the contract code, after passing the signature validation, at line 161, the _calculateSalt(organizer, contestId, implementation)
method is called to compute the address of the contract to be deployed and distributed. The implementation
parameter used here is not involved in the previous signature validation, which theoretically allows the use of the same signature information while switching to a different implementation
parameter for executing this method.
Let's consider a scenario where the same organizer
uses the same contestId
but different implementation
addresses by calling setContest
twice, creating two projects.
Under this assumption, if an attacker captures the signature information of the first project using the organizer's signature, they can immediately fill in the same signature parameter along with a different implementation
address to deploy and distribute rewards for the second project.
Note: If the organizer is trusted and not malicious, the motivation for an attacker to perform this attack arises when the attacker is one of the winners parameters in the first call and wishes to obtain rewards again, as the data parameter is immutable.
Below is the complete attack example code:
Prepare the contestId
parameter.
Obtain the address information of proxy1, corresponding to the parameter keccak256(abi.encode(TEST_SIGNER, contestId, address(distributor))
, and simulate the transfer of tokens to the sponsor role.
Deploy a new implementation
contract named distributor2
, where the stadiumAddress
in the contract is set to the new address stadiumAddress2.
Simulate the transfer of tokens to the sponsor role.
Create a contest for the first combination: (TEST_SIGNER+contestId+distributor)
.
Create a contest for the second combination: (TEST_SIGNER+contestId+distributor2)
.
Calculate the signature
and call the deployProxyAndDistributeBySignature
method for the first combination. Verify that the balances of user1
and stadiumAddress
are 9500 ether and 500 ether, respectively.
Copy the signature
information from the previous call and call the deployProxyAndDistributeBySignature
method for the second combination. Finally, verify that the balance of user1
is 9500*2 ether, and the balance of the new address stadiumAddress2
in distributor2 is 500 ether.
Unauthorized contract deployment: The vulnerability allows attackers to exploit the system by reusing previously signed messages and deploying unauthorized contracts. This can lead to the deployment of malicious or unverified contracts, compromising the integrity and security of the system.
Unintended bonus distribution: Attackers can manipulate the bonus distribution process by leveraging the vulnerability. By duplicating signed messages and switching the implementation parameter, they can trigger the deployment of additional contracts and distribute bonuses incorrectly or in an undesired manner. This can result in financial losses or imbalanced distribution among participants.
Manual Review
Include all relevant parameters in signature calculation: Modify the method to incorporate the implementation parameter when calculating the signature. This ensures that the signed message includes all necessary parameters, including the implementation address, preventing the reuse of signed messages for unintended contract deployments.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.