Skip to main content

Erroneous Writing To Memory Instead Of Storage

What it detects

Developers sometimes use a memory pointer when they meant to update a storage variable. Changes to memory are discarded after the call finishes, leaving the persistent state untouched. This detector searches for such mistakes.

Typical symptoms

  • State variables not updated after function execution
  • Temporary memory copies modified instead of storage

Solidity snippet (v0.8.25)

pragma solidity ^0.8.25;

contract StorageBug {
uint256 public count;

function badUpdate() external {
uint256 c = count; // loads to memory
c += 1; // writes to memory only
}
}

Why it matters on EVM

Writing to memory instead of storage can disable critical logic, as updates never persist. Attackers may exploit the inconsistency or rely on unchanged values.