You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Vault inflation attack in UsualX allows malicious user to steal money and innocent user to lose money
Summary
The missing check: require(convertToShares(assets) != 0); in usualX::depositWithPermit(...) allows the attacker to perform and fully beneficiate from his attack at low cost as he takes advantage of a rounding issue.
A hacker back-runs the transaction of an ERC4626 pool creation.
The hacker mints for themself one share: deposit(1). Thus, totalAsset()==1, totalSupply()==1.
The hacker front-runs the deposit of the victim who wants to deposit 20,000 usual (20,000).
The hacker inflates the denominator right in front of the victim: asset.transfer(20_000dec). Now totalAsset()==20_000dec + 1, totalSupply()==1.
Next, the victim's tx takes place. The victim gets 1 * 20_000dec / (20_000dec + 1) == 0 shares. The victim gets zero shares.
The hacker burns their share and gets all the money.
Impact
No response
PoC
No response
Mitigation
Add the following check: require(convertToShares(assets) != 0);or implement the 'dead shares' technique used by UniswapV2
The text was updated successfully, but these errors were encountered:
sherlock-admin4
changed the title
Digital Rouge Iguana - Vault inflation attack in UsualX allows malicious user to steal money and innocent user to lose money
Z0NaN - Vault inflation attack in UsualX allows malicious user to steal money and innocent user to lose money
Nov 19, 2024
Z0NaN
High
Vault inflation attack in UsualX allows malicious user to steal money and innocent user to lose money
Summary
The missing check:
require(convertToShares(assets) != 0);
inusualX::depositWithPermit(...)
allows the attacker to perform and fully beneficiate from his attack at low cost as he takes advantage of a rounding issue.Root Cause
There's a rounding issue here:
in
convertToShares(...)
called in the subcalls of deposit()https://github.com/sherlock-audit/2024-10-usual-labs-v1/blob/main/pegasus/packages/solidity/src/vaults/UsualX.sol#L308
Internal pre-conditions
External pre-conditions
No response
Attack Path
Impact
No response
PoC
No response
Mitigation
Add the following check:
require(convertToShares(assets) != 0);
or implement the 'dead shares' technique used by UniswapV2The text was updated successfully, but these errors were encountered: