Incorrect transfer size validation after time window reset can lead to rebalancing DoS
The rebalancer's transfer-size check reads a stale cached transfer record after the time window expires, so it compares the old size plus the new amount against the limit instead of just the new amount. This makes valid rebalancing transfers revert with a size-exceeded error right after a window reset, disrupting normal operations.
Source: https://github.com/sherlock-audit/2025-07-malda-judging/issues/234
Found by
0x213, 0xBlackie, 0xEkko, 0xShoonya, 0xSolus, 0xapple, 0xmechanic, 10ap17, 5am, 7, 8olidity, BADROBINX, Bizarro, Cybrid, DeveloperX, EQUATION, HeckerTrieuTien, Ivcho332, KiroBrejka, LeFy, MacroWang, PratRed, RaiseUp, Sparrow_Jac, WillyCode20, Yaneca_b, ZanyBonzy, Ziusz, axelot, coin2own, dan__vinci, davies0212, djshaneden, dreamcoder, elolpuer, elyas, farismaulana, gh0xt, har0507, harry, magbeans9, mahdifa, maxim371, onudasatoshi, oxelmiguel, oxwhite, pollersan, sheep, softdev0323, swarun, teoslaf1, v10g1, vangrim, who_is_rp, yoooo, zach223
Summary
Using stale TransferInfo in the Rebalancer::sendMsg function will cause a false Rebalancer_TransferSizeExcedeed revert for EOA rebalancers as in normal use flow, the contract checks the old transfer size even after resetting it for a new time window, leading to unexpected reverts and potential disruption of rebalancing operations.
TransferInfo memory transferInfo = currentTransferSize[_msg.dstChainId][_msg.token];
uint256 transferSizeDeadline = transferInfo.timestamp + transferTimeWindow;
if (transferSizeDeadline < block.timestamp) {
currentTransferSize[_msg.dstChainId][_msg.token] = TransferInfo(_amount, block.timestamp);
} else {
currentTransferSize[_msg.dstChainId][_msg.token].size += _amount;
}
uint256 _maxTransferSize = maxTransferSizes[_msg.dstChainId][_msg.token];
if (_maxTransferSize > 0) {
require(transferInfo.size + _amount < _maxTransferSize, Rebalancer_TransferSizeExcedeed());
//@audit if `transferSizeDeadline < block.timestamp` than `transferInfo` won't be updated but we changed `currentTransferSize` to be `TransferInfo(_amount, block.timestamp)` so we will check using the old transfer size + amount instead in this case using only amount which will lead to unexpected DoS
}
Root Cause
In Rebalancer.sol, the sendMsg function resets currentTransferSize[_msg.dstChainId][_msg.token] to TransferInfo(_amount, block.timestamp) when the time window expires, but still uses the old transferInfo.size for the max transfer size check (require(transferInfo.size + _amount < _maxTransferSize)), causing incorrect validation and potential DoS.
Internal Pre-conditions
- In normal use, an authorized rebalancer performs transfers that bring the recorded
currentTransferSizeclose to the maximum allowed for a token and destination chain within the current time window. - Once the time window expires, the next transfer resets
currentTransferSizeto the new transfer amount with an updated timestamp. - However, during this next transfer, the contract still checks the sum of the old (stale) transfer size plus the new amount against the max limit, causing an unexpected revert and blocking valid transfers.
External Pre-conditions
none
Attack Path
- An authorized rebalancer calls
sendMsgmultiple times within a singletransferTimeWindow, pushingcurrentTransferSize[_dstChainId][_token].sizeclose tomaxTransferSizes[_dstChainId][_token]. - The
transferTimeWindowexpires without further transfers, socurrentTransferSize[_dstChainId][_token]remains at a high value but stale. - On the first
sendMsgcall after the window resets, the contract resetscurrentTransferSizeto the new amount but still validates using the old (stale)transferInfo.size. - Because the validation uses the stale size, the contract rejects the transfer by reverting with
Rebalancer_TransferSizeExcedeed, even though the new window should allow it. - This causes a denial of service for rebalancing operations on that token and destination chain until the next window reset or state update.
Impact
The authorized rebalancers cannot execute valid rebalancing transfers for certain tokens and destination chains immediately after a transfer time window resets. This causes a denial of service in normal use flow, disrupting expected protocol operations without any malicious actor involved.
PoC
No response
Mitigation
No response
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/malda-protocol/malda-lending/pull/138
CergyK
Fix looks good
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 code updates the stored transfer record for a new window but validates the limit against the previously loaded, stale record instead of the freshly written value.
Impact
Authorised rebalancers cannot execute valid transfers for affected tokens and destination chains immediately after a window reset, causing a denial of service in normal use with no attacker involved.
What the attacker needed
Authorised rebalancer role; prior transfers near the limit in a window; time window must expire
The fix
The issue was fixed by the protocol team in a pull request.
How it was found
- An authorised rebalancer sends transfers within one window, bringing the recorded size close to the maximum.
- The time window expires, leaving the stored size high but stale.
- The next transfer resets the stored size to the new amount but the check still uses the old size.
- The transfer reverts with the size-exceeded error even though the new window should allow it.
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 limits how much can be moved to a destination within a rolling time window. When the window ends, the counter should start fresh, but the code still looks at the old counter when deciding whether the new transfer is too big, so a legitimate transfer gets rejected.
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.