DYAD - asui's results

The first capital efficient overcollateralized stablecoin.

General Information

Platform: Code4rena

Start Date: 18/04/2024

Pot Size: $36,500 USDC

Total HM: 19

Participants: 183

Period: 7 days

Judge: Koolex

Id: 367

League: ETH

DYAD

Findings Distribution

Researcher Performance

Rank: 163/183

Findings: 1

Award: $0.02

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2024-04-dyad/blob/cd48c684a58158de444b24854ffd8f07d046c31b/src/core/VaultManagerV2.sol#L134-L143

Vulnerability details

Impact

The calls to withdraw function can be dos by anyone using deposit function with 0 token transfers, which leads to stuck assets for those who want to withdraw.

Proof of Concept

Since the VaultManagerV2 contract uses idToBlockOfLastDeposit[id] = block.number; in deposit and withdraw function to prevent depositing and withdrawing at the same time(block). And the assets(eg. weth, wstETH) are ERC20 tokens which doesn't revert on 0 token transfers, an attacker who monitors the mempool can revert all withdraw transaction by frontrunning and calling the deposit function in the same block with 0 as amount.

When the attacker sees the withdraw transaction he can frontrun it by calling deposit which will update the idToBlockOfLastDeposit to the current block.number and when the withdrawer's transaction gets executed the check if (idToBlockOfLastDeposit[id] == block.number) revert DepositedInSameBlock(); will revert his withdrawal because the idToBlockOfLastDeposit is the current block. The attacker can repeat this everytime the targeted user tries to withdraw and spend only gas fees and 0 assets for this attack while the user is impossible to withdraw his assets.

Tools Used

manual

In the deposit function use isDNftOwner(id) modifier instead of isValidDNft(id) so that no one but the owner can deposit which will prevent the attack.

Or in both the functions change block.number to block.timestamp which will have a very rare/impossible case of two transactions to have the same timestamp rather than block.number which can be the same for two different transactions.

-      idToBlockOfLastDeposit[id] = block.number;
+      idToBlockOfLastDeposit[id] = block.timestamp;

Or set a minimum amount that must be deposited when deposit is called.

Assessed type

DoS

#0 - c4-pre-sort

2024-04-27T11:48:30Z

JustDravee marked the issue as duplicate of #489

#1 - c4-pre-sort

2024-04-29T09:28:40Z

JustDravee marked the issue as sufficient quality report

#2 - c4-judge

2024-05-05T20:38:14Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#3 - c4-judge

2024-05-05T20:39:23Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#4 - c4-judge

2024-05-05T21:21:52Z

koolexcrypto marked the issue as nullified

#5 - c4-judge

2024-05-05T21:21:58Z

koolexcrypto marked the issue as not nullified

#6 - c4-judge

2024-05-08T15:28:11Z

koolexcrypto marked the issue as duplicate of #1001

#7 - c4-judge

2024-05-11T19:50:28Z

koolexcrypto marked the issue as satisfactory

#8 - c4-judge

2024-05-13T18:34:30Z

koolexcrypto changed the severity to 3 (High Risk)

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