Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Ethernaut's Delegation exploit #24

Open
leovct opened this issue Sep 19, 2024 · 0 comments
Open

Fix Ethernaut's Delegation exploit #24

leovct opened this issue Sep 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@leovct
Copy link
Owner

leovct commented Sep 19, 2024

$ forge test -vvv --match-contract Delegation                                                                                                                                                      
[⠊] Compiling...
No files changed, compilation skipped

Ran 1 test for test/Ethernaut/DelegationExploit.t.sol:DelegationExploit
[FAIL. Reason: assertion failed] testExploit() (gas: 37866)
Logs:
  Target contract deployed
  Current owner: 0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946
  New owner: 0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946
  Error: a == b not satisfied [address]
        Left: 0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946
       Right: 0x5Bf3eeB5560eEACC941C553320999006D27dD42b

Traces:
  [37866] DelegationExploit::testExploit()
    ├─ [2303] Delegation::owner() [staticcall]
    │   └─ ← [Return] deployer: [0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946]
    ├─ [0] console::log("Current owner: %s", deployer: [0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946]) [staticcall]
    │   └─ ← [Stop] 
    ├─ [0] VM::startPrank(exploiter: [0x5Bf3eeB5560eEACC941C553320999006D27dD42b])
    │   └─ ← [Return] 
    ├─ [4983] Delegation::pwn()
    │   ├─ [0] exploiter::pwn() [delegatecall]
    │   │   └─ ← [Stop] 
    │   └─ ← [Stop] 
    ├─ [0] VM::stopPrank()
    │   └─ ← [Return] 
    ├─ [303] Delegation::owner() [staticcall]
    │   └─ ← [Return] deployer: [0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946]
    ├─ [0] console::log("New owner: %s", deployer: [0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946]) [staticcall]
    │   └─ ← [Stop] 
    ├─ emit log(val: "Error: a == b not satisfied [address]")
    ├─ emit log_named_address(key: "      Left", val: deployer: [0xaE0bDc4eEAC5E950B67C6819B118761CaAF61946])
    ├─ emit log_named_address(key: "     Right", val: exploiter: [0x5Bf3eeB5560eEACC941C553320999006D27dD42b])
    ├─ [0] VM::store(VM: [0x7109709ECfa91a80626fF3989D68f67F5b1DD12D], 0x6661696c65640000000000000000000000000000000000000000000000000000, 0x0000000000000000000000000000000000000000000000000000000000000001)
    │   └─ ← [Return] 
    └─ ← [Stop] 

Suite result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 582.42µs (94.83µs CPU time)

Ran 1 test suite in 167.48ms (582.42µs CPU time): 0 tests passed, 1 failed, 0 skipped (1 total tests)

Failing tests:
Encountered 1 failing test in test/Ethernaut/DelegationExploit.t.sol:DelegationExploit
[FAIL. Reason: assertion failed] testExploit() (gas: 37866)

Encountered a total of 1 failing tests, 0 tests succeeded
@leovct leovct added the bug Something isn't working label Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant