No sanity check on pricePerShare might lead to lost value
The wibbtc contract calculates transfer amounts using pricePerShare without any sanity check. If pricePerShare is incorrectly low due to a bug or oracle issue, an attacker could receive more tokens than deserved and drain the Curve pool.
Submitted by kenzo
pricePerShare is read either from an oracle or from ibBTC’s core.
If one of these is bugged or exploited, there are no safety checks to prevent loss of funds.
Impact
As pricePerShare is used to calculate transfer amount, a bug or wrong data retuning a smaller pricePerShare than it really is, could result in drainage of wibbtc from Curve pool.
Proof of Concept
Curve’s swap and remove liquidity functions will both call wibbtc’s transfer function:
- https://etherscan.io/address/0xFbdCA68601f835b27790D98bbb8eC7f05FDEaA9B#code%23L790
- https://etherscan.io/address/0xFbdCA68601f835b27790D98bbb8eC7f05FDEaA9B#code%23L831
- The
transferfunction calculates the amount to send by callingbalanceToShares:WrappedIbbtcEth.solL127 balanceToSharescalculates the shares (=amount to send) by dividing inpricePerShare:WrappedIbbtcEth.solL156
Therefore, if due to a bug or exploit in ibBTC core / the trusted oracle pricePerShare is smaller than it really is, the amount that will be sent will grow larger. So Curve will send to the user/exploiter doing swap/remove liquidity more tokens that he deserves.
Tools Used
Manual analysis, hardhat
Recommended Mitigation Steps
Add sanity check:
pricePerShare should never decrease but only increase with time (as ibbtc accrues interest) (validated with DefiDollar team). This means that on every pricePerShare read/update, if the new pricePerShare is smaller than the current one, we can discard the update as bad data.
This will prevent an exploiter from draining Curve pool’s wibbtc reserves by decreasing pricePerShare.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the contract does not validate that pricePerShare is not decreasing, so incorrect low values lead to inflated transfer amounts.
Impact
A bug or wrong data returning a smaller pricePerShare than real could result in drainage of wibbtc from the Curve pool.
What the attacker needed
PricePerShare becomes incorrectly low; attacker can swap or remove liquidity
The fix
Add a sanity check so that pricePerShare never decreases; discard updates where the new value is smaller than the current one.
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 report has not been written yet. The Original tab links to the source.
This report is about a smart contract that wraps a token and uses a price per share to decide how many tokens to send when someone transfers. If that price is wrong (too low), the contract sends too many tokens, letting someone take more than they should from a pool. The fix is to check that the price never goes down.
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.