A worked security review of a StakingRewards contract — the deliverable a
competitive audit actually asks for, not just isolated bug demos.
src/StakingRewards.sol is a Synthetix-model staking-rewards protocol with three
real, subtle bugs planted in it. AUDIT.md is the findings report:
each issue is described, rated by severity, and paired with a Foundry test in
test/StakingRewards.t.sol that carries out the attack against the code as
written.
| ID | Severity | Bug |
|---|---|---|
| H-01 | High | stake() skips the reward checkpoint → a one-day staker walks off with a seven-day staker's rewards |
| M-01 | Medium | notifyRewardAmount is unauthenticated → anyone can cut the reward rate and stall payouts |
| L-01 | Low | reward-rate rounding permanently strands the remainder of every non-divisible reward |
forge test -vv # 3 PoCs; -vv prints the stolen/stranded amountsThe point is the method: read the contract, prove the bug with a test before claiming it, rate it by impact and likelihood, and give the exact fix. Companion to contract-security-notes, which covers the individual vulnerability classes.