The PrincipalToken contract's deposit function is intended to handle ERC-20 token transactions but does not support the deposit of native ETH. Users attempting to deposit native ETH will experience transaction failures, leading to a poor user experience and potential loss of gas fees. Additionally, the inability to deposit native ETH limits the contract's functionality and accessibility, as users must first convert their ETH to the accepted ERC-20 token format before interacting with the contract.
Proof of Concept
for example PrincipalToken contract takes stETH as IBT
A user attempts to deposit native ETH by calling the deposit function and sending ETH along with the transaction.
The transaction reverts because the deposit function is not marked as payable and thus cannot accept native ETH.
Even if the function were payable, the logic within the function expects to interact with an ERC-20 token, using methods like safeTransferFrom and safeIncreaseAllowance, which are not applicable to native ETH.
Since stETH's underlying asset is ETH, users might reasonably expect to be able to deposit ETH directly. The contract's inability to handle this case is a significant usability issue.
Tools Used
Manual Review
Recommended Mitigation Steps
Implement a new depositETH and WithdrawEth function that is marked as payable to accept native ETH.
Lines of code
https://github.com/code-423n4/2024-02-spectra/blob/383202d0b84985122fe1ba53cfbbb68f18ba3986/src/tokens/PrincipalToken.sol#L176-L185
Vulnerability details
Impact
The
PrincipalToken
contract'sdeposit
function is intended to handleERC-20
token transactions but does not support the deposit of nativeETH
. Users attempting to deposit native ETH will experience transaction failures, leading to a poor user experience and potential loss of gas fees. Additionally, the inability to deposit native ETH limits the contract's functionality and accessibility, as users must first convert their ETH to the accepted ERC-20 token format before interacting with the contract.Proof of Concept
for example
PrincipalToken
contract takesstETH
as IBTA user attempts to deposit native ETH by calling the
deposit
function and sending ETH along with the transaction.The transaction reverts because the deposit function is not marked as payable and thus cannot accept native ETH.
Even if the function were payable, the logic within the function expects to interact with an ERC-20 token, using methods like
safeTransferFrom
andsafeIncreaseAllowance
, which are not applicable to native ETH.Since
stETH's
underlying asset isETH
, users might reasonably expect to be able to deposit ETH directly. The contract's inability to handle this case is a significant usability issue.Tools Used
Manual Review
Recommended Mitigation Steps
Implement a new
depositETH
andWithdrawEth
function that is marked as payable to accept native ETH.Assessed type
Error