Book a free call

7 Smart Contract Vulnerabilities to Check Before Launch

Reentrancy, access control gaps and oracle manipulation are among the flaws that drain smart contracts. Here are the seven to check before launch.

Hertiv engineering teamReviewed by a senior engineer
7 min read
7 Smart Contract Vulnerabilities to Check Before Launch
On this page

Short answer

The most common smart contract vulnerabilities are reentrancy, broken access control, integer overflow, unchecked external calls, oracle manipulation, front-running and weak randomness. Each one has caused real losses on public chains. They are caught with the same routine: read the code line by line, test the edge cases, run static analysis, and get an independent audit before the contract holds real value.

Which smart contract vulnerabilities should you check first?

The vulnerabilities worth checking first are the ones that let an attacker take funds or control from outside the contract, and the ones that appear in the most audits. The table below is a shortlist, not a ranking: any one of them can drain a contract.

Vulnerability What it lets an attacker do Main defence
Reentrancy Call back into a function before it finishes Update state before external calls
Broken access control Call admin functions without permission Role checks on every sensitive function
Integer overflow Wrap balances past their limits Checked arithmetic, current compiler
Unchecked external calls Silently fail and leave state wrong Check every call return value
Oracle manipulation Feed the contract a false price Time-weighted prices, multiple sources
Front-running Copy a trade and jump ahead of it Commit-reveal, slippage limits
Weak randomness Predict the outcome and win Verifiable randomness, no block data

Check these in order of impact, not in order of how clever they sound. A missing access check on a withdrawal function is usually more dangerous than an exotic edge case, because it is simple to exploit and easy to miss in review. An audit, such as the one described in what is a smart contract audit, covers this list and more.

Reentrancy, access control and integer overflow

1. Reentrancy: best for draining funds before balances update

Reentrancy happens when a contract sends funds to an external address before it updates its own records, and the receiving contract calls back into the first contract while the balance is still unchanged. The attacker withdraws again and again until the contract is empty.

The fix is simple and well known: update the state first, then make the external call, and use a reentrancy guard that blocks a function from running twice at once. The classic example is a withdrawal function that sends ether before setting the balance to zero; reversing that order closes the hole.

2. Broken access control: best for taking over admin functions

Broken access control means a function that should only be callable by an owner or an admin can be called by anyone. A mint function, a pause function or a withdrawal function without a permission check is an open door, and attackers scan for these constantly.

Every sensitive function needs an explicit check on who is calling it, usually through a role system where only named addresses hold each role. The check should be tested directly: call each admin function from an address that has no role and confirm it fails.

3. Integer overflow: best for wrapping balances past their limits

Integer overflow happens when arithmetic on a number goes past the largest value its type can hold, and the number wraps around to zero or a small value. An attacker can use that to turn a small balance into a huge one, or to make a check pass that should fail.

Current Solidity versions check arithmetic by default and revert on overflow, which removes most of this risk. Older contracts, or code that deliberately disables the checks to save gas, still carry it. The review step is to find every place the checks are disabled and confirm the maths is safe there.

Unchecked calls, oracles and front-running

4. Unchecked external calls: best for hiding a failed transfer

An unchecked external call is a call to another contract whose result is never checked. If the call fails, the contract carries on as if it succeeded, and the state no longer matches reality. Funds can be marked as sent when they never moved.

The fix is to check the return value of every external call and to revert or handle the failure explicitly. Low-level calls that return a success flag are the usual source of this bug, because they do not revert on failure the way a normal call does.

5. Oracle manipulation: best for feeding a contract a false price

Oracle manipulation happens when a contract reads a price from a single source, usually a decentralised exchange pool, and an attacker moves that price with a large trade in the same block. The contract then lends, liquidates or pays out at the wrong price.

The defence is to never trust one price feed. Use a time-weighted average price, which smooths out single-block moves, and combine it with a second source. Lending protocols that relied on a single pool price have lost funds this way more than once.

6. Front-running: best for copying a trade and jumping ahead

Front-running happens when an attacker sees a pending transaction in the public mempool, copies it, and pays a higher fee so their copy runs first. In a trading contract, the attacker buys before the victim's order pushes the price up, then sells into it.

Complete prevention is hard, because the mempool is public. The practical defences are slippage limits that cap how much worse a price can get, commit-reveal schemes that hide the trade until it is locked in, and private transaction channels where they are available.

Weak randomness and how it is fixed

7. Weak randomness: best for predicting a lottery or a game outcome

Weak randomness means a contract generates a random number from data anyone can see or predict, such as the block timestamp, the block hash or the caller's address. An attacker who can predict the number can win a lottery, a loot drop or a game every time.

Block data is not random, and it is not secret. The fix is to use a verifiable randomness service, where the random value comes with a proof that it was generated fairly, or to have users commit to a choice first and reveal it later so the outcome cannot be known in advance.

Randomness is easy to get wrong because the code looks correct: it calls a function named random and gets a number back. The review question is always where that number comes from and who can influence it. If the answer is block data, it needs replacing. For the wider development process, what is smart contract development covers how these checks fit into a build.

How to check a contract before launch

Checking a contract before launch follows a fixed order, and the audit is the last step, not the first.

  1. Read the code line by line. Two reviewers read every function, asking what happens if each call fails and who can call it.
  2. List the invariants. Write down what must always be true, such as total supply matching the sum of balances, and test each one.
  3. Test the edge cases. Zero amounts, maximum amounts, repeated calls, calls from unexpected addresses, and calls in unexpected order.
  4. Run static analysis. Automated tools flag known patterns, including reentrancy and unchecked calls, and catch what tired eyes miss.
  5. Test on a fork of the live chain. Run the contract against real prices and real token behaviour, not only against clean test data.
  6. Get an independent audit. An external team reads the code with fresh eyes and reports what the builders missed.
  7. Limit the value at risk. Launch with caps on deposits and a pause function, then raise the caps as the contract proves itself.

The caps and the pause function are the cheapest insurance a team can buy. A contract that holds a small amount while it is new loses a small amount if something was missed.

What are the common mistakes?

The most common mistakes in smart contract security are trusting the audit to find everything, skipping the edge cases, and launching with no way to stop the contract.

  • Treating the audit as a guarantee. An audit finds some bugs, not all of them. Teams that stop testing after the audit are the ones that get caught.
  • Skipping the invariants. Without a written list of what must always be true, tests only check the happy path.
  • No pause or upgrade path. A contract that cannot be paused cannot be saved when a bug is found live.
  • Copying code without reading it. Copied code carries the original bugs and the original assumptions, which may not fit the new contract.
  • One price source. A single oracle is a single point of failure, and attackers know exactly where it is.

Key takeaways

  • Reentrancy, access control and overflow are the flaws to check first
  • Update state before external calls, and check every call return value
  • Never trust a single price feed; use time-weighted prices and a second source
  • Block data is not random; use verifiable randomness for lotteries and games
  • Audit last, after line-by-line review, invariant tests and static analysis
  • Launch with deposit caps and a pause function, then raise the caps slowly

Frequently asked questions

What is the most dangerous smart contract vulnerability?

Reentrancy and broken access control cause the largest losses most often, because both let an attacker take funds directly. Reentrancy drains a contract by calling back before balances update, and broken access control lets anyone call admin functions.

Do audits find all smart contract vulnerabilities?

No. Audits find many bugs, but they cannot guarantee a contract is safe. Teams should still review the code line by line, test edge cases, run static analysis and launch with deposit caps and a pause function.

How do you prevent reentrancy in Solidity?

Update the contract's state before making any external call, and add a reentrancy guard that blocks a function from running twice at once. This order means a callback finds the balance already updated.

What is oracle manipulation in smart contracts?

It is when an attacker moves the price in a single decentralised exchange pool so a contract that reads that price lends, liquidates or pays out at a false value. Time-weighted average prices and a second source make the attack much harder.

Can front-running be stopped completely?

Not completely, because pending transactions are visible in the public mempool. Slippage limits, commit-reveal schemes and private transaction channels reduce the damage, but a determined attacker can still copy a visible trade.

Why is weak randomness a vulnerability?

Because block timestamps and hashes are visible and partly predictable, so an attacker can work out the outcome of a lottery or game in advance. Verifiable randomness services generate the value with a proof, which removes the prediction.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a smart contract and want it checked before launch? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Blockchain Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call