Debasing/rebasing periods can be decreased by 50% by a malicious actor
The debasing calculation rounds down the number of periods, and a malicious user can call the update function at a specific time to cause only one period to be counted instead of two, slowing the debase rate. This keeps the collateral factor low and harms the protocol.
Source: https://github.com/sherlock-audit/2024-12-numa-audit-judging/issues/18
Found by
000000
Vulnerability Detail
Upon debasing, we have the following calculation:
uint ndebase = ((blockTime - lastBlockTime) * debaseValue) / (deltaDebase);
If the time passed is less than 4320, we round down to 0 (debaseValue is 20 and deltaDebase is 24 hours). However, there is the following check to handle such round downs:
if (ndebase <= 0) {
// not enough time has passed to get some debase, so we reset our time reference
blockTime = lastBlockTime;
}
It resets the time to the last block time before the update. However, this can still be abused by a malicious actor by instead rounding to 1. It can also happen during normal conditions by users simply interacting with the protocol at certain times.
Attack Path
- Malicious user calls
VaultManager.getSynthScalingUpdate()or any other block time state updating function every $4320 * 2 - 1$ seconds - The
ndebasewill equal $(4320 * 2 - 1) * 20 / 86400 = 1,9997685185$ which rounds down to 1 - Instead of 2 debasing periods, there will only be 1 which causes the protocol to debase much slower than supposed to, which would keep the CF low and cause huge issues for the protocol
Impact
Synthetics will derate slower than intended, which will keep the CF low as users are not incentivized to sell them
Mitigation
Refactor the formula
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 integer division in the debase calculation rounds down, and the check for zero does not account for rounding to one when nearly two periods have passed.
Impact
Synthetics will derate slower than intended, which could keep the collateral factor low and cause issues for the protocol.
What the attacker needed
Ability to call the update function; Timing calls precisely
The fix
The formula should be refactored to avoid rounding errors, for example by using a more precise calculation or accumulating remainders.
How it was found
- Call a function that updates the block time state, such as VaultManager.getSynthScalingUpdate(), every 4320 * 2 - 1 seconds.
- The calculated ndebase equals (4320 * 2 - 1) * 20 / 86400, which rounds down to 1.
- Only one debasing period is applied instead of two, slowing the debase rate.
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 periodically reduces the value of synthetic tokens (debasing) based on how much time has passed. The code calculates how many periods to apply by dividing elapsed time by a period length, but it rounds down. An attacker can time their calls so that almost two periods' worth of time is counted as only one, making the debasing happen more slowly than intended.
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.