This repository has been archived by the owner on May 26, 2023. It is now read-only.
hansfriese - ERC5095.withdraw()
and ERC5095.redeem()
don't transfer the principal token to the contract when they work before maturity.
#124
Labels
hansfriese
high
ERC5095.withdraw()
andERC5095.redeem()
don't transfer the principal token to the contract when they work before maturity.Summary
ERC5095.withdraw()
andERC5095.redeem()
don't transfer the principal token to the contract when they work before maturity.Vulnerability Detail
ERC5095.withdraw()
andERC5095.redeem()
are used to withdraw/redeem the principal token and receive the underlying token.These functions are available before maturity as well and they exchange from the principal token to the underlying using the marketplace in this case.
But they don't transfer the principal token to the contract properly and let me explain in detail with withdraw() function.
In the
withdraw()
function, it callsMarketPlace.sellPrincipalToken()
to exchange from the pricipal to underlying here and here.And MarketPlace.sellPrincipalToken() exchanges using the pool.
It transfers the principal token to the pool here from
msg.sender
.So when this function is called from the
ERC5095
contract,msg.sender
will be theERC5095
contract itself.But in the
ERC5095.withdraw()
, it doesn't transfer the principal token frommsg.sender
to the contract so that the balance of the contract itself will be used.After all, if the contract has some balance already, a malicious caller can receive the underlying token for free and if the contract doesn't have any balance,
withdraw()
will always revert.Impact
ERC5095.withdraw()
andERC5095.redeem()
will always revert when theERC5095
contract doesn't have enough balance of the principal token.If not, the users can earn the underlying token for free by burning the contract's balance.
Code Snippet
https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/tokens/ERC5095.sol#L218-L248
https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/tokens/ERC5095.sol#L293-L317
Tool used
Manual Review
Recommendation
We should transfer the principal token to the contract before calling the
sellPrincipalToken()
function inERC5095.withdraw()
andERC5095.redeem()
.Duplicate of #195
The text was updated successfully, but these errors were encountered: