Possible Wrong bAsset Rewards/Borrow limits Calculation
The contract's reward and borrow limit calculations rely on configuration values that are updated without recalculating the epoch operations, leaving stale data. An attacker could potentially exploit this to obtain incorrect rewards or borrow limits.
Submitted by defsec
During the code review, It has been observed that reward calculation has been done with execute_epoch_operations function. However, the config are stored in the storage. When the anc_purchase_factor is updated by the owner, the execute_epoch_operations is not called.
Proof of Concept
- Navigate to the following contract.
https:
- Config is updated with update_config function.
if let Some(threshold_deposit_rate) = threshold_deposit_rate {
config.threshold_deposit_rate = threshold_deposit_rate;
}
if let Some(buffer_distribution_factor) = buffer_distribution_factor {
config.buffer_distribution_factor = buffer_distribution_factor;
}
if let Some(anc_purchase_factor) = anc_purchase_factor {
config.anc_purchase_factor = anc_purchase_factor;
}
if let Some(target_deposit_rate) = target_deposit_rate {
config.target_deposit_rate = target_deposit_rate;
}
if let Some(epoch_period) = epoch_period {
config.epoch_period = epoch_period;
}
if let Some(price_timeframe) = price_timeframe {
config.price_timeframe = price_timeframe;
}
- After the update, execute_epoch_operations function is not called. That will cause to out-of-date data.
Recommended Mitigation Steps
Consider calling execute_epoch_operations function after config update.
Alex the Entreprenerd (triage) commented:
Confirmed Lack of validation.
Albert Chon (judge) commented:
Good catch.
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 update_config function does not trigger a recalculation of epoch-dependent values, so the stored configuration and the computed state become inconsistent.
Impact
The stale data could lead to incorrect reward or borrow limit calculations, potentially allowing users to receive more rewards or borrow more than intended.
What the attacker needed
Owner updates config
The fix
The execute_epoch_operations function should be called after updating the configuration.
How it was found
- Navigate to the contract.
- Update the configuration using the update_config function.
- Observe that execute_epoch_operations is not called afterwards.
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 changing settings doesn't immediately update the calculations that depend on them. So the system keeps using old numbers until the next scheduled update, which could give someone wrong rewards or borrowing limits.
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.