Incorrectly handled subtraction leads to underflow resulting in permanent user fund lock and DOS
A precision loss in deposit claim calculations causes the total pending deposit to be less than the sum of individual user pending amounts. When users cancel, a subtraction underflows, reverting the transaction and permanently locking the last users' funds.
Bobai23 Follow with BoyD, HeckerTrieuTien and 10 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-10-centrifuge-protocol-v3-1-audit-judging/issues/187
Found by
Bobai23, BoyD, HeckerTrieuTien, TessKimy, anonymousjoe, blockace, ezsia, fullstop, hassan-truscova, jongwon, namaila, silver_eth, x15
Summary
When notifyDeposit() is called, if the user has a cancellation queued the code reaches the following line:
pendingTotal = isIncrement ? pendingTotal + amount : pendingTotal - amount;
Here the code assumes that pendingTotal >= amount if isIncrement = false. This assumption is broken in a case which leads to pendingTotal underflowing and thus the txn reverting. Which means that the user can never call the notifyDeposit() function. And the user's deposited funds will be forever locked in the contract without ever getting the shares or being refunded.
The particular case is when the following condition doesnt hold arising from a precision loss : PendingDeposit[poolId][scId][assetId] < Σ(userOrder.pending). More regarding this is described below.
Root Cause
- In the approveDeposits() function, the
pendingDeposit[][][]is subtracted by theapprovedAssetAmount.
// Reduce pending
pendingDeposit[poolId][scId_][depositAssetId] -= approvedAssetAmount;
https://github.com/sherlock-audit/2025-10-centrifuge-protocol-v3-1-audit/blob/main/protocol/src/vaults/BatchRequestManager.sol#L229-L230
2. In the _claimDeposit(), paymentAssetAmount is calculated. This calculation however can have a precision loss leading to a lower than correct value (Note: this precision loss is for the paymentAssetAmount and not for the payoutShareAmount which is addressed in the comments). Due to this precision loss, the summation of all the paymentAssetAmount of each user will be less than the approvedAssetAmount which was deducted in step 1.(this smaller than actual paymentAssetAmount will be deducted from the individual user's pending)
paymentAssetAmount = epochAmounts.approvedAssetAmount == 0
? 0
: userOrder.pending.mulDiv(epochAmounts.approvedAssetAmount, epochAmounts.pendingAssetAmount).toUint128(); // <= Precision loss
// NOTE: Due to precision loss, the sum of claimable user amounts is leq than the amount of minted share class
// tokens corresponding to the approved share amount (instead of equality). I.e., it is possible for an epoch to
// have an excess of a share class tokens which cannot be claimed by anyone.
if (paymentAssetAmount > 0) {
payoutShareAmount = epochAmounts.pricePoolPerShare.isNotZero()
? PricingLib.assetToShareAmount(
paymentAssetAmount,
hubRegistry.decimals(depositAssetId),
hubRegistry.decimals(poolId),
epochAmounts.pricePoolPerAsset,
epochAmounts.pricePoolPerShare,
MathLib.Rounding.Down
)
: 0;
userOrder.pending -= paymentAssetAmount; // <= Being subtracted from each user
https://github.com/sherlock-audit/2025-10-centrifuge-protocol-v3-1-audit/blob/main/protocol/src/vaults/BatchRequestManager.sol#L511-L530
3. Which means that, in the next epoch, the PendingDeposit[][][] will be less than the summation of the userOrder.pending of all the users.i.e: 'PendingDeposit[poolId][scId][assetId] < Σ(userOrder.pending)`
4. So, if all users cancel their deposit orders, the users at the ends will face an arithmetic underflow when the subtraction is tried. Which will lead to their funds being stuck in the contract
pendingTotal = isIncrement ? pendingTotal + amount : pendingTotal - amount; // <= subtraction tried due to queued cancellation
Internal Pre-conditions
Last user(/few users) try to cancel their requests.
External Pre-conditions
None.
Attack Path
There is no attack path per say, this occurs during normal working of the protocol.
- Alice deposits 4 tokens into the vault
- Bob deposits 5 tokens into the vault
- Pool Manager approves 4 tokens
- Alice and Bob queue their cancellations
- Alice claims her shares by calling notifyDeposit(), which leads to her queued cancel also executing
- Bob calls the notifyDeposit() but it reverts due to arithmetic underflow.
Basically 4 is subtracted from the pendingDeposits during approval by manager But Alice gets (4 * 4) /9 = 1 and Bob gets (4 * 5) /9 = 2 meaning alice + bob = 3, while 4 was deducted from the total pendingDeposits. This mismatch will cause an issue during cancellation.
Impact
Permanent lock of funds for the last few users (depends on the precision loss which grows over time).
PoC
Add the following test case in protocol\test\vaults\unit\BatchRequestManager.t.sol\BatchRequestManager.t.sol
(Note that the test will fail due to arithmetic underflow)
Also import the console library (or remove the console.log lines)
import {console} from "forge-std/console.sol";
POC:
function test_underflow_POC() public {
bytes32 investor1 = bytes32("investor1");
bytes32 investor2 = bytes32("investor2");
uint128 depositAmount1 = 4;
uint128 depositAmount2 = 5;
uint128 approvedAmount1 = 4;
uint128 approvedAmount2 = 5;
D18 pricePoolPerShare = d18(uint128(bound(500, 1e14, type(uint128).max / 1e18)));
// investor1 deposits 4 tokens, investor2 deposits 5 tokens
batchRequestManager.requestDeposit(poolId, scId, depositAmount1, investor1, USDC);
batchRequestManager.requestDeposit(poolId, scId, depositAmount2, investor2, USDC);
(uint128 pending, uint32 timestamp) = batchRequestManager.depositRequest(poolId,scId,USDC,investor1);
console.log("Investor1's user.pending is :", pending);
console.log("Investor1's user.timestamp is :", timestamp);
(pending,timestamp) = batchRequestManager.depositRequest(poolId,scId,USDC,investor2);
console.log("Investor2's user.pending is :", pending);
console.log("Investor2's user.timestamp is :", timestamp);
console.log("Total pending right now is :", batchRequestManager.pendingDeposit(poolId,scId,USDC));
console.log("Current deposit timestamp is :", _nowDeposit(USDC));
// pool manager approves 4 tokens and issues shares
vm.startPrank(MANAGER);
batchRequestManager.approveDeposits{
value: COST
}(poolId, scId, USDC, _nowDeposit(USDC), approvedAmount1, _pricePoolPerAsset(USDC), REFUND);
batchRequestManager.issueShares{
value: COST
}(poolId, scId, USDC, _nowIssue(USDC), pricePoolPerShare, SHARE_HOOK_GAS, REFUND);
vm.stopPrank();
console.log("Total pending right now is :", batchRequestManager.pendingDeposit(poolId,scId,USDC));
console.log("Current deposit timestamp is :", _nowDeposit(USDC));
// investor1 and investor2 queue their cancellations for the remaining amount
batchRequestManager.cancelDepositRequest(poolId, scId, investor1, USDC);
batchRequestManager.cancelDepositRequest(poolId, scId, investor2, USDC);
(bool ans,) = batchRequestManager.queuedDepositRequest(poolId,scId,USDC,investor1);
console.log("Investor1 is cancelling :", ans);
(ans,) = batchRequestManager.queuedDepositRequest(poolId,scId,USDC,investor2);
console.log("Investor1 is cancelling :", ans);
// investor1 and investor2 try claim their shares by calling notifyDeposit()
batchRequestManager.notifyDeposit{value: COST}(poolId, scId, USDC, bytes32("investor1"), 10, REFUND);
console.log("Total pending right now(after investor 1 claims) is :", batchRequestManager.pendingDeposit(poolId,scId,USDC));
(pending,timestamp) = batchRequestManager.depositRequest(poolId,scId,USDC,investor2);
console.log("Investor2's user.pending is :", pending);
batchRequestManager.notifyDeposit{value: COST}(poolId, scId, USDC, bytes32("investor2"), 10, REFUND);
}
For better understanding of where exactly it fails add the following code snippets to BatchRequestManager.sol:
- Update
_updatePendingDepositas follows:
uint128 pendingTotal = pendingDeposit[poolId][scId_][assetId];
console.log("Reached here"); // <= added line
pendingTotal = isIncrement ? pendingTotal + amount : pendingTotal - amount;
console.log("Reached here 2"); // added line
pendingDeposit[poolId][scId_][assetId] = pendingTotal;
- Add import as follows:
import {console} from "forge-std/console.sol";
Mitigation
Update the _updatePendingDeposit function as follows to handle the underflow.
if(isIncrement == false && amount > pendingTotal)
amount = pendingTotal;
pendingTotal = isIncrement ? pendingTotal + amount : pendingTotal - amount;
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/centrifuge/protocol-internal/pull/31
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 a precision loss in the payment asset amount calculation during deposit claims causes the sum of individual pending amounts to exceed the total pending deposit, leading to an underflow when subtracting during cancellation.
Impact
Permanent lock of funds for the last few users, with the severity depending on the precision loss which grows over time.
What the attacker needed
Multiple users deposit; pool manager approves partial amount; users cancel deposits
The fix
The protocol team fixed this issue in a pull request.
How it was found
- Alice deposits 4 tokens into the vault
- Bob deposits 5 tokens into the vault
- Pool Manager approves 4 tokens
- Alice and Bob queue their cancellations
- Alice claims her shares by calling notifyDeposit(), which leads to her queued cancel also executing
- Bob calls the notifyDeposit() but it reverts due to arithmetic underflow.
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.
When users deposit money, the system tracks how much each person has pending. Due to rounding errors, the total tracked by the system can become smaller than the sum of individual user amounts. If users then try to cancel, the system tries to subtract more than it has, which fails and locks the funds.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.