In this challenge, you need to figure out a password that’s stored “privately” in the contract, with an additional twist of bit manipulation!
The contract has:
mintFlag function that requires a partially masked version of the passwordbytes32 password = await provider.getStorageAt(contractAddress, 1);
bytes32 count = await provider.getStorageAt(contractAddress, 2);
2. Calculate the mask and new password:
bytes32 mask = ~(bytes32(uint256(0xFF) << ((31 - (uint256(count) % 32)) * 8)));
bytes32 newPassword = password & mask;
3. Call mintFlag with the calculated password:
challenge9.mintFlag(newPassword);
Congratulations! You've learned that "private" doesn't mean "secret" in blockchain! 🎉
Remember: Never store sensitive information directly in blockchain storage, even if marked as private. Use proper cryptographic techniques if you need to maintain secrets!
I couldn’t find any specific examples of this vulnerability in the wild, but it’s still a good lesson in blockchain privacy.
This demonstrates: