Skip to content
Smart contracts Audit finding Intermediate

USDV and VADER rate can be wrong

The TWAP oracle's rate calculation can return zero when one internal price is smaller than another, leading to an incorrect rate. An attacker could potentially exploit this to manipulate the reported rate.

xYrYuYx Follow

Originally disclosed on Code4rena

Submitted by xYrYuYx

Impact

https://github.com/code-423n4/2021-11-vader/blob/main/contracts/twap/TwapOracle.sol#L166

tUSDInUSDV can be smaller than tUSDInVader, and then getRate will return 0. This will lead wrong rate calculation.

Tools Used

Manually

Recommended Mitigation Steps

Multiple enough decimals before division

SamSteinGG (Vader) confirmed

The TWAP oracle module has been completely removed and redesigned from scratch as LBTwap that is subject of the new audit.

The original report as published on Code4rena, by xYrYuYx. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely integer division truncation causes the rate to become zero when the numerator is smaller than the denominator.

Impact

The rate calculation can be wrong, potentially allowing an attacker to exploit the incorrect rate.

What the attacker needed

None

The fix

The issue was fixed by removing and redesigning the TWAP oracle module.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This report is about a smart contract that calculates an exchange rate between two tokens. The calculation can produce zero because of how numbers are divided, which makes the rate wrong. Someone could use this wrong rate to their advantage.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by xYrYuYx

View all

3 more disclosed reports, best first.

More from Vader Protocol contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.