Breaking Immutability: How I Bypassed a Core Security Invariant i
The strategy initialisation function checked immutability only per token slot, not per strategy hash, so a maker could call it again with the same strategy description and a different token to add that token to an existing strategy. This broke the documented promise that a strategy's token set cannot change after creation, potentially confusing third-party apps that rely on that invariant.
In the world of smart contract security, immutability is a sacred concept. When a protocol’s documentation explicitly states that a core component — like a trading strategy — cannot be changed once created, integrators and users rely on that promise.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The immutability check was applied to each individual token's storage slot inside a loop instead of to the strategy hash as a whole, so a strategy could be extended with new tokens after its first initialisation.
Impact
Third-party applications that assume a strategy hash maps to a fixed set of tokens could be deceived, leading to incorrect fee calculations, pricing errors, or corrupted state within the integrating app.
What the attacker needed
A maker account with virtual balance; ability to call initializeStrategy
The fix
The protocol should track initialised strategy hashes in a separate mapping and reject any call that tries to initialise the same hash again.
How it was found
- Call initializeStrategy with a strategy description and one token to create a legitimate strategy.
- Call initializeStrategy again with the exact same strategy description but a different token.
- The contract checks only the new token's empty slot, so the check passes and the new token is added to the existing strategy.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
A smart contract is a program on a blockchain that runs automatically. This protocol promised that once a trading strategy was created, its list of tokens could never change. But the check only looked at each token separately, so someone could add a new token to an existing strategy by calling the setup function again with the same strategy name and a different token.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.