Skip to content
Access control Audit finding Intermediate

Permissioned nature of TwapOracle allows owner to manipulate oracle

The TwapOracle contract's update function is restricted to the owner, who can selectively call it to manipulate the time-weighted average price. This could allow the owner to extract value from the system by causing the oracle to report inaccurate prices.

TomFrenchBlockchain Follow

Originally disclosed on Code4rena

Submitted by TomFrenchBlockchain

Impact

Potentially frozen or purposefully inaccurate USDV:VADER price feed.

Proof of Concept

https://github.com/code-423n4/2021-11-vader/blob/3a43059e33d549f03b021d6b417b7eeba66cf62e/contracts/twap/TwapOracle.sol#L322

Only the owner of TwapOracle can call update on the oracle. Should the owner desire they could cease calling update on the oracle for a period. Over this period the relative prices of VADER and USDC will vary.

After some period timeElapsed the owner can call update again. A TWAP is a lagging indicator and due to the owner ceasing to update the oracle so timeElapsed will be very large, therefore we’re averaging over a long period into the past resulting in a value which may not be representative of the current USDV:VADER exchange rate.

The owner can therefore selectively update the oracle so to result in prices which allow them to extract value from the system.

Recommended Mitigation Steps

Remove the permissioning from TwapOracle.update

SamSteinGG (Vader) marked as duplicate

alcueca commented:

Duplicate of which other issue, @SamSteinGG?

SamSteinGG (Vader) commented:

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 TomFrenchBlockchain. 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

The update function is permissioned to the owner, allowing them to control when the oracle is updated and thus manipulate the time-weighted average price.

Impact

The owner could manipulate the oracle to produce inaccurate prices, potentially allowing them to extract value from the system.

What the attacker needed

Owner privileges

The fix

The permissioning should be removed from TwapOracle.update, and the module was later removed and redesigned.

How it was found

  1. The owner ceases calling update on the oracle for a period.
  2. During this period, the relative prices of VADER and USDC vary.
  3. After some timeElapsed, the owner calls update again, causing a large timeElapsed and averaging over a long period into the past.
  4. The resulting TWAP may not represent the current exchange rate, allowing the owner to extract value.

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.

A price oracle is a service that provides price data to a smart contract. Here, only the owner can update the oracle, and if they stop updating it for a while, the average price becomes stale and can be manipulated. This means the owner could unfairly profit from the system.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by TomFrenchBlockchain

View all

28 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.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.