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: 19/74
Findings: 2
Award: $169.01
š Selected for report: 0
š Solo Findings: 0
š Selected for report: tonisives
Also found by: Inspecktor, MohammedRizwan, Qeew, peanuts, sces60107
162.9427 USDC - $162.94
Aquifer.sol contract is a permissionless Well registry and factory. Aquifer.sol deploys Wells by cloning a pre-deployed Well implementation. It has boreWell() which is used to clone the well implementation by using Solady LibClone.sol functions like clone() and cloneDeterministic(). The conditions for use of these functions as commented in contract.
* Use `salt == 0` to deploy a new Well with `create` * Use `salt > 0` to deploy a new Well with `create2`
boreWell() in Aquifer.sol is given as,
File: src/Aquifer.sol 34 function boreWell( 35 address implementation, 36 bytes calldata immutableData, 37 bytes calldata initFunctionCall, 38 bytes32 salt 39 ) external nonReentrant returns (address well) { 40 if (immutableData.length > 0) { 41 if (salt != bytes32(0)) { 42 well = implementation.cloneDeterministic(immutableData, salt); 43 } else { 44 well = implementation.clone(immutableData); 45 } 46 } else { 47 if (salt != bytes32(0)) { 48 well = implementation.cloneDeterministic(salt); 49 } else { 50 well = implementation.clone(); 51 } 52 } // Some code
cloneDeterministic() function under the hood uses create2. This function has used salt which means that a malicious actor can prevent a user from deploying a boreWell creation by frontrunning it with the same "salt".
Additionally, In future if this protocol is being deployed on Multichains like optimism, arbitrum, polygon additional, more-critical vulnerabilities become possible via reorg attacks.
The "salt" is a bytes32 value that is used in boreWell creation call by the caller. This enables frontrunning to occur in the following way:
Manual review
Use a salt that includes the msg.sender. That way it is not possible to front-run the transaction.
function boreWell( address implementation, bytes calldata immutableData, bytes calldata initFunctionCall, bytes32 salt ) external nonReentrant returns (address well) { if (immutableData.length > 0) { if (salt != bytes32(0)) { - well = implementation.cloneDeterministic(immutableData, salt); + well = implementation.cloneDeterministic(keccak256(abi.encode(immutableData, salt, msg.sender))); } else { well = implementation.clone(immutableData); } } else { if (salt != bytes32(0)) { - well = implementation.cloneDeterministic(salt); + well = implementation.cloneDeterministic(keccak256(abi.encode(salt,msg.sender))); } else { well = implementation.clone(); } } // Some code
Other
#0 - c4-pre-sort
2023-07-11T15:09:06Z
141345 marked the issue as duplicate of #217
#1 - c4-pre-sort
2023-07-12T16:03:01Z
141345 marked the issue as duplicate of #221
#2 - c4-pre-sort
2023-07-12T16:12:18Z
141345 marked the issue as duplicate of #181
#3 - 141345
2023-07-12T16:20:43Z
like https://github.com/code-423n4/2023-07-basin-findings/issues/159
no clear path of losing and how reorg attacks can cause harm
maybe partial
#4 - c4-judge
2023-08-04T05:57:34Z
alcueca marked the issue as satisfactory
š Selected for report: 0xprinc
Also found by: 0x11singh99, 0xAnah, 0xWaitress, 0xkazim, 2997ms, 33audits, 404Notfound, 8olidity, CRIMSON-RAT-REACH, CyberPunks, DanielWang888, Deekshith99, Eeyore, Eurovickk, Inspecktor, JGcarv, John, Jorgect, Kaysoft, LosPollosHermanos, MohammedRizwan, Qeew, QiuhaoLi, Rolezn, TheSavageTeddy, Topmark, Trust, Udsen, a3yip6, alexzoid, bigtone, codegpt, erebus, fatherOfBlocks, ginlee, glcanvas, hunter_w3b, josephdara, kaveyjoe, kutugu, mahdirostami, max10afternoon, oakcobalt, peanuts, pfapostol, ptsanev, qpzm, radev_sw, ravikiranweb3, sces60107, seth_lawson, te_aut, twcctop, zhaojie, ziyou-
6.0655 USDC - $6.07
Number | Issue | Instances | |
---|---|---|---|
[Lā01] | draft-ERC20PermitUpgradeable is deprecated by openzeppelin | 1 | |
[Lā02] | Violation of Checks, Effect and Interactions pattern in Well.sol | 1 | |
[Lā03] | Use latest version of openzeppelin library | 1 |
Openzeppelin has deprecated the use of draft-ERC20PermitUpgradeable in v4.9.0 release. Check out the deprecations here.
There is 1 instance of this issue:
Use ERC20PermitUpgradeable.sol.
It is always recommended to follow Checks, Effect and Interactions(CEI) pattern in contracts to prevent re-entrancy attacks.
There is 1 instance of this issue:
In Well.sol at L-371.
For example:
if (amountOut >= minAmountOut) { - tokenOut.safeTransfer(recipient, amountOut); reserves[j] -= amountOut; + tokenOut.safeTransfer(recipient, amountOut); // Some code
The contracts has used old version of OZ library. Library contracts security should be upto date. Use the latest version of OZ library i.e v4.9.2.
#0 - c4-pre-sort
2023-07-13T14:50:30Z
141345 marked the issue as high quality report
#1 - c4-sponsor
2023-08-02T20:43:06Z
publiuss marked the issue as sponsor confirmed
#2 - c4-judge
2023-08-04T21:19:55Z
alcueca marked the issue as grade-b