Skip to content
Audit finding Intermediate

_getReserveRatioScalar() will give a lesser value than expected

The expansion controller calculates the number of expansions by dividing elapsed time by the expansion frequency, which rounds down and undercounts expansions when the elapsed time is not a multiple of the frequency. An attacker or any caller can trigger an expansion after a non-multiple interval, causing fewer tokens to be minted than intended.

0x73696d616f Follow with 0xc0ffEE, Ollam and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-10-mento-update-judging/issues/50

Found by

0x73696d616f, 0xc0ffEE, Ollam, Robert, onthehunt

Summary

numberOfExpansions = (block.timestamp - config.lastExpansion) / config.expansionFrequency

The calculation divides it by the expansionFrequency, but this will cause significant rounding issues.

If the expansionFrequency is 1 day (as specified in the docs), time may pass without anybody calling the function and the following scenario will be present.

Let's say 30 hours since last expansion and someone decides then to call it, it will be rounded due to the division to be 1 day, producing a smaller value than the hours that've passed.

Root Cause

The root cause is the potential of rounding down numberOfExpansions, which will give a significantly smaller value, depending on how big will be remainder of the division. (6 for 30 hours, 3 for 27 hours, etc)

Internal pre-conditions

mintUBIFromExpansion() need to be callable.

External pre-conditions

No response

Attack Path

  1. Alice calls mintUBIFromExpansion() to create an expansion
  2. 30 hours pass and nobody calls the function, Bob sees that he can call mintUBIFromExpansion()
  3. Due to the rounding down of the calculation, it will a value equivalent of 24 hours passing.

Impact

The protocol will expand slower than intended, thus less $G will be minted, which will become significant overtime.

PoC

No response

Mitigation

No response

Discussion

sherlock-admin2

The protocol team fixed this issue in the following PRs/commits: https://github.com/mento-protocol/mento-core/pull/553

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

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 truncates the number of expansions, discarding the remainder and undercounting elapsed intervals.

Impact

The protocol expands slower than intended, minting less $G over time, which could become significant.

What the attacker needed

MintUBIFromExpansion() is callable; expansionFrequency is set (e.g., 1 day)

The fix

The protocol team fixed this issue in a pull request.

How it was found

  1. Alice calls mintUBIFromExpansion() to create an expansion.
  2. 30 hours pass without anyone calling the function.
  3. Bob calls mintUBIFromExpansion().
  4. The calculation rounds down, treating only 24 hours as having passed.

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 is a smart contract that mints new tokens at regular intervals. It calculates how many intervals have passed by dividing the time since the last mint by the interval length, but this division throws away the remainder. So if 30 hours have passed and the interval is 24 hours, it only counts one interval instead of 1.25, meaning fewer tokens are created than should be.

More by 0x73696d616f

View all

172 more disclosed reports, best first.

More from Mento x Good$ Integration

View all

The newest disclosed reports for this program.

Similar reports

Same bug class and techniques, clearest first.