โ† All NFT Flashcard Decks

Smart Contract Security Audits Flashcards

6 cards from real NFT practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Smart Contract Security Audits flashcards as text
  1. An NFT contract's public `mint` function first uses `_safeMint` to transfer a new token to the buyer, then verifies the `msg.value` sent, and finally updates a mapping to record that the user has claimed their token. What is the most critical security vulnerability in this sequence of operations?

    Answer: Reentrancy

    This design violates the 'Checks-Effects-Interactions' pattern. The interaction (the `_safeMint` call, which can trigger an `onERC721Received` hook in a malicious contract) occurs before all state changes (Effects) are complete, specifically before recording that the user has minted. This allows an attacker's contract to call back into the `mint` function repeatedly before the first transaction finishes, bypassing the intended minting limits.

  2. During a smart contract security audit, what is the primary purpose of the static analysis phase?

    Answer: Identifying known vulnerabilities and code quality issues by examining the source code without executing it.

    Static analysis involves using automated tools and manual review to inspect the smart contract's source code for known vulnerability patterns (like reentrancy or integer overflows), style guide violations, and potential bugs. This is done 'statically,' meaning the code is not running on a blockchain during this phase.

  3. Which of the following is considered a critical best practice for securing an NFT contract's privileged functions, such as `withdrawBalance` or `pauseContract`?

    Answer: Ensuring the contract is controlled by a multi-signature wallet instead of a single Externally Owned Account (EOA).

    Using a multi-signature wallet for ownership adds a crucial layer of security by preventing a single point of failure. If one private key is compromised, an attacker still cannot gain control of the contract's privileged functions because multiple signatures are required. `tx.origin` is insecure, public functions are dangerous for admin tasks, and hardcoding an address prevents ownership transfer.

  4. A security audit report for an NFT marketplace flags an issue as "High Severity." What does this classification most likely imply?

    Answer: A critical flaw that could lead to a significant loss of user funds or permanent freezing of assets.

    Severity levels in audit reports categorize vulnerabilities by their potential impact and ease of exploitation. A "High" or "Critical" severity issue indicates a major threat to the contract's functionality or the security of user assets, often leading to direct financial loss.

  5. An auditor is using a tool like Echidna or Foundry's fuzzer that automatically generates a large volume of random inputs to test a contract's functions against a set of defined properties (invariants). What type of security analysis is being performed?

    Answer: Fuzzing (Dynamic Analysis)

    This process describes fuzzing, a form of dynamic analysis. Fuzzing tools execute the contract code with a wide range of random or unexpected inputs to find edge cases where the contract's behavior violates predefined rules or properties (e.g., 'the total supply should never decrease').

  6. Which of the following vulnerabilities is most relevant to an on-chain NFT raffle that uses a future block's `blockhash` as its source of randomness?

    Answer: Predictability and Miner Influence

    Using on-chain data like `block.timestamp` or `blockhash` for randomness is insecure because miners have a degree of influence over these values. A miner participating in the raffle could potentially manipulate the outcome by choosing to mine a block only when it produces a favorable hash, making the result predictable and not truly random.