Skip to content
Business logic Audit finding Intermediate

Decimals limitation limits the tokens that can be used

The contract's oracle normalisation formula can underflow when the asset's decimals exceed 18 plus the collateral's decimals, causing a revert. This prevents deployment of certain token pairs, such as those with USDC and tokens with more than 24 decimals.

CertoraInc Follow

Originally disclosed on Code4rena

Submitted by CertoraInc

Decimals limitation limits the tokens that can be used.

Proof of Concept

Let’s give some name to the decimals of certain numbers: n = decimals of numerator oracle. d = decimals denominator oracle. a = decimals of the asset. c= decimals of the collateral.

Now, the oracleNormalization = 10 ^(18 + n - d + a - c).

And here: https://github.com/code-423n4/2022-08-frax/blob/main/src/contracts/FraxlendPairCore.sol#L536 , price has decimals of 36 + n -d, so here() when we calculate _exchangeRate = _price / oracleNormalization; it would underflow and revert if a >18 +c.

And that’s a pretty big limitation on the tokens options. We have USDC which have 6 decimals so all the tokens the their decimals < 24 are not possible to use in this system (with USDC together).

DrakeEvans (Frax) disputed, disagreed with severity and commented:

Known issue, prevents certain combinations of tokens from being deployed. No high risk as no deployment will occur. No funds at risk, no incorrect functionality. Low at best.

gititGoro (judge) decreased severity to Medium and commented:

This hasn’t been listed as a known issue so it can’t be marked invalid but since deployments can’t occur, it’s a Medium severity.


The original report as published on Code4rena, by CertoraInc. 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 the oracle normalisation formula does not account for all decimal combinations, so the division can underflow when the asset has many decimals relative to the collateral.

Impact

Certain token combinations cannot be deployed, but no funds are at risk and no incorrect functionality occurs because deployment fails.

What the attacker needed

Deploying a pair with asset decimals > 18 + collateral…

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.

Smart contracts often combine prices from oracles with different decimal precisions. If the formula that adjusts for these decimals is wrong, the calculation can go below zero and the transaction fails. Here, that failure means some token pairs simply cannot be used in the system.

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 CertoraInc

View all

16 more disclosed reports, best first.

More from Frax Ether Liquid Staking 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.