Skip to content
high DeFi Economic No SWC entry CWE-682

Share Price / Staking Share Manipulation

SAFE-0020 DeFi Economic Documented — manual review item
1

What goes wrong

Share-to-asset price is derived from a manipulable on-chain balance (token.balanceOf(vault)). An attacker donates or flash-borrows to move the ratio, minting or redeeming shares at an unfair rate.

2

How to fix it

the pattern that is safe
uint256 price = internalTotalAssets * 1e18 / totalShares;  // internal accounting
Track assets internally; ignore unsolicited transfers in pricing.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source. Paste an address or the source itself — a small per-scan fee, shown before you sign, or unlimited on any plan.

Run the scanner See how it is attacked Read the docs