Utilization rate multiplier will not shift if oracle is consulted frequently
A rounding error in the VaultAdapter's multiplier calculation causes the utilization rate multiplier to not shift if the oracle is consulted frequently. An attacker can call the oracle often to prevent the multiplier from increasing or decreasing, affecting interest rate calculations.
Matin Follow with kangaroo, montecristo and 1 other
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-07-cap-judging/issues/148
Found by
Matin, kangaroo, montecristo, valuevalk
Summary
Due to round down issue in VaultAdapter's multiplier shift calculation, utilization rate will not increase/decrease if oracle is consulted frequently.
Root Cause
Root cause resides in multiplier calculation in VaultAdapter.sol:
File: cap-contracts/contracts/oracle/libraries/VaultAdapter.sol
86: if (_utilization > slopes.kink) {
87: uint256 excess = _utilization - slopes.kink;
88:@> utilizationData.multiplier = utilizationData.multiplier
89: * (1e27 + (1e27 * excess / (1e27 - slopes.kink)) * (_elapsed * $.rate / 1e27)) / 1e27;
90:
91: if (utilizationData.multiplier > $.maxMultiplier) {
92: utilizationData.multiplier = $.maxMultiplier;
93: }
94:
95: interestRate = (slopes.slope0 + (slopes.slope1 * excess / 1e27)) * utilizationData.multiplier / 1e27;
96: } else {
97:@> utilizationData.multiplier = utilizationData.multiplier * 1e27
98: / (1e27 + (1e27 * (slopes.kink - _utilization) / slopes.kink) * (_elapsed * $.rate / 1e27));
99:
100: if (utilizationData.multiplier < $.minMultiplier) {
101: utilizationData.multiplier = $.minMultiplier;
102: }
103:
104: interestRate = (slopes.slope0 * _utilization / slopes.kink) * utilizationData.multiplier / 1e27;
105: }
More specifically, rounding issue happens in the following calculation:
(_elapsed * $.rate / 1e27)
_elapsed is diff between block.timestamp and utilizationData.lastUpdate. This means one can consult rate oracle frequently to make this term 0.
As a result, utilizationData.multiplier will not shift in L88 and L97.
Internal Pre-conditions
n/a
External Pre-conditions
n/a
Attack Path
Attacker calls Oracle::utilizationRate function frequently.
The interval depends on rate parameter of VaultAdapter contract.
For example, if the rate is set so that multiplier is shifted fully in 24 hours window, the attacker can consult the oracle every 23 hours to prevent multiplier shifts.
Impact
DebtToken's interest rate calculation will be affected. The attacker can prevent it from increasing during high LTV, or vice versa during low LTV.
PoC
pragma solidity ^0.8.28;
import { IOracle } from "../contracts/interfaces/IOracle.sol";
import { IVaultAdapter } from "../contracts/interfaces/IVaultAdapter.sol";
import { VaultAdapter } from "../contracts/oracle/libraries/VaultAdapter.sol";
import { TestDeployer } from "./deploy/TestDeployer.sol";
import { console } from "forge-std/console.sol";
contract POC is TestDeployer {
VaultAdapter adapter;
address user_agent;
function setUp() public {
_deployCapTestEnvironment();
_initTestVaultLiquidity(usdVault);
_initSymbioticVaultsLiquidity(env);
user_agent = _getRandomAgent();
vm.startPrank(env.symbiotic.users.vault_admin);
_symbioticVaultDelegateToAgent(symbioticWethVault, env.symbiotic.networkAdapter, user_agent, 2.385e18);
vm.stopPrank();
vm.startPrank(env.users.lender_admin);
uint256 reservesCount = lender.reservesCount();
console.log("Reserves Count", reservesCount);
vm.stopPrank();
// setup vault adapter
vm.startPrank(env.users.access_control_admin);
VaultAdapter adapterImpl = new VaultAdapter();
adapter = VaultAdapter(_proxy(address(adapterImpl)));
adapter.initialize(address(accessControl));
accessControl.grantAccess(adapter.setSlopes.selector, address(adapter), env.users.access_control_admin);
accessControl.grantAccess(adapter.setLimits.selector, address(adapter), env.users.access_control_admin);
adapter.setSlopes(address(usdc), IVaultAdapter.SlopeData({ kink: 2e26, slope0: 0.01e27, slope1: 0.03e27 }));
adapter.setLimits({
_maxMultiplier: 1e27, // 100%
_minMultiplier: 1e25, // 1%
_rate: uint(1e27) / 1 days // 100% / day
});
vm.stopPrank();
}
function test_submissionValidity() public {
vm.startPrank(user_agent);
// utilization rate is set below than the kink ratio
lender.borrow(address(usdc), 100e6, user_agent);
assertLt(cUSD.utilization(address(usdc)), 2e26);
adapter.rate(env.usdVault.capToken, address(usdc));
// utilization rate is set above than the kink ratio
lender.borrow(address(usdc), 2600e6, user_agent);
assertGt(cUSD.utilization(address(usdc)), 2e26);
// due to rounding issue, utilization rate will not grow because multiplier is not shifted
_timeTravel(1 days / 2);
uint256 utilizationRateFirst = adapter.rate(env.usdVault.capToken, address(usdc));
_timeTravel(1 days / 2);
uint256 utilizationRateSecond = adapter.rate(env.usdVault.capToken, address(usdc));
assertEq(utilizationRateFirst, utilizationRateSecond);
// rounding issue happens for 1 day as well, so we need to advance 1 second further
_timeTravel(1 days + 1);
// now the utilization rate is increased
uint256 utilizationRateThird = adapter.rate(env.usdVault.capToken, address(usdc));
assertGt(utilizationRateThird, utilizationRateSecond);
}
}
Mitigation
diff --git a/cap-contracts/contracts/oracle/libraries/VaultAdapter.sol b/cap-contracts/contracts/oracle/libraries/VaultAdapter.sol
index 0fff0f0..7bdf86b 100644
--- a/cap-contracts/contracts/oracle/libraries/VaultAdapter.sol
+++ b/cap-contracts/contracts/oracle/libraries/VaultAdapter.sol
@@ -86,7 +86,7 @@ contract VaultAdapter is IVaultAdapter, UUPSUpgradeable, Access, VaultAdapterSto
if (_utilization > slopes.kink) {
uint256 excess = _utilization - slopes.kink;
utilizationData.multiplier = utilizationData.multiplier
- * (1e27 + (1e27 * excess / (1e27 - slopes.kink)) * (_elapsed * $.rate / 1e27)) / 1e27;
+ * (1e27 + (1e27 * excess / (1e27 - slopes.kink)) * _elapsed * $.rate / 1e27) / 1e27;
if (utilizationData.multiplier > $.maxMultiplier) {
utilizationData.multiplier = $.maxMultiplier;
@@ -95,7 +95,7 @@ contract VaultAdapter is IVaultAdapter, UUPSUpgradeable, Access, VaultAdapterSto
interestRate = (slopes.slope0 + (slopes.slope1 * excess / 1e27)) * utilizationData.multiplier / 1e27;
} else {
utilizationData.multiplier = utilizationData.multiplier * 1e27
- / (1e27 + (1e27 * (slopes.kink - _utilization) / slopes.kink) * (_elapsed * $.rate / 1e27));
+ / (1e27 + (1e27 * (slopes.kink - _utilization) / slopes.kink) * _elapsed * $.rate / 1e27);
if (utilizationData.multiplier < $.minMultiplier) {
utilizationData.multiplier = $.minMultiplier;
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/cap-labs-dev/cap-contracts/pull/187
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
Impact
The attacker can prevent the interest rate multiplier from increasing during high utilization or decreasing during low utilization, affecting DebtToken's interest rate calculation.
What the attacker needed
Attacker can call the oracle; rate parameter set such that multiplier shifts over time
The fix
The issue was fixed by changing the order of operations to multiply before dividing, avoiding rounding down to zero.
How it was found
- Set up the VaultAdapter with a rate parameter such that the multiplier would shift fully in a certain window (e.g., 24 hours).
- Borrow to set utilization above the kink.
- Advance time by half the window and call the rate function.
- Advance time by another half and call the rate function again; observe the utilization rate is unchanged.
- Advance time by the full window plus one second and call the rate function; observe the utilization rate increases.
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.
Smart contracts often use fixed-point arithmetic with scaling factors like 1e27 to represent decimals. When dividing before multiplying, small values can round down to zero, losing precision. Here, if the time since last update is small, a division makes the time factor zero, so the multiplier never changes.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.