Challenge
Your goal is to subscribe as a VIP.
Target: http://142.93.103.129:3000
This challenge is an Storage Allocation Description in smart contracts
Vulnerability
1 | function subscribe(address subscriber, uint subscription) public { |
Structs in Solidity default to storage.
-> Subscriber s;
is a storage pointer, declared in a function with no address assigned.
-> This function will overwrite the storage address 0, and 1.
1 | uint private registration_open = 0; |
- subscription -> registration_open
- subscriber -> owner
Exploit
I wrote the function call down to a python code.
1 | # register a wallet |
After setting up everything :
1 | wc.subscribe(wallet,0) # subscribe(subscriber, subscription) |
- subscriber -> owner
- subscription -> registration_open
This call, will make your wallet become owner, and close the registration.
But we are owner now, just open it by calling enableRegistration()
.
1 | wc.enableRegistration() # registration_open = 1 |
That’s all.
feel free to subscribe as VIP, then get the flag.
1 | wc.subscribe(wallet,1) |