Beginner FriendlyFoundryDeFiOracle
100 EXP
View results
Submission Details
Severity: medium
Invalid

Reentrancy in updateExchangeRate

Summary

The code is attempting to update an exchange rate for an asset token based on a fee. An attacker could potentially exploit this by calling this function multiple times in quick succession.

Vulnerability Details

The reentrancy vulnerability in this code occurs because of the modification of the state (s_exchangeRate) before emitting the ExchangeRateUpdated event.

Impact

An attacker could potentially exploit this by calling this function multiple times in quick succession, and each time it's called, they could execute an external contract call, including other malicious code, before the event is emitted. This can result in unexpected and potentially harmful behavior.

Tools Used

Manual code analysis.

Recommendations

- s_exchangeRate = newExchangeRate;
- emit ExchangeRateUpdated(s_exchangeRate);
// Emit the event before modifying the state
+ emit ExchangeRateUpdated(newExchangeRate);
// Now update the state
+ s_exchangeRate = newExchangeRate;
Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Vague generalities

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.