Blog

Smart contract security for real-world financial applications

Resources
·
·
Turnkey
Turnkey

About: Learn why smart contract security matters for financial applications, how common exploits take advantage of code and operational weaknesses, and why teams need controls before and after deployment.

Audience: Fintech developers, DeFi teams, protocol engineers, stablecoin platforms, treasury teams, crypto builders, and infrastructure teams managing smart contracts in production.

What you’ll learn:
  • What smart contract exploits are and why they are dangerous for financial applications
  • How common risks like reentrancy, accounting errors, oracle manipulation, flash loans, access control failures, upgrade risks, and bridge vulnerabilities affect users
  • Why smart contract security needs to start before deployment and continue after contracts go live
  • How signing-layer controls help teams manage privileged actions, backend automation, upgrades, and sensitive contract calls
  • How Turnkey helps teams secure smart contract operations with policy-controlled signing, smart contract interfaces, and least-privilege access

Reading time: ~10 minutes

Smart contract exploits are attacks that take advantage of a weakness in onchain code or in the systems that control how that code is used. The best security to mitigate against these smart contract exploits should have a clear strategy on how contracts are securely managed before and after their deployment.

A recent academic review of 50 severe real-world smart contract attacks between 2022 and 2025 found more than $1.09 billion in losses, with many incidents caused by “exploit chains” that combined code bugs with governance, operational, economic, or external dependency failures.

One of the clearest examples of smart contract failure is the Euler Finance exploit. In March 2023 an attacker used a flash loan to exploit a vulnerability in Euler’s contracts and drained roughly $197 million from the protocol. For users, the contracts seem to execute valid transactions, but those transactions abused assumptions the protocol had encoded into its own logic.

That is what makes smart contract exploits so dangerous: attackers do not need to break the blockchain itself. They only need to find an action the contract will treat as valid, even if that action violates the protocol’s intended behavior.

This is why smart contract security has to be understood in layers. Audits, testing, formal verification, and safer contract design matter. But production teams also need to control the operational layer around the contract: who can deploy, who can upgrade, who can mint, who can burn, which backend services can call sensitive functions, and what a signer is allowed to approve. 

Why smart contract security matters for financial applications

Smart contracts often control real financial activity such as lending markets, trading flows, payment settlement, and treasury movement. When those contracts fail, users can lose funds.

For development teams, the damage extends beyond the exploit. Engineers may need to pause contracts. Legal and compliance teams may need to assess downstream user impact. But even if the technical issue is contained, the loss of trust can last much longer than the incident itself.

That’s why financial applications need end-to-end smart contract security. Security has to start in system design, continue through development, testing, audits, deployment, and upgrades, but that is not enough. Teams also need a security model for how contracts are managed, updated, and controlled after they go live.

Common smart contract risks teams need to secure against

Smart contract risks tend to follow recognizable patterns. A contract sends funds before updating balances. A lending protocol miscalculates collateral. A price feed can be pushed out of range. A flash loan gives an attacker enough capital to stress a weak assumption. A privileged wallet can mint, pause, upgrade, or withdraw more than it should. These are the risks this section breaks down.

The visual below maps each risk to the failure pattern behind it and the security practices teams use to reduce exposure before and after deployment.

DeFi Attack Vectors & Defenses

Common exploit categories in smart contract systems and the security practices that defend against them.

Click any attack to reveal defenses
ATTACK VECTOR 01
Reentrancy & execution-order bugs
External calls fire before state updates, letting attackers re-enter and drain funds.
View defenses
Contracts can behave unexpectedly when external calls execute before internal state is updated. An attacker can re-enter a function mid-execution, draining funds by repeatedly calling a withdrawal before the balance is set to zero.
The DAO hack in 2016 remains the defining example: a recursive withdrawal drained 3.6 million ETH from the fund before the balance update could fire.
Security practices
Use the checks-effects-interactions pattern: validate, update state, then make external calls
Add reentrancy guards (mutex locks) to sensitive functions
Minimize external calls within state-changing functions
Test adversarial execution paths with tools that simulate reentrant calls
ATTACK VECTOR 02
Logic & accounting errors
Small mistakes in balance math, collateral checks, or rounding compound into large losses.
View defenses
Small mistakes in balance accounting, collateral checks, share calculations, or token math can compound into large losses. Rounding errors, integer overflow, or flawed liquidation logic can let attackers extract more value than they deposited.
Euler Finance lost $197 million in March 2023 when a flaw in its donation and liquidation logic allowed an attacker to create artificial bad debt and drain reserves.
Security practices
Use invariant testing to verify accounting identities hold across all state transitions
Fuzz critical functions with randomized inputs and edge-case values
Review edge cases around deposits, withdrawals, liquidations, and rounding
Separate high-risk logic into smaller, independently reviewable components
ATTACK VECTOR 03
Oracle & market manipulation
Weak or thin-liquidity price sources let attackers manipulate valuations and drain pools.
View defenses
Contracts that rely on external price data can be exploited if the price source is weak, delayed, or draws from thin liquidity. An attacker who can move a price feed, even temporarily, can trigger liquidations, inflate collateral values, or drain lending pools.
Security practices
Use reliable oracle providers with decentralized price aggregation
Add price sanity checks that reject values outside expected bounds
Use time-weighted average pricing (TWAP) to smooth manipulation attempts
Set circuit breakers that pause actions during abnormal market conditions
Limit high-impact actions during volatile or uncertain pricing windows
ATTACK VECTOR 04
Flash loan-enabled attacks
Temporary capital in one transaction amplifies weak assumptions in contract logic.
View defenses
Flash loans are not the root vulnerability. They are an amplifier. By providing attackers with massive temporary capital within a single atomic transaction, flash loans let them exploit weak assumptions in price logic, governance voting, or collateral calculations that would otherwise require prohibitive upfront capital.
Security practices
Design against atomic manipulation: assume any value observable within one transaction can be moved
Test economic assumptions under extreme, temporary liquidity conditions
Avoid relying on pool balances or spot prices as trusted state within a single block
Add rate limits or cooldown periods around high-impact financial actions
ATTACK VECTOR 05
Access control failures
Sensitive functions exposed to the wrong caller: minting, burning, pausing, upgrades.
View defenses
Sensitive functions like minting, burning, pausing, upgrading, ownership transfers, and treasury withdrawals can be exposed to the wrong caller. Missing or misconfigured access checks are among the simplest exploits and among the most damaging.
Security practices
Apply the principle of least privilege: every role gets only the permissions it needs
Separate duties across distinct roles rather than concentrating authority
Limit admin authority and require stronger approval for sensitive actions
Audit every privileged function and role assignment before deployment
ATTACK VECTOR 06
Upgrade & proxy risks
Upgrade authority is one of the most sensitive control paths in any contract system.
View defenses
Upgradeable contracts offer flexibility, but the upgrade authority itself becomes one of the most sensitive control paths in the system. A compromised upgrade key can replace contract logic entirely, bypassing every other security measure in place.
Security practices
Use timelocks that enforce a delay before major upgrades take effect
Require multi-party approval (multisig or governance vote) for upgrade execution
Limit who can propose and execute upgrades to the smallest possible set
Test upgrade paths in staging environments before mainnet execution
Keep upgrade permissions dormant when not actively needed
ATTACK VECTOR 07
Bridge & cross-chain risks
Bridges stack trust assumptions across validators, relayers, and multi-chain contracts.
View defenses
Bridges introduce complexity by relying on message verification, validator sets, relayer infrastructure, locked assets, and contracts deployed across multiple chains. Each layer is an additional trust assumption, and bridge exploits have produced some of the largest losses in DeFi history.
Security practices
Minimize trusted assumptions: fewer validators and relayers means fewer attack surfaces
Protect validator and admin keys with hardware security and access controls
Monitor cross-chain message flows for anomalous or unauthorized activity
Use strict limits and rate controls around bridge-related contract calls
Maintain emergency pause mechanisms and documented incident response plans

A contract that works in normal conditions can still fail when an attacker finds the edge case it was not designed to handle. The goal then is to reduce the number of paths a contract will accept when the action is unsafe, unauthorized, or outside the intended workflow.

Smart contract security before deployment

Smart contract security starts long before a contract is live. Teams need to understand what the contract is supposed to do, where value can move, which assumptions the system depends on, and which actions could cause the most damage if they fail.

Smart Contract Security Process

Eight layers of review, from first design to launch.

01
Threat modeling
Identify the highest-risk scenarios before writing code.
What happens if a price feed is manipulated, a privileged wallet is compromised, a user calls functions in an unexpected order, or the contract receives a token with unusual behavior? These questions surface where the system needs stronger controls.
02
Architecture review
Evaluate how contracts, permissions, upgrades, and fund flows fit together.
A secure architecture review examines how permissions are assigned, how upgrades work, where external dependencies enter the system, and how funds move through the application. The goal is catching design problems before they become expensive code problems.
03
Internal code review
Review critical functions for adversarial behavior, not just correctness.
Focus on functions that handle deposits, withdrawals, minting, burning, liquidations, pricing, upgrades, and admin permissions. Ask how the code behaves when users act adversarially, not just whether it works under normal conditions.
04
Independent audit
External auditors find issues the internal team missed.
Audits are especially important for financial applications. Small mistakes in accounting, permissions, or execution order can turn into large losses. Complexity and significant value both raise the stakes.
05
Formal verification
Prove that critical properties hold under defined conditions.
Not necessary for every function, but valuable for logic that manages balances, collateral, solvency, or token supply. Formal verification lets engineers prove certain invariants mathematically rather than relying on test coverage alone.
06
Comprehensive testing
Go beyond unit tests: integration, fuzzing, and invariant testing.
Unit tests check individual functions. Integration tests check how contracts behave together. Fuzzing pushes contracts through unexpected inputs. Invariant testing checks whether important properties always remain true, even across many actions. Together, these methods find bugs that normal test cases miss.
07
Testnet and staging deployment
Rehearse deployment, upgrades, and emergency procedures before mainnet.
These environments let teams practice deployment sequences, upgrade paths, integration points, monitoring, and emergency procedures before real funds are involved. A testnet deployment will not catch every economic issue, but it exposes operational mistakes before production.
08
Bug bounty
Give outside researchers a structured way to report vulnerabilities.
For applications that will hold meaningful value, a bug bounty program provides an important final check before launch. It creates a structured incentive for security researchers to find and report vulnerabilities before attackers can exploit them.

All of these steps are necessary, but they are not complete by themselves. A contract can be audited, tested, and formally reviewed, then still become risky if the operational layer is weak. After deployment, teams still need to manage the wallets, roles, keys, upgrades, approvals, and backend systems that interact with the contract.

Smart contract security after deployment

Once a contract is live, security becomes an ongoing responsibility. The contract may be immutable, but the system around it rarely is.

Any wallet with admin-level authority becomes part of the security model. Those permissions should be protected, scoped, and tied to clear approval rules.

The same applies to automated workflows. A service built for a single contract call should not have broad authority across unrelated functions. Each role should match the action it performs.

Not every privileged action carries the same risk. Routine calls can be automated when tightly scoped. Higher-risk actions should require stronger approval.

Teams also need governance around upgrades, emergency response, and key compromise. If something goes wrong, the team should already know what is allowed, who approves it, and how quickly the system can be contained.

The signing layer: where smart contract security often breaks down

A team may have strong contract code, a completed audit, and a careful launch process, but still rely on wallets and backend systems with too much authority. A treasury wallet might be able to call functions it was never meant to reach. A backend service might sign transactions outside its intended workflow. An upgrade wallet might stay active long after the upgrade is complete.

These are not smart contract bugs. They are control failures around the contract. The contract accepts a valid transaction because the signer has authority, even if the transaction should never have been approved.

This is why production teams need security at the signing layer, not only at the code layer. A signing-layer control checks whether a transaction is allowed before the signature is produced, adding a checkpoint before anything reaches the chain. 

Blockchains do not know intent. If a transaction is valid and signed by an authorized key, the network will process it regardless of whether it should have been approved.

Signing-layer controls change this by defining what each signer is actually allowed to do rather than treating every authorized key as fully trusted. A backend service can be scoped to one narrow action. A privileged upgrade can require human approval. A sensitive transaction can be blocked before it becomes final.

Where Turnkey fits into smart contract security

Turnkey helps teams secure the operational layer around smart contracts through policy-controlled signing. Instead of giving a backend service, admin wallet, or API key unrestricted authority, teams can define which users, API keys, wallets, contracts, methods, and parameters are allowed.

This is especially useful for production applications that need to manage smart contracts at scale. Teams often need automation, but they also need strong controls around that automation. A system that signs every requested transaction is too broad. A system that requires manual approval for every routine action can slow down operations. Turnkey helps teams create a more precise model, where low-risk actions can be automated under narrow rules and sensitive actions can require stronger approval.

Turnkey does not replace secure contract development, audits, testing, or formal verification. Those controls are still necessary. Turnkey protects the operational layer around smart contracts by enforcing least-privilege access before a transaction is signed.

How Turnkey maps to smart contract security risks

Enclave-enforced
Signing policies run inside secure enclaves at the same trust boundary as private keys.
ABI & IDL-aware
Policies parse Ethereum ABIs and Solana IDLs to target specific functions and arguments.
Role-scoped
Each user, API key, and service gets permissions tied to specific wallets and actions.
Multichain
Consistent policy enforcement across EVM, SVM, Bitcoin, TRON, and more.

For over-permissioned admin wallets, Turnkey helps teams restrict which wallets can call which contract functions. This reduces the blast radius if a credential, workflow, or backend system is compromised.

For unsafe minting or burning, Turnkey policies can define who can perform the action, which contract can be called, and what approval rules are required. This helps prevent token supply changes from depending on a broadly trusted signer.

For risky contract upgrades, teams can scope upgrade authority to a specific workflow. They can require approvals, restrict which upgrade function can be called, and avoid leaving broad upgrade access active during normal operations.

For blind transaction signing, Turnkey can use smart contract interfaces such as Ethereum ABIs and Solana IDLs. This allows policies to understand specific methods and arguments instead of treating contract calls as opaque calldata.

For backend automation with too much authority, machine users can be limited to specific contract calls. A service can be allowed to perform the task it was built for without being trusted to call every function the wallet can access.

Turnkey: Smart contract security 

Smart contract exploits often start with a code bug, economic assumption, or dependency failure. But real-world security also depends on how contracts are operated after deployment. Teams need secure code, strong testing, careful upgrade design, protected admin roles, and signing controls that prevent unauthorized or out-of-policy actions before they reach the chain.

That is the layered model production applications need. Audits and testing reduce the risk inside the contract. Operational controls reduce the risk around the contract. Turnkey fits into that final layer by helping teams enforce smart contract permissions at the point of signing, where risky transactions can still be stopped.

Get started with Turnkey today.‍

Turnkey
Turnkey

Related articles

A Note from Turnkey: What 2026 Revealed About Security and What's Ahead

What 2026's attacks and security research revealed, where threats are heading, and how teams can prepare for 2027.

Resources
November 3, 2026

How Turnkey is preparing for AI and quantum threats to elliptic curve signatures

Turnkey's security team on this year's quantum and AI research: which Bitcoin, Ethereum and Solana keys would be at risk and how to prepare.

Resources
October 28, 2026