Don't Get Rekt

Smart contract bugs / What does it trust?

Missing input validation

The contract trusts an address or a value that the caller gives: a fake token, a fake pool, a fake market. The attacker passes a contract they wrote.

OWASP SC05:2026 · 62 real exploits · $346.6M lost

How the attack works

  1. A function takes an address parameter: a token, a pair, a vault, a market, a receiver.
  2. The function does not check that the address is one that the protocol knows.
  3. The attacker deploys a contract that returns any value they want (a balance, a price, a successful transfer) and passes its address.
  4. The protocol credits the attacker with real funds against a fake deposit. Variants: no zero check, no bounds on a fee or a ratio, arrays of different length.

Vulnerable and fixed code

Vulnerable
function deposit(address pool, uint256 amt) external {
    IPool(pool).transferFrom(msg.sender, address(this), amt); // fake pool returns true
    uint256 value = IPool(pool).valueOf(amt);                  // fake pool says 1e30
    credit[msg.sender] += value;
}
Fixed
mapping(address => bool) public allowedPool;

function deposit(address pool, uint256 amt) external {
    require(allowedPool[pool], "unknown pool");
    require(amt > 0, "zero");
    uint256 before = IERC20(asset).balanceOf(address(this));
    IERC20(asset).safeTransferFrom(msg.sender, address(this), amt);
    uint256 received = IERC20(asset).balanceOf(address(this)) - before;
    credit[msg.sender] += IPool(pool).valueOf(received);
}

Review checklist

  • Check every address parameter against a whitelist or a factory registry.
  • Measure the balance before and after a transfer. Do not trust the amount in the call or the return value of an unknown contract.
  • Check zero values, zero addresses, array lengths, and the upper and lower bounds of fees and ratios.
  • Validate inputs in admin functions too: a wrong value from a tired admin can drain a protocol.

How to test for it

  • Fuzz every external function with random addresses and amounts.
  • Write a test with a malicious mock token or pool that returns false values. The call must revert.

Real exploits (62)

  • Jan 27, 2022BNB Chain$80.0MAudited

    Qubit Finance: Qubit Finance lost about $80M on BSC because the legacy QBridge deposit function accepted a zero tokenAddress, so a deposit succeeded without any ETH being locked.

    Root cause and fix

    Vulnerable code: QBridgeHandler · deposit()

    After depositETH was added, the tokenAddress for ETH was set to the zero address. The old deposit function stayed in the contract. In QBridgeHandler, tokenAddress.safeTransferFrom(depositer, address(this), amount) is a call to an address with no code, so it did not revert and the deposit finished for any amount. The attacker called deposit on Ethereum, got about 77,162 qXETH minted on BSC with no ETH locked, used it as collateral, and borrowed about $80M of assets.

    What would have stopped it: Remove or disable the legacy deposit function when a replacement such as depositETH is added. Check that tokenAddress is a whitelisted token with contract code, and that the balance actually received matches the amount, before crediting a deposit. Add tests for the zero-address token case.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Mar 23, 2022SolanaRust$48.0M

    Cashio: Cashio on Solana lost about $48M to an infinite mint of CASH because collateral account validation was incomplete, so fake accounts were accepted.

    Root cause and fix

    Before minting CASH, the contract checked that the deposited collateral matched what it expected. For LP tokens via saber_swap.arrow, the .mint field was never validated. The attacker built a fake root account and a chain of fake accounts that were only checked against each other, so they all passed. A later update says the attacker also bypassed depositor_source with a fake bank to pass the common.collateral check. They minted 2B CASH, swapped it for UST and USDC, and bridged the proceeds to Ethereum.

    What would have stopped it: Validate every account in the collateral chain against a trusted root, such as a hardcoded or whitelisted mint and bank address, and not only against each other. Add tests that pass in fake accounts and check that minting fails.

    rekt.news article ↗

  • Apr 19, 2024Arbitrum$44.7MFlash loanAudited

    Hedgey Finance: Hedgey Finance lost about $44.7M across Arbitrum ($42.6M) and Ethereum ($2.1M) because createLockedCampaign did not validate user-supplied claimLockup parameters, so the contract approved tokens to the attacker.

    Root cause and fix

    Vulnerable code: Hedgey Token Claim Contract (ClaimCampaigns) · createLockedCampaign()

    The createLockedCampaign function did not validate the claimLockup parameter supplied by the caller. The attacker took a $1.3M USDC flash loan from Balancer and used it to create a campaign. They set the parameter so that the contract approved USDC transfers to the attacker's contract. In a second transaction, they used that approval to pull tokens out of the contract. The attack was run as two separate transactions, likely to avoid being front-run.

    What would have stopped it: Validate and whitelist every user-supplied parameter in campaign creation. Never let caller input decide the approval spender or target. Add tests that pass malicious claimLockup values and check that no approval to an arbitrary address is created.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Nov 30, 2021Ethereum$31.4MAudited

    MonoX: MonoX lost about $31.4M on Polygon and Ethereum because swaps allowed the same token as tokenIn and tokenOut, which let the attacker inflate the MONO price.

    Root cause and fix

    Vulnerable code: Monoswap · swapTokenForExactToken

    The swapTokenForExactToken function in the Monoswap contract did not stop the same asset from being used as both tokenIn and tokenOut. The price update function _updateTokenInfo ran after each swap, and the tokenOut price overwrote the tokenIn price. The attacker swapped MONO for MONO many times in a loop, which pumped the MONO price. They then used the overvalued MONO to buy almost all the other tokens in the pools. They did this on Polygon and, 17 minutes later, on Ethereum.

    What would have stopped it: Require tokenIn != tokenOut in every swap function. Add invariant and fuzz tests that check a swap cannot change a token's price in the attacker's favour, including swaps of a token against itself.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Nov 22, 2020Ethereum$19.7MFork of Yearn yVaultsAudited, bug out of scope

    Pickle Finance: Pickle Finance lost 19.7 million DAI from its cDAI jar because swapExactJarForJar accepted attacker-made fake jars with no whitelist.

    Root cause and fix

    Vulnerable code: ControllerV4 · swapExactJarForJar

    The Controller's swapExactJarForJar function let users swap assets between Jars. It did not check that the Jars passed in were on a whitelist. The attacker created a fake Pickle Jar and used the swap to move the real cDAI jar's funds out. The vulnerable code was in the newly added ControllerV4, which came after the audits. Haechi says swapExactJarForJar was outside the scope of its audit.

    What would have stopped it: Check every jar address passed to swapExactJarForJar against a whitelist of approved jars. Re-audit after each code change such as ControllerV4, and test with fake or malicious jar contracts.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Apr 16, 2026NEARRust$18.4MAudited, bug out of scope

    Rhea Finance: Rhea Finance on NEAR lost about $18.4M when its margin trading code summed intermediate swap minimums from an attacker-built route of fake pools and never checked the real swap output.

    Root cause and fix

    Vulnerable code: Burrowland (margin_trading.rs) · get_token_out()

    Burrowland's get_token_out() computed the required minimum position amount by adding up min_amount_out across every swap action. It did not treat intermediate hops, where one step's output is the next step's input, as non-final. The attacker built 25 pools of fake tokens and a route that bounced through USDC many times, so the minimum became inflated by millions of times and still passed the Pyth-based is_min_amount_out_reasonable() check. The swap then returned only 7,925 units against a validated minimum of about 3.26e22. on_open_trade_return() credited whatever arrived, with no re-check of the minimum, health factor or leverage, and rolled back only if the swap failed outright. The result was real assets borrowed against worthless positions. The attacker then removed liquidity from the fake pools and consolidated the funds.

    What would have stopped it: Compute the expected output only from the terminal swap action, and reject routes that reuse tokens or pass through unwhitelisted pools or tokens. In on_open_trade_return(), enforce that the actual received amount is at least the validated minimum, and re-run the health-factor and leverage checks before crediting the position.

    rekt.news article ↗

  • May 28, 2025Ethereum$12.0MAudited, bug out of scope

    Cork Protocol: Cork Protocol lost about $12 million (3,761 wstETH) because its CorkHook beforeSwap accepted attacker-supplied hook data and fake tokens without validation, letting exchange rates be manipulated.

    Root cause and fix

    Vulnerable code: CorkHook · beforeSwap

    CorkHook's beforeSwap could be called by anyone and accepted custom hook data for CorkCall operations without checking the arguments, such as the paymentToken. Cork also let users create markets with arbitrary redemption assets. The attacker made a fake market that used real DS tokens from a legitimate market as its redemption asset, and used fake tokens to skew the exchange rate calculation, which fell back to a default value. They received DS and CT tokens, redeemed them through the real PSM for 3,761 wstETH, and converted it to ETH.

    What would have stopped it: Restrict beforeSwap so only the pool manager can call it, and validate all hook data, including token addresses, against a whitelist. Restrict which assets can be used as redemption assets, and don't let exchange rate logic fall back to a default value for unverified tokens. Include the hook contracts in audit scope.

    rekt.news article ↗

  • Mar 28, 2024Ethereum$11.6MFlash loanFork of LiquityAudited, bug out of scope

    PrismaFi: PrismaFi lost about $11.6M (3258 wstETH) because MigrateTroveZap's onFlashloan() did not validate its input data, letting an attacker close and open troves for other users.

    Root cause and fix

    Vulnerable code: MigrateTroveZap · onFlashloan()

    The onFlashloan() function in MigrateTroveZap did not validate the input data it received. The attacker could make it call closeTrove and openTrove on arbitrary addresses, including troves they did not own. Users had approved the zap as a delegate for migration. The attacker closed a victim's trove, which refunded 1745 wstETH to the zap. They then opened a new trove using 463 wstETH, which left about 1282 wstETH in the zap. They then opened their own trove, migrated it through the zap using the leftover collateral, and closed it to take the profit. They repeated this several times.

    What would have stopped it: In onFlashloan(), check that the trove owner in the callback data is the original caller, and that the flash loan was started by the zap itself. Add tests that try to run the zap on troves owned by other accounts. Audit every new or changed contract, including migration helpers, before it receives user approvals.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Jul 11, 2026Hedera$9.1MAudited, bug out of scope

    Bonzo Finance: Bonzo Finance on Hedera lost about $9.05M after Supra's oracle verifier accepted a forged price update with an all-zero BLS signature and public key.

    Root cause and fix

    Vulnerable code: Supra verifier (0.0.4323006) · requireHashVerified_V2

    Supra's pull oracle verifier looked up a committee public key by ID. The attacker used committee ID 2, outside the populated range, and the lookup returned an all-zero key instead of reverting. The attacker also sent a zero signature. Both are the BLS identity element, so the pairing precompile correctly returned true. The verifier never rejected the out-of-range ID, identity-element inputs or off-curve points. The attacker deposited 250 SAUCE (about $3) into Bonzo Lend, then submitted a forged price about twelve orders of magnitude too high. Eight seconds later they borrowed 6.63M USDC and 34.5M WHBAR against that collateral.

    What would have stopped it: Validate the committee index range and revert on a missing entry. Reject identity-element (zero) public keys and signatures, and check that points are on the curve, before calling the pairing precompile. Supra said the identity-element check alone would have stopped this. Lending protocols should also add sanity bounds or deviation checks on oracle prices, and a second price source for each asset.

    rekt.news article ↗

  • Jul 2, 2022SolanaRust$8.8MFlash loanAudited

    Crema Finance: Crema Finance, a Solana concentrated liquidity AMM, lost about $8.8M when an attacker passed a fake price tick account that the claim method did not validate, and so claimed inflated LP fees.

    Root cause and fix

    Vulnerable code: claim

    The account that stores price tick data, which is used to calculate LP fees, had faulty owner validation. The attacker created a fake tick account with forged data. They used flash loans to add liquidity, then withdrew it and claimed the fees that the fake data said they were owed. The audit by Bramah Systems found the same flaw in the swap method and it was fixed. The claim method had the same flaw and was missed.

    What would have stopped it: Check that every account passed in is owned by the program and is the expected tick account (owner and address or PDA derivation) in every instruction that reads it, including claim. After an audit finding, search the whole codebase for the same pattern and add tests that pass fake accounts.

    rekt.news article ↗

52 more examples in the full guide.

References

Send a new scam

Describe what happened, or paste a link to the post. Do not include seed phrases, keys or passwords.

Open the post ↗