Free Blockchain Developer Blockchain Security and Vulnerabilities Questions and Answers 1 — Questions and Answers
Question 1: An attacker creates thousands of pseudonymous nodes on a peer-to-peer network to gain a disproportionately large influence. By controlling a significant number of these fake identities, the attacker aims to out-vote honest participants or disrupt network operations. Which type of attack does this scenario describe?
- Eclipse Attack
- 51% Attack
- Sybil Attack (Correct answer)
- Timejacking Attack
Correct answer: Sybil Attack
A Sybil attack is characterized by a single entity creating a large number of fake identities (nodes) to undermine the authority or reputation system of a network. The goal is to gain enough influence to carry out malicious actions, such as out-voting honest nodes or censoring transactions.
Question 2: A smart contract written in a pre-0.8.0 version of Solidity contains a function to process batch transfers. An attacker discovers that by sending a carefully crafted array of transfer amounts, they can cause the internal loop's counter variable, a `uint8`, to exceed its maximum value of 255. This causes the variable to wrap around to 0, leading to unintended contract behavior. What is this vulnerability called?
- Reentrancy
- Integer Overflow (Correct answer)
- Denial of Service
- Short Address Attack
Correct answer: Integer Overflow
An Integer Overflow occurs when an arithmetic operation attempts to create a numeric value that is larger than what can be stored in its data type. For a `uint8`, the maximum value is 255. Adding 1 to 255 will cause it to 'wrap around' to 0, which can lead to severe vulnerabilities in smart contracts, especially in older Solidity versions that did not have built-in checks.
Question 3: An attacker targets a specific merchant's node on a blockchain network. The attacker floods the node's connection table with IP addresses of malicious nodes they control. As a result, the merchant's node is completely isolated from honest peers and only receives information, such as blocks and transactions, curated by the attacker. This allows the attacker to feed the merchant a fraudulent transaction, leading to a double-spend. Which attack has taken place?
- Sybil Attack
- 51% Attack
- Reentrancy Attack
- Eclipse Attack (Correct answer)
Correct answer: Eclipse Attack
An Eclipse Attack is a network-level attack where an attacker isolates a specific node or group of nodes from the rest of the network. By monopolizing the victim's peer connections, the attacker can filter the information the victim receives, leading to double-spending, selfish mining, or other disruptions.
Question 4: Which of the following describes the primary mechanism of a Timejacking attack?
- Manipulating a node's network time counter by connecting it to malicious peers with inaccurate timestamps, forcing it to accept an alternative blockchain. (Correct answer)
- Gaining control of over 50% of the network's hashing power to unilaterally control the creation of new blocks.
- Creating a large number of fake identities to undermine a network's reputation system and gain disproportionate influence.
- Repeatedly calling a function in a smart contract before the previous invocation has completed its state updates.
Correct answer: Manipulating a node's network time counter by connecting it to malicious peers with inaccurate timestamps, forcing it to accept an alternative blockchain.
A Timejacking attack specifically targets a node's perception of time. An attacker floods a victim node with connections from malicious peers that all report inaccurate timestamps. This can manipulate the victim's network time counter, potentially causing it to reject valid blocks from the honest network and accept a fraudulent, alternative chain from the attacker.
Question 5: A malicious actor gains control of more than 50% of a Proof-of-Work blockchain's total hashing power. With this majority control, they are able to mine a private version of the blockchain faster than the rest of the network. They then broadcast this longer chain, which causes the honest network to discard its version and accept the attacker's, allowing the attacker to reverse their own previous transactions. This vulnerability is known as a:
- Reentrancy Attack
- 51% Attack (Correct answer)
- Sybil Attack
- Eclipse Attack
Correct answer: 51% Attack
A 51% Attack, also known as a majority attack, occurs when a single entity or group controls more than 50% of a blockchain's consensus power (e.g., hashing power in PoW). This majority control allows them to manipulate the blockchain, most notably by creating a longer chain in private and then releasing it to orphan the honest chain, enabling double-spending of their own funds.
Question 6: A DeFi lending protocol's smart contract has a `withdraw()` function that follows this sequence: 1. Checks the user's balance. 2. Sends the Ether to the user's address. 3. Updates the user's balance to zero. An attacker creates a malicious contract with a fallback function. When the attacker calls `withdraw()`, their fallback function is triggered by the incoming Ether and immediately calls the `withdraw()` function again before the original call can update the balance. What type of vulnerability is being exploited?
- Integer Underflow
- Denial of Service
- Reentrancy (Correct answer)
- Timejacking
Correct answer: Reentrancy
This is a classic example of a Reentrancy attack. The vulnerability exists because the contract sends Ether (an external call) before it updates its internal state (the user's balance). An attacker's contract can use its fallback function to 're-enter' the vulnerable function and repeatedly withdraw funds until the contract is drained or the gas limit is hit.
An attacker creates thousands of pseudonymous nodes on a peer-to-peer network to gain a disproportionately large influence.
By controlling a significant number of these fake identities, the attacker aims to out-vote honest participants or disrupt network operations.
Which type of attack does this scenario describe?