Ethena Labs - critical-or-high's results

Enabling The Internet Bond

General Information

Platform: Code4rena

Start Date: 24/10/2023

Pot Size: $36,500 USDC

Total HM: 4

Participants: 147

Period: 6 days

Judge: 0xDjango

Id: 299

League: ETH

Ethena Labs

Findings Distribution

Researcher Performance

Rank: 13/147

Findings: 2

Award: $524.94

QA:
grade-b

🌟 Selected for report: 0

πŸš€ Solo Findings: 0

Findings Information

Labels

bug
2 (Med Risk)
disagree with severity
downgraded by judge
high quality report
satisfactory
sponsor acknowledged
duplicate-88

Awards

520.4229 USDC - $520.42

External Links

Lines of code

https://github.com/code-423n4/2023-10-ethena/blob/main/contracts/StakedUSDe.sol#L191

Vulnerability details

Impact

An attacker could make staked USDE contract unusable by donating dust amount of USDE (asset tokens) just right after StakedUSDeV2 creation. Thus discouraging users from staking USDE.

StakedUSDe is a modified version of ERC4626, while it employs a tailored mechanism to protect from frontrunning with a "donation" attack.

The protection mechanism (the _checkMinShares() function) ensures that the total supply is greater than MIN_SHARES = 1 ETH.

/// @notice ensures a small non-zero amount of shares does not remain, exposing to donation attack function _checkMinShares() internal view { uint256 _totalSupply = totalSupply(); if (_totalSupply > 0 && _totalSupply < MIN_SHARES) revert MinSharesViolation(); }

This leads to the following DoS attack via dust USDE donation:

  1. An attacker donates 1 Gwei of USDE to the StakedUSDeV2 contract after its deployment.
  2. A legitimate user tries to deposit 10_000 USDE.
  3. The previewDeposit() function returns the amount of shares 10_000 * 10^18 * (1 / 10^9) which is less than MIN_SHARES = 10^18 and call to deposit() reverts.
  4. Since it's not possible to use StakedUSDeV2, a new StakedUSDeV2 should be deployed. An attacker repeats steps 1-3.

Proof of Concept

Tools Used

Manual review.

Use ERC4626.sol built-in protection mechanism from frontrunning with a "donation" attack instead of _checkMinShares().

Assessed type

DoS

#0 - c4-pre-sort

2023-10-30T22:43:45Z

raymondfam marked the issue as primary issue

#1 - c4-pre-sort

2023-10-30T22:44:18Z

raymondfam marked the issue as sufficient quality report

#2 - raymondfam

2023-10-30T22:45:22Z

Contract unusable indeed.

#3 - c4-pre-sort

2023-11-01T19:11:55Z

raymondfam marked the issue as high quality report

#4 - c4-sponsor

2023-11-10T12:14:20Z

FJ-Riveros marked the issue as disagree with severity

#5 - FJ-Riveros

2023-11-10T12:22:37Z

We acknowledge the potential exploitability of this issue, but we propose marking it as Medium severity. Our rationale is based on the fact that this exploit can only occur during deployment. To mitigate this risk, we plan to fund the smart contract in the next block, ensuring that nobody has access to the ABI or contract source code. We could even use flashbots for this purpose.

#6 - c4-sponsor

2023-11-10T14:26:43Z

FJ-Riveros (sponsor) acknowledged

#7 - fatherGoose1

2023-11-10T20:52:08Z

Agree with medium. Several of the duplicate reports vary in their final impacts but mostly consist of:

  • Small donation leading to bricked contract (this report)
  • Large donation can eventually lead to blocked withdrawals.

The small donation impact simply requires a redeploy, though the impact is a valid medium. The large donation has major implications for stakers, but the large amount of capital required downgrades it to medium as well. I will be reviewing each duplicate on a case-by-case basis to ensure that all impacts due to the same bug class fit within medium.

#8 - c4-judge

2023-11-10T20:52:21Z

fatherGoose1 changed the severity to 2 (Med Risk)

#9 - c4-judge

2023-11-10T20:52:29Z

fatherGoose1 marked the issue as satisfactory

#10 - c4-judge

2023-11-14T17:17:03Z

fatherGoose1 marked issue #88 as primary and marked this issue as a duplicate of 88

Lines of code

https://github.com/code-423n4/2023-10-ethena/blob/main/contracts/StakedUSDeV2.sol#L116

Vulnerability details

Impact

Functions StakedUSDev2.cooldownShares() and StakedUSDev2.cooldownAssets() allow someone to withdraw USDE on behalf of the owner in case the owner approves some amount of staked USDE to someone.

It allows such a person with approved staked USDE from the owner to grief them by calling periodically cooldownShares() or cooldownAssets() with one wei amount of shares/assets. As a result, the owner cannot withdraw their USDE by calling unstake().

When cooldownShares() or cooldownAssets() is called (on behalf of the owner) cooldowns[owner].cooldownEnd is re-written witn new value uint104(block.timestamp) + cooldownDuration. Because of that, the following condition is false and unstake() reverts.

Proof of Concept

Tools Used

Manual review.

Implement a queue for the owner to withdraw USDE from USDeSilo.

Assessed type

DoS

#0 - c4-pre-sort

2023-10-30T21:23:51Z

raymondfam marked the issue as sufficient quality report

#1 - c4-pre-sort

2023-10-30T21:23:56Z

raymondfam marked the issue as primary issue

#2 - raymondfam

2023-10-30T21:24:45Z

Inflexibility entailed too.

#3 - c4-pre-sort

2023-11-01T19:39:08Z

raymondfam marked the issue as duplicate of #514

#4 - c4-judge

2023-11-10T21:27:01Z

fatherGoose1 marked the issue as unsatisfactory: Invalid

#5 - c4-judge

2023-11-17T17:04:09Z

fatherGoose1 changed the severity to QA (Quality Assurance)

#6 - c4-judge

2023-11-27T20:08:05Z

fatherGoose1 marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax Β© 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter