Why smart contract security is a different discipline
In an ordinary application, you find a defect and ship a patch within hours, read the logs, and restore data from backup. A smart contract on a public network changes that at the root. ethereum.org's security guide points out that deployed contract code usually cannot be changed to patch a security flaw, and that assets stolen from contracts are extremely difficult to trace and mostly irrecoverable.
The case everyone returns to is The DAO in 2016: an insecure contract was drained of more than 3.6 million ether, and the response was a fork of the Ethereum network that moved the funds to a new contract — a fork part of the community rejected, which is how Ethereum Classic came to exist. One programming mistake became a decision for an entire network.
Smart contract security therefore starts from the assumption that fixing things after deployment is hard or impossible, and that whatever can be found must be found before it.
A note: this article is technical education, not investment, financial or legal advice. Any contract touching financial assets, digital tokens or fundraising is subject to independent legal and regulatory review before design.
What the 2025 numbers say about where losses come from
Chainalysis, the blockchain analytics firm, puts cryptocurrency theft at over $3.4 billion from January to early December 2025, with the February compromise of Bybit alone accounting for $1.5 billion.
The more useful lesson is not the total but the source. Chainalysis reports that centralised services are suffering increasingly large losses from attacks on private key infrastructure and signing processes; that these compromises, though infrequent, accounted for 88% of losses in the first quarter of 2025; and that attackers have developed ways to trick legitimate signers into authorising malicious transactions.
For anyone building a smart contract, the practical reading is that code is part of the problem, not all of it. Who holds the power to upgrade, pause or withdraw, how their keys are stored, and how a signer confirms what they are actually signing are security questions of the same weight.
The OWASP Smart Contract Top 10
OWASP, the open application-security community, publishes a Smart Contract Top 10, currently the 2025 edition, which it describes as an awareness document for Web3 developers and security teams. In order: access control vulnerabilities, price oracle manipulation, logic errors, lack of input validation, reentrancy attacks, unchecked external calls, flash loan attacks, integer overflow and underflow, insecure randomness, and denial of service.
Notice that the top of the list is not an exotic technical trick but what is at heart a governance question: who is allowed to do what? And number three, logic errors, means a contract can be free of every known vulnerability class and still lose money because it calculates something in a way its owners never intended.
Use the list as a review tool, not a checklist to stop at. It describes where losses have recurred; it does not enumerate everything that could go wrong in your particular contract.
Privileged roles and keys: the single point of failure
ethereum.org warns that registering a single address as a contract's owner introduces centralisation risk and a single point of failure: if that account's keys are compromised, the attacker controls the contract. The usual alternatives are role-based permissions so that no one party holds everything, multi-signature wallets for sensitive operations, and a time delay between approving a change and executing it so users can see it coming.
The Solidity documentation is equally direct about never using tx.origin for authorisation, because an intermediary contract can exploit it to act in the wallet owner's name.
Before discussing code-level flaws at all, write a permissions map: every sensitive function, who can call it, where that key is held, and what happens if it is lost or stolen. That map alone surfaces a large share of the risk before anyone reads a line of code.
Reentrancy, external calls and arithmetic
When your contract calls another, its execution pauses until the call returns. A reentrancy attack exploits that pause: the external contract calls back into the same function before the balance has been updated and withdraws more than once. The remedy recommended by both the Solidity documentation and ethereum.org is the Checks-Effects-Interactions pattern: verify conditions first, update internal state second, and make the external call last.
External calls can also fail silently if their return value is not checked, which is why unchecked external calls have their own entry in the OWASP list.
On arithmetic, since Solidity 0.8.0 operations revert on overflow and underflow rather than silently wrapping. But code marked unchecked deliberately restores the old wrapping behaviour to save gas, so every such block deserves its own review — as do contracts compiled with older versions.
Upgradeable contracts: flexibility with a price
Many projects deploy upgradeable contracts behind a proxy so they can fix defects later. That flexibility solves one problem and opens three.
First, the upgrade permission becomes the most dangerous permission in the system: whoever holds it can replace the contract's entire logic, which brings every question about keys and multi-signature control straight back.
Second, initialisation. OpenZeppelin's documentation explains that upgradeable contracts cannot use constructors and rely instead on an initialiser called once, and that an uninitialised contract can be taken over by an attacker — whether it is the proxy or the implementation contract behind it.
Third, storage layout. When upgrading, you cannot change the order in which state variables are declared, nor their types; otherwise the new version reads mixed-up storage values, which OpenZeppelin warns can cause critical errors. Every upgrade therefore needs an automated storage-layout comparison before it is approved.
Test before the audit — and the audit is not the end
Systematic testing starts with unit tests that cover the success path, the rejection paths and the edge cases of every function. Next comes fuzzing, where tools such as Foundry generate random inputs and run a test many times to find what nobody anticipated. Then invariant testing, which checks conditions that must hold whatever sequence of operations occurs — for instance, that the sum of balances never exceeds what the contract holds. ethereum.org adds formal verification, which unlike ordinary testing can prove the absence of errors relative to a formal specification written for the security properties you need.
After that comes the independent audit, and it matters. Yet ethereum.org itself cautions against treating it as a silver bullet: an audit won't catch every bug and is essentially an additional round of review. It suggests bug bounty programmes as a continuing form of external review once the contract is live.
Order matters. A contract that reaches its auditor with thorough tests, an invariants document and a permissions map receives a deeper review, because the auditor's time goes to what tools cannot find rather than to what could have been caught in-house.
How DataWork can help
DataWork offers smart contract testing and quality assurance. The work includes a framing session on what each contract guards, a specification-versus-implementation review, unit and integration tests, fuzz and invariant testing, manual code review against known weakness classes supported by static analysis, a review of privileged roles, upgrade paths and storage layout, and testing against a fork of live network state with a testnet deployment rehearsal. You receive a severity-ranked findings report, a deployment and rollback runbook, and a re-test once fixes land.
The limits are explicit. We do not issue a formal audit certificate: an independent audit is a separate engagement you contract directly, and our role is to prepare the code for it. We do not assert that code is free of vulnerabilities, because systematic testing lowers risk but cannot prove the absence of defects. We give no legal, regulatory or investment advice, and we do not hold private keys or handle user funds.
If you are still building, our smart contract development service writes the contract and its tests together from the start. And if the question comes earlier — whether you need a blockchain at all — our blockchain strategy service begins there.
Key takeaways
- Deployed smart contracts usually cannot be changed and stolen assets are rarely recovered, so defects have to be found before launch.
- The largest 2025 losses came from attacks on keys and signing processes; a permissions map and multi-signature control are part of contract security.
- The OWASP Smart Contract Top 10 starts with access control, and it is a review tool, not a sufficient checklist.
- For upgradeable contracts: protect the upgrade role, never leave a contract uninitialised, and never reorder storage.
- Unit, fuzz and invariant tests come before the independent audit, and the audit will not catch every bug.
Frequently asked questions
What are the most common smart contract vulnerabilities?
According to the OWASP Smart Contract Top 10 (2025): access control flaws, price oracle manipulation, logic errors, missing input validation, reentrancy, unchecked external calls, flash loan attacks, integer overflow and underflow, insecure randomness, and denial of service.
What is the difference between testing and auditing a smart contract?
Testing is continuous work in which the team builds automated tests for every function and for the invariants that must never break. An audit is an independent review by an outside party at a point in time. Good testing makes the audit deeper; neither replaces the other.
Does an audit make a contract secure?
No. ethereum.org notes that smart contract audits won’t catch every bug and are essentially an additional round of review. Teams therefore combine thorough testing, an independent audit, bug bounty programmes and post-deployment monitoring.
How do I protect an upgradeable contract?
Put the upgrade role behind a multi-signature wallet with a delay before execution, make sure both the proxy and the implementation are initialised because an uninitialised contract can be taken over, and compare storage layout automatically before every upgrade.
Is Solidity 0.8 enough to avoid arithmetic bugs?
Since 0.8.0, arithmetic reverts on overflow and underflow instead of wrapping silently, which closes an old class of bugs. But unchecked blocks restore the wrapping behaviour, and logic errors in the calculation itself are invisible to the compiler.
Sources
- OWASP Smart Contract Top 10 (2025) — OWASP Foundation · https://owasp.org/www-project-smart-contract-top-10/
- Smart contract security — ethereum.org · https://ethereum.org/developers/docs/smart-contracts/security/
- The history of Ethereum — The DAO fork — ethereum.org · https://ethereum.org/en/history/
- 2025 Crypto Theft Reaches $3.4 Billion — Chainalysis · https://www.chainalysis.com/blog/crypto-hacking-stolen-funds-2026/
- Security Considerations — Solidity documentation · https://docs.soliditylang.org/en/latest/security-considerations.html
- Solidity v0.8.0 Breaking Changes — Solidity documentation · https://docs.soliditylang.org/en/latest/080-breaking-changes.html
- Writing Upgradeable Contracts — OpenZeppelin · https://docs.openzeppelin.com/upgrades-plugins/writing-upgradeable
- Proxies — Contracts 5.x API — OpenZeppelin · https://docs.openzeppelin.com/contracts/5.x/api/proxy
- Fuzz testing — Foundry · https://getfoundry.sh/forge/fuzz-testing
- Invariant testing — Foundry · https://getfoundry.sh/forge/invariant-testing