Skip to content
DoS Audit finding Intermediate

sFrxEth may revert on redeeming non-zero amount

d3e4 Follow

Originally disclosed on Code4rena

Submitted by d3e4

https://github.com/code-423n4/2023-03-asymmetry/blob/44b5cd94ebedc187a08884a7f685e950e987261c/contracts/SafEth/derivatives/SfrxEth.sol#L61-L65 https://github.com/code-423n4/2023-03-asymmetry/blob/44b5cd94ebedc187a08884a7f685e950e987261c/contracts/SafEth/SafEth.sol#L118

Impact

Unstaking is blocked.

Proof of Concept

When unstaking the withdraw of each derivative is called. SfrxEth.withdraw calls IsFrxEth(SFRX_ETH_ADDRESS).redeem(_amount, address(this), address(this));. This function may revert if _amount is low due to the following line in redeem (where _amount is shares): require((assets = previewRedeem(shares)) != 0, "ZERO_ASSETS"); previewRedeem(uint256 shares) returns convertToAssets(shares) which is the shares scaled by the division of total assets by total supply: shares.mulDivDown(totalAssets(), supply). So if _amount == 1 and total assets in sFrxEth is less than its total supply, then previewRedeem(shares) == 0 and redeem will revert. This revert in SfrxEth.withdraw causes a revert in SafEth.unstake at L118, which means that funds cannot be unstaked.

_amount may be as low as 1 when the weight for this derivative has been set to 0 and funds have adjusted over time through staking and unstaking until only 1 remains in the SfrxEth derivative. Instead of just being depleted it may thus block unstaking.

Recommended Mitigation Steps

In SfrxEth.withdraw check if IsFrxEth(SFRX_ETH_ADDRESS).previewRedeem(_amount) == 0 and simply return if that’s the case.

elmutt (Asymmetry) acknowledged, but disagreed with severity and commented:

Valid, but feels like an extreme edge case so disagreeing with severity.

Picodes (judge) decreased severity to Low and commented:

The same reasoning works when staking and is mitigated by the min amount. So when unstaking it makes sense to assume that users will unstake at least min amount. Downgrading to Low.

d3e4 (warden) commented:

@Picodes - The amount unstaked from each derivative is a percentage of it’s remaining balance. So if 50 % of the total supply of safEth is unstaked only 50 % of sFrxEth will be withdrawn, whether that be millions or just 1 out of 2 Wei remaining. In the scenario I provided (the weight of sFrxEth set to 0) fractions (not absolute amounts!) of the sFrxEth balance will be withdrawn and close to 0 it will decrease very slowly, eventually hitting 1.

Picodes (judge) increased severity to Medium and commented:

@d3e4 - You are right and my previous comment was incorrect.

The admin may set the weight of sFrxETH to 0, then the balance will slowly decrease, and eventually get very small and lead to this potential DOS. Starting with 1e18 sFrxETH, it’d take ~60 withdrawals of 50% of the SafEth supply to reach this zone.

Note that adding the possibility to remove derivative would also solve this, so we could argue that this is linked to #703.

toshiSat (Asymmetry) commented:

We added an enable/disable to derivative so this will be fixed with that. This is a valid ticket.

romeroadrian (warden) commented:

This is an excellent finding.

Asymmetry mitigated:

Fixing it by enable/disable derivatives.

Status: Not mitigated. Full details in reports from adriro, d3e4, and 0x52 - and also shared below in the Mitigation Review section.


The original report as published on Code4rena, by d3e4. 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.

What is known

A medium-severity doS bug in Asymmetry Finance afETH Invitational. Code4rena made it public on 28 July 2023. Found in the 2023-03-asymmetry audit contest (finding M-02).

About DoS

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

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

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 d3e4

View all

19 more disclosed reports, best first.

More from Asymmetry Finance afETH 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.