load_prices function returns an incomplete list of prices
The load_prices function decreases the record count even when a price lookup returns None, so the returned price list is shorter than the number of records paid for. A user therefore pays the full fee but receives fewer prices, and calculate_twap may return None.
newspacexyz Follow with 0x18a6, arturtoros and 2 others
Originally disclosed on Code4rena
Submitted by newspacexyz, also found by 0x18a6, arturtoros, ayden, and Mylifechangefast_eth
prices.rs #L219-L227
Finding description and impact
When get_price_fn returns None (retrieve_asset_price_data or load_cross_price can return None), it skips to push the price to prices.
if let Some(price) = get_price_fn(timestamp) {
prices.push_back(price);
}
But records is decreased and returns an incomplete list of prices. For example, when store prices skip one resolution, retrieve_asset_price_data returns None.
However, the user has already paid the fee for prices and gets an incomplete list of prices (fewer prices than expected, but paid for full prices vector). User has to pay more fees.
Also, calculate_twap returns None even though user has already paid fees.
Recommended mitigation steps
load_prices must not decrease records when get_price_fn returns None. Or, BeamOracleContract::prices/x_prices has to burn fee for prices.len().
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 loop decrements the records counter regardless of whether get_price_fn returned a price, so skipped prices still consume the paid quota.
Impact
A user pays the full fee but receives an incomplete price list and may get None from calculate_twap, forcing them to pay more fees.
What the attacker needed
User calls load_prices with a fee; a price lookup returns None
The fix
load_prices should not decrease records when get_price_fn returns None, or the fee should be burned only for the actual number of prices returned.
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 function is meant to return a list of prices, and the user pays a fee based on how many prices they ask for. When one price cannot be found, the code still counts it as delivered, so the user gets fewer prices than they paid for. This is a fairness bug in how fees and results are counted.
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.