Bad pricing mechanism of InvestToken::mint
and InvestToken::withdraw
causes infinite USDE minting bug
#131
Labels
duplicate
This issue or pull request already exists
Github username: @https://github.com/37H3RN17Y2
Twitter username: -
Submission hash (on-chain): 0xb72a6644f5dae04e00be541698dc46f7e22fbc58dffdf60825b0ce88a938ba80
Severity: high
Description:
Description
In the project README (excerpt below), it states that any conversion from USDE to investToken (EUI) should follow current price, whereas conversion from EUI to USDE should follow previous price. This is such that users depositing USDE or converting EUI does not accrue the yield of the same day.
However, the implementation of USDE and EUI conversion does not follow these descriptions. Additionally, chaining these vulnerabilities together will result in infinite USDE minting bug (described below).
The implementation of
InvestToken::mint
usesYieldOracle::previousPrice
via the pathInvestToken::mint
>>InvestToken::convertToAssets
>>YieldOracle::sharesToAssets
>>YieldOracle::previousPrice
. Hence conversions of USDE to EUI will follow previous price, and users will accrue yields on the same day, breaking protocol functionality.The implementation of
InvestToken::withdraw
usesYieldOracle::currentPrice
via the pathInvestToken::withdraw
>>InvestToken::convertToShares
>>YieldOracle::assetsToShares
>>YieldOracle::currentPrice
. Hence conversions of EUI to USDE will follow current price, and users will accrue yields on the same day, breaking protocol functionality.As enforced by YieldOracle.sol#L92, the conversion price between USDE to EUI can only increase and never decrease. Hence, users can call
InvestToken::mint
to convert USDE to EUI at the lowerYieldOracle::previousPrice
and immediately callInvestToken::withdraw
to convert EUI to USDE at a higherYieldOracle::currentPrice
to profit from the price difference. Calling these 2 functions repeatedly allows users to mint infinite USDE for themselves, thus breaking protocol functionality.Impact
Impact: HIGH. Infinite USDE minting bug causes USDE hyperinflation and breaks the USDE token peg.
Likelihood: HIGH. The attack relies on simple preconditions (described below) and users are incentivized to exploit this bug for a profit.
Severity: HIGH
Attack Scenario
The attack relies on the following preconditions.
The attack path is as follows
InvestToken::mint
to convert USDE to EUI at the lower price ofYieldOracle::previousPrice
.InvestToken::withdraw
to convert EUI back to USDE at the higher price ofYieldOracle::currentPrice
, thus gaining more USDE.Attachments
Place the PoC in a new file and run the following code.
The infinite USDE minting bug is caused by the bad pricing mechanism of
InvestToken::mint
andInvestToken::withdraw
. Fixing these pricing issues by using separate EUI/USDE conversion functions forpreviousPrice
andcurrentPrice
will resolve the bug.Modifications to YieldOracle.sol
Modifications to InvestToken.sol
Files:
The text was updated successfully, but these errors were encountered: