Skip to content
DoS Audit finding Intermediate

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.

0x213 Follow with 0xBlackie, 0xEkko and 47 others

Originally disclosed on Sherlock

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.

Solidity
       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.

https://github.com/sherlock-audit/2025-07-malda/blob/main/malda-lending/src/rebalancer/Rebalancer.sol#L141-L152

Internal Pre-conditions

  1. In normal use, an authorized rebalancer performs transfers that bring the recorded currentTransferSize close to the maximum allowed for a token and destination chain within the current time window.
  2. Once the time window expires, the next transfer resets currentTransferSize to the new transfer amount with an updated timestamp.
  3. 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

  1. An authorized rebalancer calls sendMsg multiple times within a single transferTimeWindow, pushing currentTransferSize[_dstChainId][_token].size close to maxTransferSizes[_dstChainId][_token].
  2. The transferTimeWindow expires without further transfers, so currentTransferSize[_dstChainId][_token] remains at a high value but stale.
  3. On the first sendMsg call after the window resets, the contract resets currentTransferSize to the new amount but still validates using the old (stale) transferInfo.size.
  4. 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.
  5. 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

The original report as published on Sherlock, by 0x213. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

  1. An authorised rebalancer sends transfers within one window, bringing the recorded size close to the maximum.
  2. The time window expires, leaving the stored size high but stale.
  3. The next transfer resets the stored size to the new amount but the check still uses the old size.
  4. 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.

More from Malda

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.