Basin - kaveyjoe's results

A composable EVM-native decentralized exchange protocol.

General Information

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

Basin

Findings Distribution

Researcher Performance

Rank: 44/74

Findings: 1

Award: $17.52

QA:
grade-a

🌟 Selected for report: 0

🚀 Solo Findings: 0

Target : https://github.com/code-423n4/2023-07-basin/blob/main/src/Aquifer.sol

The boreWell function allows the deployment of new Well contracts by cloning a pre-deployed Well implementation. there is a missing check for the success of the cloneDeterministic and clone functions, which can result in failed deployments without proper error handling.

##impact

The current issue does not pose a significant security risk, but it can lead to confusion and difficulty in diagnosing deployment failures. Proper error handling is crucial to provide clear feedback to users and developers interacting with the contract.

Proof of concept

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.17;

import "truffle/Assert.sol"; import "../Aquifer.sol";

contract AquiferTest { Aquifer aquifer;

function beforeEach() public { aquifer = new Aquifer(); } function testBoreWellCloningFailure() public { // Deploy a mock Well implementation contract MockWellImplementation wellImplementation = new MockWellImplementation(); // Call boreWell with a failing clone function address well = aquifer.boreWell(address(wellImplementation), "", "", bytes32(0)); // Verify that the boreWell function reverts with the expected error message (bool success, bytes memory returnData) = address(aquifer).staticcall( abi.encodeWithSignature("wellImplementation(address)", well) ); Assert.equal(success, false, "BoreWell did not revert"); Assert.isTrue( string(returnData) == "Clone failed: clone", "BoreWell did not revert with the expected error message" ); }

}

contract MockWellImplementation { function clone(bytes calldata) external returns (address) { // Simulate a cloning failure return address(0); } } In the above test, we create a test contract AquiferTest that inherits from truffle/Assert.sol to perform assertions. We set up a beforeEach function to deploy a fresh instance of the Aquifer contract before each test case.

The testBoreWellCloningFailure function tests the scenario where the clone function fails during well deployment. We create a mock Well implementation contract MockWellImplementation with a faulty clone function that always returns address(0).

Inside the test case, we call the boreWell function of the aquifer contract, passing the address of the MockWellImplementation as the implementation. We expect this deployment to fail due to the faulty clone function.

We then use staticcall to retrieve the well implementation address for the deployed well. We verify that the call to wellImplementation reverts (indicating a failed deployment) and that the revert message matches the expected error message ("Clone failed: clone").

#0 - c4-pre-sort

2023-07-12T09:56:13Z

141345 marked the issue as high quality report

#1 - 141345

2023-07-13T14:58:33Z

#2 - c4-sponsor

2023-07-24T13:05:14Z

publiuss marked the issue as sponsor disputed

#3 - publiuss

2023-07-24T13:06:35Z

Aquifer calls the clone(...) function in LibClone, not the clone(...) function on the actual implementation. The reporter seems to think that does the latter. For this reason, the report should not be considered valid.

#4 - c4-judge

2023-08-04T21:09:00Z

alcueca marked the issue as grade-a

#5 - alcueca

2023-08-04T21:09:16Z

For cleanliness, do not store the addresses of failed deployments

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter