Skip to content

Read-Only Reentrancy

SAFE-0003 Reentrancy Checked automatically by the scanner
1

What goes wrong

A view function returns state that is temporarily inconsistent during an external call in another contract. Third-party integrators (e.g. price oracles, lending markets) read this corrupted view mid-transaction and make decisions on manipulated values.

2

How to fix it

the pattern that is safe
// Add a reentrancy lock check usable by readers, or expose a lock state
modifier readGuard() { require(!_locked, "reentrant read"); _; }
function getVirtualPrice() public view readGuard returns (uint256) {
    return totalAssets() * 1e18 / totalSupply();
}
Curve/Balancer read-only reentrancy class. Expose the reentrancy lock to readers.
Check your own contract for this

The SaferICO scanner runs 201 detectors over your Solidity source, SAFE-0003 among them. 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