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.
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!
citadelPriceInAssetis not updated whencitadelPriceFlagis 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.
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.