Open hats-bug-reporter[bot] opened 8 months ago
Need to add import { console2 as console } from "forge-std/console2.sol";
to OrigamiOToken.t.sol
to use the console.log
for the foundry test.
OrigamiOToken::circulatingSupply
function is used in OrigamiLendingClerk::globalUtilisationRatio
& OrigamiLendingClerk::_globalAvailableToBorrow
, these functions are core functions that in charge of the calculation of borrow and utilisation ratio. If the afftected function underflow, wrong value will be fetched and calculation will be manipulated or wrong. An exploiter can manipulate the affected function to its own benefits.
looking into this now thanks
@erictee2802 This is a great find, thank you so much for reporting.
amoMint()
can only be called with elevated access, and will only be minted to protocol owned contracts or trusted parties (for example protocol owned liquidity). However you are correct that the holder of the AMO minted tokens can call burn()
instead of amoBurn()
-- either accidentally or maliciously.
In terms of impact:
oToken.circulatingSupply()
is only used within OrigamiLendingClerk
to determine the current globalUtilisationRatio()
(defined as totalBorrowerDebt() - oToken.circulatingSupply()
), and _globalAvailableToBorrow()
circulatingSupply() == ~type(uint256).max
means the utilisation ratio is almost zero, meaning the _calculateGlobalInterestRate()
will be set to the min interest rate._calculateCombinedInterestRate()
amoMinted()
has no external dependencies.So this has no impact on user funds, only a minor impact on the interest rate due to the OrigamiLendingClerk.
Therefore we see this as a medium finding.
I've put together an end to end test which can be added into OrigamiLovTokenIntegrationTest.t.sol
If you think there is more to this issue, please provide a further PoC/test.
Please keep up the great hunting 🙏
Github username: @erictee2802 Twitter username: 0xEricTee Submission hash (on-chain): 0x995c916914d1e7efc77578b362f16ea38069bbc9f22c3e35e9b0f5f74712901d Severity: high
Description: Description\
OrigamiOToken::circulatingSupply will underflow when users burn their tokens.
Attack Scenario\
Check the Poc below.
Attachments
NA
Add the following content to
OrigamiOToken.t.sol
:Foundry Result:
ERC20Burnable
functions if not used.