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 QuillCTF's CollatzPuzzle exploit #22

Open
leovct opened this issue Jan 26, 2024 · 0 comments
Open

Fix QuillCTF's CollatzPuzzle exploit #22

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

Comments

@leovct
Copy link
Owner

leovct commented Jan 26, 2024

#21 modifies the exploit CI job to run all the exploits except the CollatzPuzzle one because it is failing. Find out what is the problem and how to fix it.

This may have to do with the foundry-huff library? It looks like it is now using the Shanghai evm version why may be at the origin of the problem.

$ forge test -vvvv --match-contract CollatzPuzzle
[⠆] Compiling...
[⠔] Compiling 4 files with 0.8.23
[⠒] Solc 0.8.23 finished in 2.23s
Compiler run successful!
2024-01-26T09:55:50.114435Z ERROR cheatcodes: non-empty stderr input=["./lib/foundry-huff/scripts/binary_check.sh"] stderr="warning node-gyp > make-fetch-happen > cacache > @npmcli/[email protected]: This functionality has been moved to @npmcli/fs\n"
2024-01-26T09:55:50.160261Z ERROR cheatcodes: non-empty stderr input=["huffc", "src/../test/QuillCTF/__TEMP__wdrjwjkvtvhklggxmjmeecsgvyzxecuqCollatzHelper.huff", "-b", "-e", "shanghai"] stderr="error: Found argument '-e' which wasn't expected, or isn't valid in this context\n\n\tIf you tried to supply `-e` as a value rather than a flag, use `-- -e`\n\nUSAGE:\n    huffc [OPTIONS] [PATH] [SUBCOMMAND]\n\nFor more information try --help\n"

Running 1 test for test/QuillCTF/CollatzPuzzleExploit.t.sol:CollatzPuzzleExploit
[FAIL. Reason: revert: bad code size!] testExploit() (gas: 10156)
Traces:
  [2454824] CollatzPuzzleExploit::setUp()
    ├─ [165408] → new CollatzPuzzle@0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f
    │   └─ ← 858 bytes of code
    ├─ [2059491] → new HuffConfig@0x2e234DAe75C793f67A35089C9d99245E1C58470b
    │   └─ ← 10226 bytes of code
    ├─ [118191] HuffConfig::deploy("../test/QuillCTF/CollatzHelper")
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/binary_check.sh"])
    │   │   └─ ← 0x01
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/rand_bytes.sh"])
    │   │   └─ ← 0xce4ea5eac6899bcbef8d092227f0d68e
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/file_writer.sh", "src/../test/QuillCTF/__TEMP__wdrjwjkvtvhklggxmjmeecsgvyzxecuqCollatzHelper.huff", "\n"])
    │   │   └─ ← 0x
    │   ├─ [0] VM::ffi(["./lib/foundry-huff/scripts/read_and_append.sh", "src/../test/QuillCTF/__TEMP__wdrjwjkvtvhklggxmjmeecsgvyzxecuqCollatzHelper.huff", "src/../test/QuillCTF/CollatzHelper.huff"])
    │   │   └─ ← 0x
    │   ├─ [0] VM::ffi(["huffc", "src/../test/QuillCTF/__TEMP__wdrjwjkvtvhklggxmjmeecsgvyzxecuqCollatzHelper.huff", "-b", "-e", "shanghai"])
    │   │   └─ ← 0x
    │   ├─ [0] VM::prank(HuffConfig: [0x2e234DAe75C793f67A35089C9d99245E1C58470b])
    │   │   └─  ()
    │   ├─ [0] VM::ffi(["rm", "src/../test/QuillCTF/__TEMP__wdrjwjkvtvhklggxmjmeecsgvyzxecuqCollatzHelper.huff"])
    │   │   └─ ← 0x
    │   ├─ [0] → new <unknown>@0xffD4505B3452Dc22f8473616d50503bA9E1710Ac
    │   │   └─ ← 0 bytes of code
    │   └─ ← 0xffD4505B3452Dc22f8473616d50503bA9E1710Ac
    └─  ()

  [10156] CollatzPuzzleExploit::testExploit()
    ├─ [2996] CollatzPuzzle::callMe(0xffD4505B3452Dc22f8473616d50503bA9E1710Ac) [staticcall]
    │   └─ ← revert: bad code size!
    └─ ← revert: bad code size!

Test result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 5.22s
 
Ran 1 test suites: 0 tests passed, 1 failed, 0 skipped (1 total tests)

Failing tests:
Encountered 1 failing test in test/QuillCTF/CollatzPuzzleExploit.t.sol:CollatzPuzzleExploit
[FAIL. Reason: revert: bad code size!] testExploit() (gas: 10156)

Encountered a total of 1 failing tests, 0 tests succeeded
@leovct leovct added the bug Something isn't working label Jan 26, 2024
@leovct leovct changed the title Fix CollatzPuzzle exploit Fix QuillCTF's CollatzPuzzle exploit 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