Skip to content
DoS Audit finding Intermediate

Users cannot unstake from YiedlETHStakingEtherfi.sol, because YieldAccount.sol is incompatible with ether.fi’s WithdrawRequestNFT.sol

The YieldAccount contract used for each user does not implement the onERC721Received callback required by ether.fi's WithdrawRequestNFT when it safe-mints a withdrawal request NFT. As a result, users cannot unstake from YiedlETHStakingEtherfi, locking their funds, yield and NFT collateral.

oakcobalt Follow with 0x73696d616f and bin2chen

Originally disclosed on Code4rena

Submitted by oakcobalt, also found by 0x73696d616f and bin2chen

In YiedlETHStakingEtherfi::stake, users yieldBorrow WETH, convert it to ETH, and stake in Ether.fi’s LiquidityPool. Ether.fi’s LiquidityPool will mint eETH (protocol token) to the user’s yieldAccount.

Users will unstake() by requesting withdrawal of staked ETH from ether.fi’s WithdrawRequestNFT::requestWithdraw.

The problem is WithdrawRequestNFT::requestWithdraw will _safeMint an NFT token to the user’s yieldAccount as proof of request withdrawal. But the user’s yieldAccount is not compatible with _safeMint because the implementation YieldAcount.sol doesn’t have onERC721Received method required by _safeMint.

//src/yield/YieldAccount.sol
...
//@audit YieldAcount doesn't inherit openzeppelin's ERC721Holder.sol, neither does it implement onERC721Received. Not compatible with safeMint method required by ether.fi's WithdrawRequestNFT.
contract YieldAccount is IYieldAccount, Initializable {
...

https://github.com/code-423n4/2024-07-benddao/blob/117ef61967d4b318fc65170061c9577e674fffa1/src/yield/YieldAccount.sol#L15

Flows: YieldStakingBase::unstake →YieldEthStakingEtherfi::protocolRequestWithdrawal → liquidityPool::requestWithdraw → WithdrawRequestNFT::requestWithdraw → _safeMint (recipient, requestId)

    function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {
        _mint(to, tokenId);
        require(
            _checkOnERC721Received(address(0), to, tokenId, data),
            "ERC721: transfer to non ERC721Receiver implementer"
        );
    }

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol#L315

Because yieldAcount.sol is cloned for every user and atomically used as caller address for ether.fi interactions, no one can unstake from YiedlETHStakingEtherfi.sol. User funds, yield and nft collaterals will be locked. When users’ positions become unhealthy (e.g., nft token price drops), yieldBorrow debts compounding can also put the protocol at risks.

Note: In the unit test file for test/yield/YieldEthStakingEtherfi.t.sol, unit tests passed only because a MockEtherfiWithdrawRequestNFT.sol is used that uses _mint() instead of _safeMint().

Recommended Mitigation Steps

Add onERC721Received support in YieldAccount.sol.

thorseldon (BendDAO) confirmed and commented:

Fixed here.


The original report as published on Code4rena, by oakcobalt. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the YieldAccount contract does not inherit or implement the ERC721Holder interface, so it cannot receive NFTs via safeMint.

Impact

Users cannot unstake, so their funds, yield and NFT collateral are locked, and unhealthy positions could put the protocol at risk.

What the attacker needed

User has staked via YiedlETHStakingEtherfi

The fix

The issue was fixed by adding onERC721Received support in YieldAccount.sol.

How it was found

  1. User calls unstake on YieldStakingBase.
  2. The call reaches YieldEthStakingEtherfi::protocolRequestWithdrawal.
  3. That calls liquidityPool::requestWithdraw.
  4. Which calls WithdrawRequestNFT::requestWithdraw.
  5. WithdrawRequestNFT tries to safeMint the withdrawal request NFT to the user's yieldAccount.
  6. The safeMint fails because yieldAccount has no onERC721Received, so the transaction reverts.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a contract sends an NFT to another contract, the receiving contract must have a special function that says it can accept NFTs. Here the user's yield account contract lacks that function, so the NFT transfer fails and the whole unstaking transaction reverts. That means users cannot get their staked money back.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by oakcobalt

View all

50 more disclosed reports, best first.

More from BendDAO Invitational

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.