# Alien Codex
You've uncovered an Alien contract. Claim ownership to complete the level.
Things that might help
- Understanding how array (opens new window) storage works (opens new window)
- Understanding ABI specifications (opens new window)
// SPDX-License-Identifier: MIT
pragma solidity ^0.5.0;
import '../helpers/Ownable-05.sol';
contract AlienCodex is Ownable {
bool public contact;
bytes32[] public codex;
modifier contacted() {
assert(contact);
_;
}
function make_contact() public {
contact = true;
}
function record(bytes32 _content) contacted public {
codex.push(_content);
}
function retract() contacted public {
codex.length--;
}
function revise(uint i, bytes32 _content) contacted public {
codex[i] = _content;
}
}
TIP
This level exploits the fact that the EVM doesn't validate an array's ABI-encoded length vs its actual payload.
Additionally, it exploits the arithmetic underflow of array length, by expanding
the array's bounds to the entire storage area of 2^256
. The user is then able
to modify all contract storage.
Both vulnerabilities are inspired by 2017's Underhanded coding contest (opens new window)
You can also solve this CTF problem (opens new window)!
← Delegation Force →