Staking contract audit: rewards, timing and who can move the stake
A staking contract audit checks how rewards accrue and who can take them: the reward-per-share math, whether every stake, claim and unstake settles the rewards of the account first, how long a stake must stay before it earns, and whether anyone but the staker can move staked assets. QuillShield audits the staking contracts together with the tokens and vaults around them, then checks each pull request against that audit.
What goes wrong in staking contracts?
Staking bugs gather around one number, the reward an account is owed, and the state it is computed from. A January 2026 study of DeFi staking, SSR, sorted the logic defects found in 64 security incidents and 144 audit reports into six types, and they make a good review map:
- State not updated on every path. Stake, claim and unstake must each settle the rewards of the account before they change its balance. A path that skips the update pays rewards on a balance the account didn't hold, one of the reward accounting errors.
- Weak checks on claim and unstake. A claim that doesn't check what was already paid, or an unstake that doesn't check the lock, pays twice or pays early.
- Reward variables anyone can change. A rate, a total or a timestamp that an external function can set lets the caller choose their own reward. The access control page covers the pattern.
- Rewards with no time in them. If rewards ignore how long a stake was held, someone can stake, claim and leave in one block, often with a flash loan.
- Rewards priced from one pool. Rewards or minted staking tokens that depend on a single liquidity pool move when that pool moves, which is oracle price manipulation under another name.
- Staked assets others can reach. A function that lets someone other than the staker move or withdraw the stake.
Two more show up whenever staking shares are minted like vault shares. A donation to an empty pool can round the shares of the next staker down to zero, the same mechanics as the ERC-4626 inflation attack. And a reward drop that is visible before it lands can be sandwiched by someone who stakes just before it and leaves just after.
How common are reward logic bugs?
The authors of the SSR study scanned 15,992 DeFi staking contracts and flagged 3,557 of them, 22.24%, with at least one of the six defect types, at 89.41% precision on a manually checked sample, so these defects are common enough to look for on purpose. The table shows how often each type appeared.
| Defect type | What it means | Contracts flagged |
|---|---|---|
| Unsafe verification | Missing or weak checks when rewards are claimed or stakes withdrawn | 1,315 (8.22%) |
| Omission in status update | Staking state not updated promptly after a stake, claim or unstake | 889 (5.56%) |
| Unauthorized staking asset access | Functions that let others reach users' staked assets | 846 (5.29%) |
| Rewards without time delay | Rewards that ignore staking duration, with no time limit on claims | 516 (3.23%) |
| Staking variable manipulation | Critical staking variables that external functions can change | 430 (2.69%) |
| Single liquidity pool reliance | Rewards or minted staking tokens that depend on one pool | 44 (0.28%) |
These counts come from an automated tool run on deployed contracts, so read them as how often each pattern appears, not as confirmed exploits.
What has gone wrong before?
| Protocol | OTSea Staking |
|---|---|
| Date | NaN undefined October 2024 |
| Chain | Ethereum |
| Loss | $26,000 |
| What happened | A logical defect let the attacker manipulate a variable used to calculate staking rewards, according to the SSR study, which uses the case as its example of staking variable manipulation. The loss was small, but the same defect type was flagged in 430 of the 15,992 contracts the study scanned. |
| Sources | arXiv |
The running example in the study shows the staked-assets type in a few lines. sportsDAO computed its staking rewards from the token balance of the contract, and a public withdrawTeam function let anyone move all the staking tokens to the owner, which drained the balance the rewards depended on, so one unguarded function broke both the stake and the reward math.
What does a staking finding look like?
The QuillShield demo audit covers a small yield vault rather than a staking contract, but two of its findings are staking bugs in all but name. On 23 October 2026 a full audit of the Mini DeFi Vault, our own demo contract, reported 5 findings, 3 of them Critical and 2 Medium. These are the two that matter for staking:
- Critical,
src/MiniYieldVault.sol:26:deposit()prices new shares on a balance that already includesmsg.value, so depositors are under-minted and earlier holders take their principal. - Medium,
src/MiniYieldVault.sol:27: Searcher can sandwich a visible ETH donation and take yield meant for existing holders.
The first is a balance read at the wrong moment, the same ordering mistake as a staking contract that changes balances before it settles rewards. The second is the reward-drop sandwich from the list above. The audit took 2h 7m on our own demo code, and larger codebases take longer.
Which bug classes should a staking review cover?
| Bug class | Where it shows up in staking |
|---|---|
| Reward accounting errors | Reward per share updated after balances change, or not on every path. |
| Rounding and precision | Reward per share kept with too little precision, or rounded toward the claimer. |
| ERC-4626 inflation attack | A first staker or a donation sets a share price that rounds later stakes to zero. |
| Sandwich attack | Stake just before a visible reward drop, unstake just after. |
| Flash loan attack | Borrowed tokens staked for one block when rewards ignore time. |
| Access control | Who can set the reward rate, add reward tokens, pause or move staked funds. |
| Reentrancy | A stake or reward token with transfer hooks calls back before the claim is recorded. |
| Fee-on-transfer token issues | The contract credits the amount sent, not the amount it received. |
| Timestamp dependence | Lock and vesting periods measured in block time, with edge cases at the boundary. |
| Oracle price manipulation | Rewards or liquid staking token mints priced from one pool. |
| Denial of service | Loops over all stakers or all reward tokens that grow until they hit the gas limit. |
How do a full audit and pull request checks fit a staking team?
Put the staking contract in scope with everything that sets or pays its numbers: the reward distributor, the staking and reward tokens if they are yours, any vault or liquid staking wrapper, and the contracts that hold admin roles. QuillShield reviews them as one codebase, so a reward rate set in one contract is read with the claim function that pays it. Before the audit starts, add context such as the whitepaper, trust assumptions, privileged roles and previous audit reports.
A separate reviewer agent tries to disprove every finding before you see it. Each finding that holds up comes with the exact lines, the impact, a recommended fix and, on full audits, the proof of concept result, so you can see whether a reward path pays out more than it should before you change it.
Reward programs keep changing after launch: new reward tokens, new rates, new lock periods. Each full audit of a GitHub or GitLab.com repository comes with five pull request checks, and on GitHub, with branch protection or rulesets, a required QuillShield check blocks a merge while the pull request has a High or Critical finding, or one at the threshold you set. The guide to pull request checks on GitHub shows the setup.
QuillShield does not replace a manual audit. For a staking launch with real value behind it, request a manual audit from QuillAudits as well, and use QuillShield for every change between audits.
What does a staking contract audit cost?
Staking contracts are priced like any other Solidity: from the lines in scope, not counting comments and blank lines, starting at $49. The pricing page lists 1,000 lines at $379 and 5,000 lines at $1,169 as of November 2026, and you see the exact quote before anything is charged. A new reward token or rate change later costs a pull request check: $5 for up to 50 added lines of Solidity plus $0.10 for each added line after that, once the five included checks are used. Sign-up is free. New accounts get $50 in credit, good for up to half of an order.
Run a full audit of your staking contracts and see the exact quote before anything is charged. The Solidity audit page explains what QuillShield needs from a Foundry project.
What should you check before you launch a staking contract?
- Does every stake, claim, unstake and transfer settle rewards before it changes a balance?
- Can any external function change the reward rate, the totals or the timestamps rewards are computed from?
- Do rewards depend on how long a stake was held, so that staking, claiming and leaving in one block earns nothing?
- Does a claim check what was already paid, and an unstake check the lock?
- Can a first staker or a donation set a share price that rounds later stakes to zero?
- Is a reward drop visible before it lands, and can someone stake just ahead of it?
- Does the contract credit the amount it received, for fee-on-transfer and rebasing tokens?
- Who can move staked funds, and is that written down for users?
FAQ
What is the most common bug in staking contracts?
In the SSR scan of 15,992 staking contracts, unsafe verification on claim and unstake was the most frequent of the six defect types, flagged in 1,315 contracts (8.22%). Missed state updates came second, at 889 (5.56%).
Do I need an audit if I fork a well-known staking contract?
A fork needs its own audit, because it changes the tokens, the reward schedule and the admin roles, and each change is outside what the original audit reviewed. The reward math is also only as safe as the tokens you plug into it.
How much does a staking contract audit cost with QuillShield?
It follows the lines of Solidity in scope and starts at $49: as of November 2026, 1,000 lines cost $379 and 5,000 lines $1,169. You see the exact price before anything is charged.
Can a pull request check block a risky reward change?
It can on GitHub, if your plan includes branch protection or rulesets. Mark the QuillShield check as required, and a pull request with a High or Critical finding, or one at the threshold you set, can't merge.