Skip to content
Smart contracts Audit finding Intermediate

Decimal token underflow could produce loss of funds

The GUniLPOracle contract performs a decimal subtraction that can underflow when a pool token has more than 18 decimals. This could cause errors when the oracle calculates price values.

0x1f8b Follow

Originally disclosed on Code4rena

Submitted by 0x1f8b, also found by broccolirob and pauliax

https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/oracles/GUniLPOracle.sol#L47

https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/oracles/GUniLPOracle.sol#L51

It is possible to produce underflows with specific tokens which can cause errors when calculating prices.

Proof of Concept

The pragma is pragma solidity 0.6.12; therefore, integer overflows must be protected with safe math. But in the case of GUniLPOracle, there is a decimal subtraction that could underflow if any token in the pool has more than 18 decimals. This could cause an error when calculating price values.

Recommended Mitigation Steps

Ensure that tokens have less than 18 decimals.

m19 (Mimo DeFi) confirmed and commented:

We confirm this issue.


The original report as published on Code4rena, by 0x1f8b. 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

Impact

Price calculations could error out for pools containing tokens with more than 18 decimals, which the report frames as a possible loss of funds.

What the attacker needed

A pool token with more than 18 decimals

The fix

The report recommends ensuring that tokens have fewer than 18 decimals.

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 is a program that runs on a blockchain. This one works out the price of a pool of tokens, and it subtracts a number based on how many decimal places the tokens use. If a token uses more than 18 decimal places, that subtraction goes below zero, which the code does not handle, so the price calculation can fail.

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 0x1f8b

View all

21 more disclosed reports, best first.

More from Mimo DeFi 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.