"Nothing on-chain is private. Not even the stuff that isn't in storage."
| Difficulty | Focus | Est. time |
|---|---|---|
| Intermediate | Sensitive on-chain data · EVM storage layout · bytecode | 30–90 min |
A vault engineer split the master password into three fragments and hid
each one in a different "private" place inside CipherLocker. A wrong guess
doesn't revert: it burns an attempt. Three misses and the locker bricks forever.
- Unlock the locker (
locked == false). - Become the owner of the contract (
owner == player).
Read src/CipherLocker.sol, then complete
script/Exploit.s.sol.
function run() external {
CipherLocker locker = CipherLocker(vm.envAddress("TARGET"));
vm.startBroadcast(PLAYER_PRIVATE_KEY);
// ════════════ YOUR EXPLOIT HERE ════════════
// ═══════════════════════════════════════════
vm.stopBroadcast();
}- Owner: the deployer (the vault engineer)
locked:true- Attempts used:
0of3 - Player balance: 1 ether
- Player:
0x70997970C51812dc3A010C7d01b50e0d17dc79C8(public Anvil dev account #1)
Hint 1 · CipherLocker.sol
Two variables share slot 1. Which one sits in the low-order bytes?Hint 2 · CipherLocker.sol
Dynamic array data lives atkeccak256(slot). How many bytes8 fit in one 32-byte slot?Hint 3 · CipherLocker.sol
immutable variables are not in storage. Where do they go after deployment?Hint 4 · Exploit.s.sol
You can readpasswordHash. That means you can test candidates for free before spending an attempt.Hint 5 · Exploit.s.sol
Immutables are inlined as a 32-bytePUSH32 (opcode 0x7f); a bytesN is left-aligned.Requires Foundry.
git clone --recursive https://github.com/mrstark25/cipher-locker-ctf.git
cd cipher-locker-ctf
# already cloned without --recursive? run: git submodule update --initVerify your solution. The verifier in test/CipherLocker.t.sol deploys a
fresh target with new randomness, runs your Exploit.s.sol, then asserts the
goal. It fails until you solve the challenge.
forge test --match-contract CipherLockerChallenge -vvPlay against a local chain (optional).
anvil # terminal 1
forge script script/Deploy.s.sol --rpc-url http://127.0.0.1:8545 --broadcast
TARGET=<deployed address> forge script script/Exploit.s.sol \
--rpc-url http://127.0.0.1:8545 --broadcastYou can also poke the deployed contract with cast storage and cast code.
Rules
- Edit only
script/Exploit.s.sol. Leavesrc/andtest/as they are. - Reading state is allowed (
vm.load,address.code,cast storage,cast code). - Don't use cheatcodes that write state (
vm.store,vm.etch,vm.deal,vm.prank).
The keys in script/ are Anvil's public dev keys. Never send real funds to them.
- Packed storage slots and byte ordering (
bytes16+uint128in one slot) - Dynamic array slot math and sub-slot packing
constantvsimmutablevs storage, and why immutables are in runtime bytecode- Off-chain verification against a leaked hash (don't waste on-chain attempts)
- Spotting decoys (
MASTER_KEY, thenotesmapping)
No solution is published here, so the puzzle isn't spoiled. Solved it? Open an
issue titled Solved: <your handle> with a short write-up, without code.
Written by Nikhil Baghel. Inspired by the Ethernaut Vault and Privacy levels.