Skip to content
Business logic Audit finding Intermediate

Stale price used when citadelPriceFlag is cleared

When an oracle price falls outside the valid range, the contract sets a flag but does not store the new price. If the policy operations team later clears the flag, the contract continues using the stale price from before the flag, allowing the team to influence pricing without oracle coordination and potentially causing incorrect asset valuations and loss of funds.

IllIllI Follow

Originally disclosed on Code4rena

Submitted by IllIllI

During the video it was explained that the policy operations team was meant to be a nimble group that could change protocol values considered to be safe. Further, it was explained that since pricing comes from an oracle, and there would have to be unusual coordination between the two to affect outcomes, the group was given the ability to clear the pricing flag to get things moving again once the price was determined to be valid

Impact

If an oracle price falls out of the valid min/max range, the citadelPriceFlag is set to true, but the out-of-bounds value is not stored. If the policy operations team calls clearCitadelPriceFlag(), the stale price from before the flag will be used. Not only is it an issue because of stale prices, but this means the policy op team now has a way to affect pricing not under the control of the oracle (i.e. no unusual coordination required to affect an outcome). Incorrect pricing leads to incorrect asset valuations, and loss of funds.

Proof of Concept

The flag is set but the price is not stored File: src/Funding.sol (lines 427-437)

        if (
            _citadelPriceInAsset < minCitadelPriceInAsset ||
            _citadelPriceInAsset > maxCitadelPriceInAsset
        ) {
            citadelPriceFlag = true;
            emit CitadelPriceFlag(
                _citadelPriceInAsset,
                minCitadelPriceInAsset,
                maxCitadelPriceInAsset
            );
        } else {

Tools Used

Code inspection

Recommended Mitigation Steps

Always set the citadelPriceInAsset

shuklaayush (BadgerDAO) confirmed and commented:

Makes sense. It’s best to update the price even when it’s flagged

jack-the-pug (judge) commented:

This is a very good catch! citadelPriceInAsset is not updated when citadelPriceFlag is set, therefore clearing the flag will not approve the out of range price but continues with a stale price before the out of range price.


The original report as published on Code4rena, by IllIllI. 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 sets a flag when the oracle price is out of bounds but does not update the stored price, so clearing the flag leaves the stale price in place.

Impact

Incorrect pricing leads to incorrect asset valuations and loss of funds, and the policy operations team gains a way to affect pricing without oracle coordination.

What the attacker needed

Policy operations team clears flag

The fix

The contract should always update the stored price, even when the flag is set.

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 bug where a price check fails but the bad price is not saved. When the flag is later cleared, the old price is still used, which can lead to wrong valuations and lost money.

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 IllIllI

View all

119 more disclosed reports, best first.

More from Badger Citadel 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.