Protocols don't fail because code is wrong β οΈ
they're exploited because
the system behaves correctly
under the wrong assumptions
The code did its job
your model didn't π
Your contract can be perfectly written...
and still perfectly exploitable β οΈ
No overflows
No reentrancy
No obvious bugs
Just one wrong assumption:
who can call what, and when
Security doesn't break in syntax
it breaks in assumptions π
@uttam_singhk Security saved the funds
but it also proved something uncomfortable
the system can intervene
which means decentralization is conditional, not absolute
Most auditors look at functions β οΈ
while attackers look at execution paths
Value in β state changes β external calls β value out
every step is a chance to break assumptions
Bugs don't live in lines
they live in flow. π
This one line changes everything β οΈ
User storage u = users[id]
Looks like a copy...
it's not
It's a pointer to storage
Modify u
you modify the contract state
Not a variable
a direct write to storage π§
Changing ERC20 allowances can silently cost you tokens β οΈ
Approve 100 - spender can use 100
You change it to 50 - sounds safe, right ?
But before it updates..
they can spend the old 100
and still get the new 50 π
Old allowance
meets new intent β‘
That's how tokens disappear