DYAD - blutorque'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: 169/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#L143

Vulnerability details

Impact

The deposit() function allows anyone to deposit on behalf of other user(holding dNFT). This result in updating the idToBlockOfLastDeposit[id] to current block.number. As a result, any future withdrawal for that id in the same block will revert.

Actually, the idToBlockOfLastDeposit[id] is used to prevent from flashloan based attack, which require deposit and withdraw to be in the same txn. However, this check can also maliciously be used against legitmate user who want to withdraw their assets.

Proof of Concept

  1. A user sent a withdraw() txn to VaultManagerV2,
  2. Attacker saw the txn in mempool and sent a deposit() txn for that user id, with 1 wei of assets as amount,
  3. Since, the withdraw call got frontrunned by the deposit txn, the idToBlockOfLastDeposit[id] got updated,
  4. The withdraw txn got reverts, due to err DepositedInSameBlock().

Tools Used

Manual review

Allow idToBlockOfLastDeposit[id] to update, only when the caller is the ownerOf(id). This way, anyone can make deposit to id without any interruption.

function deposit( uint id, address vault, uint amount ) external isValidDNft(id) { - idToBlockOfLastDeposit[id] = block.number; + if (dNft.ownerOf(id) == msg.sender) idToBlockOfLastDeposit[id] = block.number; Vault _vault = Vault(vault); _vault.asset().safeTransferFrom(msg.sender, address(vault), amount); _vault.deposit(id, amount); }

Assessed type

DoS

#0 - c4-pre-sort

2024-04-27T11:38:31Z

JustDravee marked the issue as duplicate of #1103

#1 - c4-pre-sort

2024-04-27T11:45:35Z

JustDravee marked the issue as duplicate of #489

#2 - c4-pre-sort

2024-04-29T09:28:38Z

JustDravee marked the issue as sufficient quality report

#3 - c4-judge

2024-05-05T20:38:17Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#4 - c4-judge

2024-05-05T20:39:23Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#5 - c4-judge

2024-05-05T20:39:26Z

koolexcrypto marked the issue as unsatisfactory: Invalid

#6 - c4-judge

2024-05-05T21:40:10Z

koolexcrypto marked the issue as nullified

#7 - c4-judge

2024-05-05T21:40:16Z

koolexcrypto marked the issue as not nullified

#8 - c4-judge

2024-05-08T15:28:00Z

koolexcrypto marked the issue as duplicate of #1001

#9 - c4-judge

2024-05-11T19:53:10Z

koolexcrypto marked the issue as satisfactory

#10 - 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