Unable To Call emergencyWithdraw
ETH in NoYield
Contract
#52
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Handle
leastwood
Vulnerability details
Impact
The
emergencyWithdraw
function is implemented in all yield sources to allow theonlyOwner
role to drain the contract's balance in case of emergency. The contract considers ETH as a zero address asset. However, there is a call made on_asset
which will revert if it is the zero address. As a result, ETH tokens can never be withdrawn from theNoYield
contract in the event of an emergency.Proof of Concept
Consider the case where
_asset == address(0)
. An external call is made to check the contract's token balance for the target_asset
. However, this call will revert as_asset
is the zero address. As a result, theonlyOwner
role will never be able to withdraw ETH tokens during an emergency.Affected function as per below:
https://github.com/code-423n4/2021-12-sublime/blob/main/contracts/yield/NoYield.sol#L78-L83
Tools Used
Manual code review.
Recommended Mitigation Steps
Consider handling the case where
_asset
is the zero address, i.e. the asset to be withdrawn under emergency is the ETH token.The text was updated successfully, but these errors were encountered: