Skip to content

Uninitialised Storage Pointer

SAFE-0142 Logic / State Checked automatically by the scanner
1

What goes wrong

A local variable of a struct/array type is declared without an explicit memory/storage location (older Solidity) or as an unassigned storage reference. It aliases slot 0 and writing through it overwrites unrelated state — often the owner or a critical mapping.

2

The vulnerable pattern

proof of concept — how it is exploited
// function f() public { Data storage d; d.x = 1; }  // d -> slot 0
// slot 0 is `owner` -> d.x = 1 overwrites owner with 0x...01.
3

How to fix it

the pattern that is safe
// always specify the data location explicitly
MyStruct memory s = MyStruct(...);   // memory, not a dangling storage ref
Explicit data location; modern compilers reject the ambiguous form.
Check your own contract for this

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