Double subtraction of cash_reserve in deposit_limit_breached allows bypassing the maximum deposit limit
The deposit limit check subtracts the protocol's cash reserve twice, so the calculated pool size is smaller than the real user deposits. An attacker could deposit more than the configured maximum, bypassing the cap by roughly the accumulated reserve amount.
0x04 Follow with 0xGreed, 0xTheBlackPanther and 47 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2026-03-current-finance-judging/issues/8
Found by
0x04, 0xGreed, 0xTheBlackPanther, 0xepley, 0xgh0st, 0xiehnnkta, 0xkmr_, 0xzen, 1337, 1nc0gn170, 6PottedL, 8olidity, A_Failures_True_Power, AbSattar, Afriaudit, Alpha, BADROBINX, Baazigar, Daian0s, Demonhatz, Diavolo, I1iveF0rTh1Sh1t, Icarus, K42, OhmOudits, Orionn, OxRai, Polaris_2, RV, Razkky, Ridden5839, Rolando, SUPERMAN_I4G, Saurabh_Singh, Siddhu, Stepanko93, Synthrax, Xmanuel, ZeroTrust, ah_mo54, atilla0283, b0rd3aux, basia, bratwork, calc1f4r, coinsspor, denys_sosnovskyi, duan, fgh56ty, flora2627, gh0xt, giraffe, hyuunn, ibrahimatix0x01, jayjoshix, jolyon, joshuam33, kimonic, klaus, kudaliar, marchev, odinshell, rubencrxz, sahuang, shaflow01, shiazinho, sonanh08t4, th3hybrid, toprince, unineko, xiaoming90, y4y, yaractf, youcef330, zeroDayHunter, zubyoz
Summary
The double subtraction of cash_reserve in the deposit limit calculation will cause a bypass of the maximum deposit limit for the protocol as malicious whales or regular users will deposit funds significantly exceeding the intended cap.
Root Cause
In https://github.com/sherlock-audit/2026-03-currentsui-contest-march-2026/blob/main/sui-move-contract/contracts/protocol/sources/internal/market/reserve.move#L87-L90 inside the deposit_limit_breached function, the double subtraction of cash_reserve is a mistake. The function is written as:
public(package) fun deposit_limit_breached<MarketType>(self: &Reserve<MarketType>, increment: u64, limit: u64): bool { let total_deposit_plus_interest = self.total_deposit_plus_interest(); total_deposit_plus_interest.ceil() + increment - self.cash_reserve.ceil() > limit }
The variable total_deposit_plus_interest is calculated as exchange_rate() * total_supply. Expanding exchange_rate() gives (cash + debt - cash_reserve) / total_supply. Thus, total_deposit_plus_interest is exactly cash + debt - cash_reserve. By subtracting self.cash_reserve.ceil() again in the return statement, the protocol evaluates: (cash + debt - cash_reserve) + increment - cash_reserve > limit. This artificially deflates the calculated deposit size by - cash_reserve, allowing limits to be bypassed.
Internal Pre-conditions
- Protocol needs to accrue interest over time to set cash_reserve to be at least a significant amount (e.g., accumulated protocol fees).
- Users need to deposit funds to set the total pool size to be close to the limit.
External Pre-conditions
None
Attack Path
- The lending market operates normally, and borrowers pay interest, which increases the protocol's cash_reserve.
- A user attempts to deposit an increment that would push the real total user deposits (cash + debt - cash_reserve) over the configured limit.
- The deposit_limit_breached function is called to validate the transaction.
- Because the function incorrectly subtracts cash_reserve twice, the evaluated pool size is much smaller than the actual user deposits.
- The check returns false, and the protocol accepts the deposit, breaking the max_deposit_amount invariant.
Impact
The protocol suffers an approximate loss of risk management integrity. The users can bypass the maximum deposit cap by an amount equal to the accumulated cash_reserve. As the protocol grows and collects more fees, the deposit limit becomes entirely ineffective, exposing the protocol to higher systemic risks (e.g., unlimited minting of cTokens for a specific asset).
PoC
The vulnerability can be proven through a direct mathematical expansion of the contract's functions. No complex state setup is required, as the flaw lies in the algebraic evaluation of the core accounting logic.
Step 1: Expansion of total_deposit_plus_interest()
Plaintext total_deposit_plus_interest = exchange_rate * total_supply
Step 2: Expansion of exchange_rate()
Plaintext exchange_rate = cash_plus_borrows_minus_reserves / total_supply Therefore:
Plaintext total_deposit_plus_interest = (cash_plus_borrows_minus_reserves / total_supply) * total_supply total_deposit_plus_interest = cash_plus_borrows_minus_reserves
Step 3: Expansion of cash_plus_borrows_minus_reserves()
Plaintext cash_plus_borrows_minus_reserves = cash + debt - cash_reserve (Notice that cash_reserve has already been properly deducted to isolate the users' portion of the pool).
Step 4: The Flawed Check in deposit_limit_breached
Plaintext Condition: total_deposit_plus_interest + increment - cash_reserve > limit Substitute Step 3 into the Condition: (cash + debt - cash_reserve) + increment - cash_reserve > limit cash + debt + increment - 2 * cash_reserve > limit
Scenario:
- cash = 100,000
- debt = 20,000
- cash_reserve = 10,000 (Protocol fees accrued over time)
- limit = 111,000
- increment (New deposit) = 5,000
Real user deposits after increment: (100,000 + 20,000 - 10,000) + 5,000 = 115,000. Since 115,000 > 111,000, the transaction should revert.
However, the contract evaluates: 110,000 + 5,000 - 10,000 > 111,000 => 105,000 > 111,000 => FALSE. The deposit limit is successfully bypassed by exactly the amount of cash_reserve.
Mitigation
Remove the redundant subtraction of cash_reserve from the deposit_limit_breached function, as total_deposit_plus_interest() already represents the pure user-owned value.
public(package) fun deposit_limit_breached<MarketType>(self: &Reserve<MarketType>, increment: u64, limit: u64): bool { let total_deposit_plus_interest = self.total_deposit_plus_interest(); total_deposit_plus_interest.ceil() + increment > limit }
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 deposit_limit_breached function subtracts cash_reserve a second time even though total_deposit_plus_interest already excludes it.
Impact
The maximum deposit cap can be bypassed by an amount equal to the accumulated cash_reserve, which could expose the protocol to higher systemic risks such as unlimited minting of cTokens for a specific asset.
What the attacker needed
Protocol accrues interest to build cash_reserve; Pool size close to the deposit limit
The fix
Remove the redundant subtraction of cash_reserve from the deposit_limit_breached function.
How it was found
- The lending market operates normally and borrowers pay interest, increasing cash_reserve.
- A user attempts to deposit an amount that would push real user deposits over the configured limit.
- The deposit_limit_breached function is called to validate the transaction.
- Because cash_reserve is subtracted twice, the evaluated pool size is much smaller than actual user deposits.
- The check returns false and the deposit is accepted, breaking the max_deposit_amount invariant.
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 lending pool has a rule that total deposits must not exceed a set limit. The code that checks this limit accidentally subtracts the protocol's own saved fees twice, making the pool look smaller than it really is. As a result, someone can add more money than the limit allows without the check stopping them.
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.