Skip to content
DoS Audit finding Intermediate

WrappedAerodromeAM.sol is not compatible with the Revert on Zero Value Tokens

The WrappedAerodromeAM contract's decreaseLiquidity and claimFees functions unconditionally transfer fee amounts to the position owner, even when a fee is zero. If the underlying token reverts on zero-value transfers, the transfer fails, causing a denial of service that prevents users from decreasing liquidity or claiming fees.

blackhole Follow with merlin

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-04-arcadia-pricing-module-judging/issues/23

Found by

blackhole, merlin

Summary

From the README file: We also want to receive issues regarding minimal implementations of ERC20 Tokens, which besides a standard implementation have one of the following "weird behaviours": Revert on Zero Value.

Vulnerability Detail

When the owner of a position calls WrappedAerodromeAM.decreaseLiquidity, they should receive the transferred liquidity back and fees.

Let's consider the following scenario:

1)The owner of the position calls decreaseLiquidity, and they are supposed to receive fees.

Solidity
        // Claim any pending fees from the Aerodrome Pool.
        (uint256 fee0Pool, uint256 fee1Pool) = _claimFees(pool);

        // Calculate the new fee balances.
        (poolState_, positionState_) = _getFeeBalances(poolState_, positionState_, fee0Pool, fee1Pool);

2)Since the fee for the revert on zero transfer token is zero, a DOS will occur, and the user will not be able to decrease liquidity.

Solidity
        // Pay out the fees to the position owner.
        ERC20(token0[pool]).safeTransfer(msg.sender, fee0Position);  //fee0Position = 0
        ERC20(token1[pool]).safeTransfer(msg.sender, fee1Position); // or fee1Position = 0
        emit FeesPaid(positionId, uint128(fee0Position), uint128(fee1Position));

Impact

A denial-of-service (DOS) can occur on the decreaseLiquidity and claimFees functions in WrappedAerodromeAM smart contract of the revert on zero transfer token when the fee is zero value.

Code Snippet

src/asset-modules/Aerodrome-Finance/WrappedAerodromeAM.sol#L452-L453 src/asset-modules/Aerodrome-Finance/WrappedAerodromeAM.sol#L411-L412

Tool used

Manual Review

Recommendation

Consider changing decreaseLiquidity and claimFees functions as follows:

Diff
+ if (fee0Position != 0)
            ERC20(token0[pool]).safeTransfer(msg.sender, fee0Position);
+ if (fee1Position != 0)
            ERC20(token1[pool]).safeTransfer(msg.sender, fee1Position);

Discussion

sherlock-admin4

2 comment(s) were left on this issue during the judging contest.

takarez commented:

this should be valid considering the readMe stated to report issues with the said(weird) behavior; medium(1)

shealtielanz commented:

dup of #033

sherlock-admin3

The protocol team fixed this issue in the following PRs/commits: https://github.com/arcadia-finance/accounts-v2/pull/202

oxwhite

What does "besides a standard implementation have one of the following "weird behaviours": Revert on Zero Value" mean? What ı understand the protocol will not accept any vulnerability related to "Revert on Zero Value" and the followings mentioned in ReadMe, which means it is out of scope. How can this submission be valid?

sherlock-admin2

The Lead Senior Watson signed off on the fix.

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

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

The contract does not check whether the fee amount is zero before calling safeTransfer, so tokens that revert on zero-value transfers cause the entire transaction to fail.

What the attacker needed

Token reverts on zero-value transfers; position has zero fees to claim

The fix

The contract was fixed by only transferring fees when the amount is non-zero.

How it was found

  1. The position owner calls decreaseLiquidity and is supposed to receive fees.
  2. The contract claims pending fees from the Aerodrome pool and calculates the new fee balances.
  3. The contract attempts to transfer the fee to the position owner, but the fee amount is zero.
  4. Because the token reverts on zero-value transfers, the transfer fails and the entire decreaseLiquidity call 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.

Some tokens refuse to transfer a zero amount, which is unusual but allowed. The contract always tries to send the fee, even when it is zero, so the transfer fails and the whole function stops. This means users cannot withdraw their liquidity or collect fees when one of the fees happens to be zero.

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 blackhole

View all

2 more disclosed reports, best first.

More from Arcadia - Aerodrome integrations

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.