[web3] Critical bug in dHEDGE found by Quantish worth 500
The dHEDGE protocol allowed a malicious pool manager to steal almost all client funds by exploiting a missing check on intermediate tokens in Uniswap swap paths, combined with a 10% slippage allowance. By repeatedly swapping through a fake token, the manager could drain up to 96% of the pool's value.
mirror.xyz
Published on mirror.xyz
On Feb 6, 2023 we discovered the critical security vulnerability in the dHEDGE protocol allowing a malicious trader or manager to almost fully drain the pool containing the clients’ funds, and submitted it to the dHEDGE via the Immunefi bug bounty platform.
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 guard contract only validated the input and output tokens of a Uniswap swap, not the intermediate tokens in the path, allowing a malicious manager to insert a fake token and exploit the 10% slippage tolerance to repeatedly extract value.
Impact
A malicious manager could steal up to 96% of a pool's value, with one pool having over $15M TVL, potentially stealing $14.4M; the protocol team decided not to fix it.
What the attacker needed
Be a pool manager or trader; create fake token and Uniswap pools; provide liquidity to those pools
The fix
The team decided not to fix it, but mitigations such as monitoring pool value loss and pausing, or checking direct swap output, were suggested.
How it was found
- Create a fake ERC-20 token.
- Create two UniswapV3 pools with the fake token and two pre-approved assets, providing liquidity so that a swap through the fake token yields a 10% loss.
- Call execTransaction on the pool to perform the swap, reducing pool value by 10% and adding it to the malicious pools.
- Repeat the swap multiple times to increase stolen amount.
- Remove liquidity from the malicious pools to obtain the stolen funds.
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.
In dHEDGE, managers trade with other people's money but are supposed to be restricted to safe actions. The bug let a manager use a fake token in the middle of a trade to slowly siphon off funds, because the system only checked the start and end tokens, not the ones in between.
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.