Hourglass (old)
The order book stored each user's order under a key made only of chain id and the two token addresses, so any order for the same token pair shared one storage slot. An attacker could place a tiny order for the same pair and call send() first, setting the shared awaiting flag and permanently blocking the victim's order from being executed.
github.com
Published on github.com
History
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 order book mapping is keyed only by chain id and token pair, so orders from different users for the same pair collide in one storage slot.
Impact
The victim's order can no longer be executed, so the tokens already transferred into the contract by placeTaker() could be permanently stuck, causing loss of funds and a denial of service.
What the attacker needed
Attacker can place a taker order; same token pair and chain as victim; attacker calls send() before victim
The fix
The order book key should include a value that cannot be replicated by another user, such as the sender's address or the order quantity.
How it was found
- The victim places a taker order for a token pair on a given chain.
- The attacker places a much smaller taker order for the same token pair and chain.
- After the epoch span, the attacker calls send() for that pair, which sets the shared awaiting flag to true.
- The victim calls send() for the same pair and the call reverts with the awaiting-message error.
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 keeps a table of orders, and each row is found using a label built from the chain and the two tokens being traded. Because the label leaves out who placed the order, two different people trading the same pair end up writing to the same row. One person can then flip a 'busy' switch on that row, and the other person's order can never be processed, leaving their tokens stuck in the contract.
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.