Skip to content
Tech Interview Prep
Technical interview guide

Smart Contract Security & Common Vulnerabilities

Why smart contract bugs are uniquely costly (immutable, public, and directly holding funds) and the vulnerability classes that recur across major exploits.

Read
50 min
Practice MCQs
25
Interview Q&A
25
Edition
v3
Editorial status
Reviewed

Scope: OWASP Smart Contract Security Verification Standard and Smart Contract Top 10:2026 reviewed 2026-09-04; Solidity latest security guidance; OpenZeppelin Contracts 5.x and Upgrades documentation; Chainlink Data Feeds documentation.

Curated: · Written: · Reviewed:

25 questions

MCQ-10A contract compiled with Solidity 0.8.19 declares `uint256 public total = 500` and runs this function: ```solidity function drain(uint256 amount) external { unchecked { total -= amount; } } ``` `drain(600)` is called and the transaction is mined. What is `total` when the call returns?
MCQ-11A token settles transfers with `fee = amount * 30 / 10_000`, integer division on uint256, no minimum fee, and a smallest allowed transfer of 1 unit. A desk must move 1,000,000 units into one exchange deposit address and can split the move across as many transfers as it wants. Gas aside, which routing does the desk use, and what does the contract collect in fees?
MCQ-1A vault contract gates its emergency withdrawal with `require(tx.origin == owner)`. An attacker who holds no owner key still drains the vault. Which mechanism lets the call pass that check?
MCQ-22A lending protocol holds $12M in user deposits. It has a boolean `paused` state. `pause()` sets it to true and `unpause()` sets it to false; both are `external` with no access control. The `withdraw()` function has a `whenNotPaused` modifier; `deposit()` and `repay()` do not. During an exploit, the team calls `pause()`. In the very next block, an attacker calls `unpause()`. What is the correct assessment of this pause mechanism?
MCQ-8A payout contract on Ethereum mainnet executes `(bool ok, bytes memory ret) = token.call(abi.encodeWithSelector(0xa9059cbb, recipient, 1_000e6)); require(ok, "call failed");`. The token is a non-standard ERC20 that returns `false` instead of reverting when the sender's balance is too low. The payout contract's token balance is 0, the recipient's balance is 0, and the call is made. The outer transaction succeeds, `PaymentSent` is emitted, and the recipient's balance stays 0. Which statement explains the on-chain result?
MCQ-12A lending market on Ethereum mainnet reads a Chainlink ETH/USD aggregator proxy. Its consumer runs `(, int256 answer, , , ) = feed.latestRoundData(); require(answer > 0);` and values collateral as `collateralWei * uint256(answer) / 1e18`, treating the result as 18-decimal USD. The aggregator's `decimals()` returns 8. ETH trades at $2,000, so `answer` is 200000000000. What happens when a borrower posts 1 ETH of collateral?
MCQ-9A vault contract integrates a third-party ERC-20 and calls `token.transferFrom(user, address(this), amount)` inside a deposit function. The token is a fee-on-transfer token: it deducts a 2% fee on every transfer, so the vault receives `amount * 0.98` while the call still returns `true`. The vault credits the user with `amount` in its internal ledger. What is the first production failure this causes?
MCQ-21A vault's invariant test asserts that totalShares (the sum of all user share claims) never exceeds totalAssets. The vault starts with totalAssets = 100 and totalShares = 100. The test deposits 100 USDC. The vault uses a fee-on-transfer token that takes 1% on every transfer, so the vault receives 99 USDC. The deposit function mints shares equal to the amount argument passed by the caller. After the deposit, totalAssets is 199 and totalShares is 200. The test flags a violation. Which diagnosis explains the failure?
MCQ-20A vault (Solidity 0.8.20) mints shares 1:1 with the amount deposited: ```solidity mapping(address => bool) public allowed; mapping(address => uint256) public shares; function deposit(address token, uint256 amount) external { require(allowed[token], "token"); require(amount > 0, "amount"); _deposit(msg.sender, token, amount); } function depositFor(address user, address token, uint256 amount) external { _deposit(user, token, amount); } function _deposit(address user, address token, uint256 amount) internal { IERC20(token).transferFrom(msg.sender, address(this), amount); shares[user] += amount; } ``` `allowed` holds USDC and DAI. An attacker deploys `FakeToken`, whose `transferFrom` returns `true` without moving any tokens, and calls `depositFor(attacker, address(FakeToken), 1_000e18)`. The vault's USDC and DAI balances do not change. What is the outcome of that call?
MCQ-5A vault contract (Solidity 0.8.x) holds 100 ETH: 10 ETH recorded in balances[attacker] and 90 ETH belonging to other users. Its withdraw(uint256 amount) checks balances[msg.sender] >= amount, then runs (bool ok,) = msg.sender.call{value: amount}(""); require(ok); and only after that balances[msg.sender] -= amount. The attacker contract deposits 10 ETH, calls withdraw(1 ether), and its receive() re-enters withdraw(1 ether) while its own counter is below 4, incrementing the counter each time. How much ETH leaves the vault in this transaction, and what does balances[attacker] read when it finishes?
MCQ-6A vault holds poolETH = 200 ETH and totalShares = 100. withdrawETH(ethAmount) is marked nonReentrant: it burns ethAmount * totalShares / poolETH shares, reduces totalShares, sends ethAmount ETH with a call that hands control to the caller, and only after that call returns runs poolETH -= ethAmount. redeemShares(shareAmount) carries no modifier: it computes shareAmount * poolETH / totalShares, burns the shares, sends the ETH, then reduces poolETH. An attacker contract holding 30 shares calls withdrawETH(40), and its receive() calls redeemShares(10). What does the attacker walk away with?
MCQ-7A lending protocol values collateral by calling `pool.get_virtual_price()`. An attacker calls `pool.swap()`; the token's `transfer` hook re-enters `lender.borrow()`, the borrow check passes, and the attacker takes an over-sized loan. `get_virtual_price()` returns the correct price before the swap and again once the swap completes. Which property of the view did the attacker exploit?
MCQ-23A vault contract exposes deposit, borrow, repay, withdraw, and liquidate. A unit test deposits 100, borrows 50, repays 50, withdraws 100, and passes. An invariant fuzzer runs random sequences of these calls by multiple actors with arbitrary amounts and a malicious callback. It finds: attacker deposits 1 wei, borrows near the maximum, donates collateral via callback, liquidates own position, and ends with more tokens than they started. The callback re-entered before the vault updated the attacker's debt. Which statement best explains why the fuzzer found a bug the unit test missed?
MCQ-14An ETH lending market on Ethereum prices ETH collateral by reading the ETH/USDC reserves of a single Uniswap V2 pool: price = reserveUSDC / reserveETH. Borrowers may take up to 75% of collateral value. The pool holds 10,000 ETH and 20,000,000 USDC. In one transaction an attacker flash-borrows 8,000,000 USDC, swaps all of it into the pool for ETH, deposits 500 ETH as collateral, borrows 1,400,000 USDC, repays the flash loan and its fee, and keeps the rest. The market's solvency check passed at every step. Which single property of the market's design made this sequence profitable?
MCQ-13A lending market uses the XYZ/DAI Uniswap v2 pool's spot price as its XYZ collateral oracle. The pool holds 1,000,000 DAI and 1,000 XYZ. The market's maximum LTV is 50%. An attacker flash-borrows 1,000,000 DAI and swaps all of it into the pool in one transaction. What can the attacker do next, and what is the resulting bad debt if the price returns to its pre-swap level?
MCQ-4A UUPS proxy (Solidity 0.8.x) has a V1 implementation that declares, in order: `address owner` (slot 0), `uint256 totalSupply` (slot 1), `mapping(address => uint256) balances` (slot 2). V1's totalSupply is 1,000,000e18 and balances[alice] is 250e18. The team ships V2, which declares `address owner`, then a new `uint256 feeBps`, then `uint256 totalSupply`, then `mapping(address => uint256) balances`, and upgrades in place with no migration. After the upgrade, feeBps() returns 1,000,000e18, totalSupply() returns 0, and balances[alice] returns 0. Which diagnosis fits these readings?
MCQ-19A proxy stores `address implementation` in slot 0 and `address owner` in slot 1, and its fallback runs `implementation.delegatecall(msg.data)`. The implementation declares `address owner` first and `uint256 total` second, and exposes `setOwner(address)`. An attacker calls `setOwner(0xBAD)` on the proxy. What is in the proxy's slot 0 when the call returns, and what happens on the next `withdraw()` call?
MCQ-3A team deploys an upgradeable ERC-20 behind OpenZeppelin Contracts v4.9 `TransparentUpgradeableProxy`, using a helper contract to do it in one transaction: ```solidity contract Deployer { function deploy(address impl, address owner_) external returns (address) { TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(impl, address(this), ""); (bool ok, ) = address(proxy).call( abi.encodeWithSignature("initialize(address)", owner_) ); require(ok, "init failed"); return address(proxy); } } ``` The implementation's `initialize(address)` sets `owner` and carries the `initializer` modifier. What is the result of calling `deploy`?
MCQ-2An ETH lending vault behind an upgradeable proxy is governed by a 48-hour TimelockController (minDelay = 172800) that holds DEFAULT_ADMIN_ROLE on the vault and on the separate PriceRouter. The timelock's PROPOSER_ROLE is a 3-of-5 multisig; its EXECUTOR_ROLE is granted to address(0). The router's setFeed(token, feed) is guarded by OPERATOR_ROLE and takes effect immediately, and the vault's liquidate() reads the current feed on every call. OPERATOR_ROLE is held by one cloud-hosted EOA; GUARDIAN_ROLE, which can pause, is a different key. Three positions hold 4,300 ETH of collateral against 2,900 ETH of debt, each borrowed to the 80% borrow cap with an 85% liquidation threshold, and the market is fully drawn, with 0 ETH of idle liquidity. At block 21,000,000 that EOA's private key leaks. Which single transaction can the leaked key land before any role revocation goes through?
MCQ-25A vault releases funds when ecrecover over keccak256(abi.encode(amount, nonce)) returns the stored owner address, and it records each signature hash so the same signature cannot be submitted twice. Which validation must the recovery path add before that comparison decides the transfer?
MCQ-18An exchange relayer accepts EIP-712 `TransferWithAuthorization` messages for USDC. The same contract address is deployed on Ethereum mainnet (chainId 1) and Polygon (chainId 137). A user signs an authorization for 100 USDC to a merchant, nonce 7, valid until 1735689600. The relayer submits it on Polygon; the transfer succeeds and nonce 7 is marked used in the contract's `mapping(address => mapping(uint256 => bool))` on Polygon. Ten minutes later, an attacker submits the same signature to the contract on Ethereum mainnet. The contract recovers the user's address, sees nonce 7 unused on mainnet, and transfers 100 USDC from the user's mainnet balance. Which change prevents this specific replay?
MCQ-15Alice signs a swap on a constant-product DEX router: 10 ETH in, amountOutMin = 31,680 USDC against a pool quote of 32,000, deadline 20 minutes from signing. She broadcasts to the public mempool; a searcher buys ahead of her in the same block, leaving the pool returning 30,900 USDC for her 10 ETH, and her transaction is mined 11 seconds after she signed. What happens to her swap?
MCQ-16A lottery contract on an EVM chain closes entries at block N and, when its draw function is called in a later block, picks the winner with `uint256(blockhash(N)) % 10000`. The producer of block N holds 40 of the 10,000 outstanding tickets. The producer can reorder the transactions it includes and change the coinbase address, and it can compute the resulting block hash before broadcasting. What should you expect?
MCQ-17An Ethereum contract stores subscribers in a public `address[] subscribers` array and pays them with: ```solidity function payout() external { for (uint i = 0; i < subscribers.length; i++) { payable(subscribers[i]).transfer(1 wei); } } ``` Each iteration costs about 5,000 gas: a cold SLOAD for `subscribers[i]` plus a value transfer. The array has 8,000 entries. The chain's block gas limit is 30,000,000. A user calls `payout()`. What happens?
MCQ-24A payments team's external auditor issued a clean report in March covering release 4.2 (commit 9f3c1a), the production Terraform config, and the March threat model. In May the team ships release 4.4, which adds a webhook endpoint that turns out to be vulnerable to SSRF; an attacker exploits it in June. The team wants to know what the March audit actually established. Which statement is correct?