Platform: Code4rena
Start Date: 03/07/2023
Pot Size: $40,000 USDC
Total HM: 14
Participants: 74
Period: 7 days
Judge: alcueca
Total Solo HM: 9
Id: 259
League: ETH
Rank: 15/74
Findings: 1
Award: $211.83
🌟 Selected for report: 1
🚀 Solo Findings: 0
🌟 Selected for report: tonisives
Also found by: Inspecktor, MohammedRizwan, Qeew, peanuts, sces60107
211.8255 USDC - $211.83
The boreWell function in the Aquifer contract is responsible for creating new Wells. However, there are two critical security issues:
salt
parameter allows an attacker to frontrun a user's transaction and capture the deposit amount intended for the user's Well. By creating a Well with the same salt
value, the attacker can receive the deposit intended for the user's Well and withdraw the funds.salt
value as the user's intended Well. This causes the user's transaction to be reverted, resulting in a denial-of-service (DoS) attack on the boreWell function. The attacker can repeatedly execute this attack, preventing users from creating new Wells.If a user intends to create a new Well and deposit funds into it, an attacker can frontrun the user's transactions and capture the deposit amount. Here is how the attack scenario unfolds:
salt
value, and the second to deposit funds into the newly created Well.salt
value.In this attack scenario, an attacker can forcefully revert a user's create Well transaction by deploying a Well for themselves using the user's salt
value. Here are the steps of the attack:
salt
value.salt
value.vscode
To mitigate the identified security issues, it is recommended to make the upcoming Well address user-specific by combining the salt
value with the user's address. This ensures that each user's Well has a unique address and prevents frontrunning attacks and DoS attacks. The following code snippet demonstrates the recommended modification:
well = implementation.cloneDeterministic( keccak256(abi.encode(msg.sender, `salt`)) );
Other
#0 - c4-pre-sort
2023-07-11T14:59:01Z
141345 marked the issue as duplicate of #217
#1 - c4-pre-sort
2023-07-12T16:03:13Z
141345 marked the issue as duplicate of #221
#2 - c4-pre-sort
2023-07-12T16:11:11Z
141345 marked the issue as not a duplicate
#3 - c4-pre-sort
2023-07-12T16:11:15Z
141345 marked the issue as primary issue
#4 - 141345
2023-07-12T16:13:56Z
Stealing of user's intended deposit fund might be the possible path of losing
#5 - c4-sponsor
2023-07-21T14:58:51Z
publiuss marked the issue as sponsor confirmed
#6 - c4-judge
2023-08-04T05:57:08Z
alcueca marked the issue as satisfactory
#7 - c4-judge
2023-08-04T06:01:50Z
alcueca marked the issue as selected for report
#8 - publiuss
2023-08-23T00:44:27Z
This issue has been addressed in the code. The boreWell(...)
function now uses a salt
consisting of the hash of msg.sender
appended to the input salt
value. See here:
https://github.com/BeanstalkFarms/Basin/blob/91233a22005986aa7c9f3b0c67393842cd8a8e4d/src/Aquifer.sol#L40