Unbounded State Bloat: How I Found a Chain-Halting DoS Bug in Inj
The Injective Peggy Bridge rate-limiting module stored an unbounded list of transfers per token, and the EndBlocker pruned this list with nested loops over every token and every transfer. An attacker could flood the bridge with many tiny transfers across multiple tokens, causing block processing to exceed the consensus timeout and potentially halt the chain.
Hello everyone, HackerMD here. As a security researcher deeply engaged in auditing blockchain protocols and DeFi smart contracts, I recently participated in the Injective Peggy Bridge audit on Code4rena.
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 rate-limit state stored transfers in an unbounded slice, and the EndBlocker iterated over every token and every transfer in that slice on each block without any cap or efficient indexing.
Impact
An attacker could cause a complete denial of service and potentially halt the chain by making block processing exceed the consensus timeout.
What the attacker needed
Ability to submit bridge transfers; many low-value transfers across tokens
The fix
The protocol should cap the number of stored transfers and use composite-key indexing so expired records can be removed without loading the entire history into memory.
How it was found
- Identify the rate-limit state that appends every bridge transfer to a slice without a size limit.
- Send many low-value transfers across multiple tokens to grow the transfer list.
- Observe that the EndBlocker loops over all tokens and all transfers each block, causing high CPU usage.
- Measure that the pruning logic exceeds the safe block time, which could lead to a chain halt.
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 blockchain processes every transaction in blocks, and each block must finish within a short time limit. The bridge kept a growing list of every small transfer and checked the whole list at the end of every block. By making lots of tiny transfers, an attacker could make that check take too long, so the network could not keep up and might stop producing blocks.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.