Skip to content
Business logic Audit finding Intermediate

Oracle will become invalid much faster than intended on non-mainnet chains

The NFT floor price oracle uses a fixed number of blocks (1800) to decide if a price is still valid, assuming 12-second blocks. On chains with faster block times, prices expire much sooner than the intended six hours, so the oracle may reject valid prices.

Trust Follow

Originally disclosed on Code4rena

Submitted by Trust

https://github.com/code-423n4/2022-11-paraspace/blob/c6820a279c64a299a783955749fdc977de8f0449/paraspace-core/contracts/misc/NFTFloorOracle.sol#L12

NFTFloorOracle is in charge of answering price queries for ERC721 assets. EXPIRATION_PERIOD constant is the max amount of blocks allowed to have passed for the reading to be considered up to date:

uint256 diffBlock = currentBlock - priceInfo.updatedAt;
if (diffBlock <= config.expirationPeriod) {
    validPriceList[validNum] = priceInfo.twap;
    validNum++;
}

We can see it is set to 1800, which is intended to be 6 hours with 12 second block time assumption:

//expirationPeriod at least the interval of client to feed data(currently 6h=21600s/12=1800 in mainnet)
//we do not accept price lags behind to much
uint128 constant EXPIRATION_PERIOD = 1800;

The issue is that different blockchains have wildly different block times. BSC has one every 3 seconds, while Avalanche has a new block every 1 sec. Also the block product rate may be subject to future changes. Therefore, readings may be considered stale much faster than intended on non-mainnet chains.

The correct EVM compatible way to check it is using the block.timestamp variable. Make sure the difference between current and previous timestamp is under 6 * 3600 seconds.

Paraspace docs show they are clearly intending to deploy in multiple chains so it’s very relevant.

Impact

Oracle will become invalid much faster than intended on non-mainnet chains.

Recommended Mitigation Steps

Use block.timestamp to measure passage of time.


The original report as published on Code4rena, by Trust. 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 contract measures time in block counts instead of using the block timestamp, so the expiration period is wrong on chains with different block times.

What the attacker needed

Deployment on a chain with block time not 12 seconds

The fix

The contract should use block.timestamp to measure the passage of time instead of counting blocks.

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 smart contract oracle checks whether a price is fresh by counting how many blocks have passed since it was last updated. It assumes each block takes 12 seconds, so 1800 blocks equals six hours. But other blockchains produce blocks faster, so the same 1800 blocks pass in much less time, making the price expire too early.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Trust

View all

77 more disclosed reports, best first.

More from ParaSpace contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.