DEV Community

umbrellayusan
umbrellayusan

Posted on Originally published at crypto-winter.xyz

10 Critical Solidity Vulnerability Patterns You Can Catch in 1 Second (Zero Server Upload)

Smart contract audits take weeks and cost tens of thousands of dollars—yet a surprisingly large share of real-world exploits still come down to 10 repeatable, pattern-level Solidity mistakes that slip into pull requests long before an auditor ever sees the repo.

We built a 100% browser-local, zero-login Solidity 1-Second Quick-Check at crypto-winter.xyz/en/tools/solidity-check/ so Solidity engineers can paste any contract, catch the 10 most common high-severity patterns in under a second without uploading proprietary code to any server, and optionally hand off findings straight into our 6-chain EVM scanner & AI Code Studio.

Here is the exact checklist of all 10 patterns—with vulnerable snippets and minimal defensive fixes.


1. Reentrancy & Unchecked .call{value: ...}("") (SWC-107)

Updating user balances after an external ETH call lets a malicious receiver re-enter withdraw() recursively before the balance is decremented.

// Vulnerable
function withdraw(uint256 amount) external {
    require(balances[msg.sender] >= amount, "insufficient");
    (bool ok, ) = msg.sender.call{value: amount}("");
    balances[msg.sender] -= amount; // state updated too late + ok ignored
}

// Defensive fix (CEI + ReentrancyGuard)
function withdraw(uint256 amount) external nonReentrant {
    require(balances[msg.sender] >= amount, "insufficient");
    balances[msg.sender] -= amount;
    (bool ok, ) = msg.sender.call{value: amount}("");
    require(ok, "ETH transfer failed");
}
Enter fullscreen mode Exit fullscreen mode

2. Authorization via tx.origin (SWC-115)

Using require(tx.origin == owner) allows phishing relay contracts to hijack admin calls whenever an owner interacts with an untrusted contract. Always replace tx.origin with msg.sender.

3. Unguarded delegatecall Context Hijacking (SWC-112)

delegatecall executes target bytecode inside the caller's storage layout. Restrict upgradeable proxy targets strictly to audited, immutable implementations behind a multisig + Timelock, and verify storage slot alignment (ERC-7201 namespaced storage).

4. selfdestruct Backdoor / Post-EIP-6780 Semantics (SWC-106)

Following EIP-6780, selfdestruct no longer deletes bytecode unless invoked in the same transaction as creation, yet still force-transfers ETH and breaks invariants. Remove selfdestruct from production contracts.

5. Missing Access Control on Privileged Functions (CW-MINT)

Functions like mint, setOwner, upgradeTo, or initialize without onlyOwner / onlyRole / initializer (or an uninitialized implementation missing _disableInitializers() in the constructor) are among the highest-severity mainnet drains.

6. Legacy pragma solidity < 0.8.0 Arithmetic Overflow (SWC-101)

Contracts compiled under Solidity 0.4.x–0.7.x silently wrap on integer underflow/overflow unless every operation uses SafeMath. Upgrade to >= 0.8.20 and audit every unchecked {} block carefully.

7. Weak On-Chain Randomness from Block Attributes (SWC-120)

Never derive lottery winners, mint rarity, or reward selection from block.timestamp, block.prevrandao, or block.number % n. Validators/builders can bias or withhold blocks; use Chainlink VRF or commit-reveal.

8. Spot AMM Reserve Pricing (getReserves() / slot0()) (CW-ORACLE)

Reading spot Uniswap v2 getReserves() or v3 slot0() directly as a collateral price oracle makes lending and vault protocols trivially manipulable inside a single flash-loan transaction. Use Chainlink price feeds (with staleness & sequencer-uptime checks) or manipulation-resistant TWAPs.

9. Unchecked Low-Level .call / .send Return Values (CW-UNCHECKED)

Ignoring the boolean return value of .call() or .send() causes silent fund-accounting mismatches. Capture (bool ok, ) and require(ok), and wrap ERC-20 transfers with OpenZeppelin SafeERC20.

10. Division Before Multiplication Precision Loss (CW-DIV)

In Solidity integer arithmetic, (amount / totalShares) * feeBps truncates intermediate quotients to zero for small deposits. Always multiply before dividing ((amount * feeBps) / totalShares) and add Foundry fuzz/invariant tests for dust amounts.


Try It Live in 1 Second (100% Browser-Local)

Every rule in the quick-check runs purely inside your browser—zero code leaves your machine. When you need deeper multi-contract static triage across 6 EVM chains or Foundry regression test generation, you can send findings into the workspace in one click.

Top comments (0)