2023 Business CTF: Paid Contr-actor
Challenge Information
| Attribute | Details |
|---|---|
| Event | 2023 Business CTF |
| Category | Blockchain |
| Challenge | Paid Contr-actor |
| Difficulty | Very Easy |
Summary
As a newly enlisted expert in blockchain security for the United Nations of Zenium military, you must complete paperwork by “signing” a contract. The contract has a simple condition that must be met to mark yourself as signed and complete the enrollment.
Analysis
The challenge provides two smart contracts:
Setup.sol:
function isSolved() public view returns (bool) { return TARGET.signed();}Contract.sol:
bool public signed;
function signContract(uint256 signature) external { if (signature == 1337) { signed = true; }}The vulnerability is trivial - the “signature” is just a magic number (1337) with no actual cryptographic verification.
Solution
The solution is straightforward:
- Connect to the blockchain using the provided RPC endpoint and private key
- Get the target Contract address from the Setup contract
- Call
signContract(1337)on the target contract with the magic number - The
signedboolean will be set to true - Call
isSolved()on the Setup contract to verify success
Simple exploit code:
# Call the contract with the magic numbercontract.functions.signContract(1337).transact()
# Verifyassert contract.functions.signed().call() == TrueKey Takeaways
- Not all blockchain challenges require complex cryptography
- Magic numbers and hardcoded values are security anti-patterns
- Proper access control should replace simple condition checks
- This serves as a warm-up challenge for blockchain CTF participants
- Always validate input properly in smart contracts