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