Challenge - 5 Problems
Blockchain Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Reentrancy Attack Output
What is the output of this simplified Solidity-like pseudocode when a reentrancy attack occurs?
Blockchain / Solidity
contract Vulnerable {
mapping(address => uint) public balances;
function deposit() public payable {
balances[msg.sender] += msg.value;
}
function withdraw(uint amount) public {
require(balances[msg.sender] >= amount);
(bool success,) = msg.sender.call{value: amount}("");
require(success);
balances[msg.sender] -= amount;
}
}
// Attacker calls withdraw repeatedly before balances[msg.sender] is updated.Attempts:
2 left
💡 Hint
Think about what happens if the external call happens before the balance is updated.
✗ Incorrect
Because the balance is updated after sending funds, the attacker can call withdraw recursively before the balance decreases, draining all funds.
❓ Predict Output
intermediate1:30remaining
Integer Overflow Result
What is the value of variable `total` after running this Solidity-like pseudocode?
Blockchain / Solidity
uint8 a = 250; uint8 b = 10; uint8 total = a + b; // uint8 max is 255
Attempts:
2 left
💡 Hint
Remember uint8 can only hold values from 0 to 255 and wraps around on overflow.
✗ Incorrect
Adding 250 + 10 equals 260, but uint8 max is 255, so it wraps around: 260 - 256 = 4.
🔧 Debug
advanced2:00remaining
Fix the Timestamp Dependency Bug
This smart contract uses block.timestamp to decide a winner. What is the main vulnerability here?
Blockchain / Solidity
contract Lottery {
address public winner;
function pickWinner() public {
require(block.timestamp % 2 == 0, "Not even timestamp");
winner = msg.sender;
}
}Attempts:
2 left
💡 Hint
Think about who controls the block timestamp and how it affects randomness.
✗ Incorrect
Miners can slightly manipulate block.timestamp, allowing them to influence the outcome unfairly.
📝 Syntax
advanced1:30remaining
Identify the Syntax Error in Access Control
Which option contains the correct Solidity code to restrict a function to the contract owner?
Attempts:
2 left
💡 Hint
Look for correct syntax including semicolons and the placeholder _; in modifiers.
✗ Incorrect
Option D correctly uses require with an error message and includes the _; placeholder properly.
🚀 Application
expert2:30remaining
Detecting Front-Running Vulnerability
Which of the following code snippets is vulnerable to front-running attacks in a blockchain environment?
Attempts:
2 left
💡 Hint
Consider the order of state changes and how miners or attackers can exploit it.
✗ Incorrect
Option A updates highestBidder before highestBid, allowing an attacker to front-run and submit a higher bid before state is fully updated.