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
Rank: 13/147
Findings: 2
Award: $524.94
π Selected for report: 0
π Solo Findings: 0
π Selected for report: ayden
Also found by: 0xWaitress, Madalad, Yanchuan, cartlex_, ciphermarco, critical-or-high, d3e4, mert_eren, peanuts, pontifex, trachev, twcctop
520.4229 USDC - $520.42
https://github.com/code-423n4/2023-10-ethena/blob/main/contracts/StakedUSDe.sol#L191
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 Gwei
of USDE to the StakedUSDeV2
contract after its deployment.10_000 USDE
.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.StakedUSDeV2
, a new StakedUSDeV2
should be deployed. An attacker repeats steps 1-3.Manual review.
Use ERC4626.sol
built-in protection mechanism from frontrunning with a "donation" attack instead of _checkMinShares()
.
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:
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
π Selected for report: 0xmystery
Also found by: 0x11singh99, 0xAadi, 0xAlix2, 0xG0P1, 0xStalin, 0xWaitress, 0x_Scar, 0xhacksmithh, 0xhunter, 0xpiken, Al-Qa-qa, Arz, Avci, Bauchibred, BeliSesir, Breeje, Bughunter101, DarkTower, Eeyore, Fitro, HChang26, Imlazy0ne, J4X, JCK, Kaysoft, Kral01, Madalad, Mike_Bello90, Noro, PASCAL, PENGUN, Proxy, Rickard, Shubham, SovaSlava, Strausses, Team_Rocket, ThreeSigma, Topmark, Udsen, Walter, Yanchuan, Zach_166, ZanyBonzy, adam-idarrha, adeolu, almurhasan, arjun16, ast3ros, asui, ayden, btk, cartlex_, castle_chain, cccz, chainsnake, codynhat, critical-or-high, cryptonue, csanuragjain, deepkin, degensec, dirk_y, erebus, foxb868, ge6a, hunter_w3b, jasonxiale, kkkmmmsk, lanrebayode77, lsaudit, marchev, matrix_0wl, max10afternoon, nuthan2x, oakcobalt, oxchsyston, pavankv, peanuts, pep7siup, pipidu83, pontifex, ptsanev, qpzm, radev_sw, rokinot, rotcivegaf, rvierdiiev, sorrynotsorry, squeaky_cactus, supersizer0x, tnquanghuy0512, twcctop, twicek, young, zhaojie, ziyou-
4.5226 USDC - $4.52
https://github.com/code-423n4/2023-10-ethena/blob/main/contracts/StakedUSDeV2.sol#L116
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.
Manual review.
Implement a queue for the owner to withdraw USDE from USDeSilo.
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