Skip to content
Business logic Write-up Intermediate

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.

Hacker MD Follow

Published on blog.blockmagnates.com

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.

Hacker MD, on blog.blockmagnates.com

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

  1. Call initializeStrategy with a strategy description and one token to create a legitimate strategy.
  2. Call initializeStrategy again with the exact same strategy description but a different token.
  3. 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.

More by Hacker MD

View all

12 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.