Skip to content
Business logic Audit finding Intermediate

Cross-segment limiter netting failure lets attackers grief daily borrow and withdraw caps

The rate limiter records outflow in per-segment buckets but only reduces usage in the current segment, so a repayment made after a segment boundary leaves the earlier segment charged. An attacker can borrow or withdraw near the end of a segment and repay immediately after the next segment starts, keeping the daily cap exhausted for the rest of the cycle.

0xAether Follow with 0xc0ffEE, 0xca1x and 29 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2026-03-current-finance-judging/issues/3

Found by

0xAether, 0xc0ffEE, 0xca1x, 0xkmr_, 1337, 6PottedL, Bozwkd, CertiK_sec, ChainNerd27, Daian0s, Demonhatz, HiteshRajpurohit, JohnWeb3, OhmOudits, RV, Rareone, RoushanGoswami, TOSHI, Wojack, Ziusz, arifulone, atilla0283, bratwork, giraffe, gwumex, hy, ibrahimatix0x01, invariantex, kkkkkk, maigadoh, odinshell, victoryg0d

Brief/Intro

The limiter is documented and used as a rolling net-outflow control, but repayments and redeposits only reduce usage inside the current segment. If an attacker borrows or withdraws near the end of one segment and unwinds immediately after the next segment starts, the old segment stays fully charged for the rest of the cycle. This lets temporary exposure keep daily borrow or withdraw caps artificially exhausted.

Vulnerability Details

Finding description and impact

The limiter stores usage in per-segment buckets. Adding outflow works by charging the current segment:

MOVE
let curr_outflow = limiter.count_current_outflow(now);
assert!(curr_outflow + value <= limiter.outflow_limit, error::outflow_reach_limit_error());
...
segment.value = segment.value + value;

However, reducing outflow only touches the current segment:

MOVE
if (segment.value <= reduced_value) {
    segment.value = 0;
} else {
    segment.value = segment.value - reduced_value;
}

And total usage is computed by summing all still-live segments in the rolling window:

MOVE
if ((len > timestamp_index) || (segment.index >= (timestamp_index - len + 1))) {
    curr_outflow = curr_outflow + segment.value;
}

Affected code:

  • contracts/protocol/sources/internal/market/limiter.move:78-94
  • contracts/protocol/sources/internal/market/limiter.move:100-118
  • contracts/protocol/sources/internal/market/limiter.move:154-170

This means the limiter only nets inflow against the same segment that originally recorded the outflow. If repayment or redeposit happens after the segment rolls over, the earlier segment remains charged until it naturally ages out. The protocol therefore enforces a gross historical outflow approximation rather than the intended rolling net outflow.

Impact Details

An attacker can saturate a daily borrow or withdraw cap with only temporary exposure. The attack is:

  • take a large borrow or withdraw shortly before a segment boundary,
  • wait for the next segment to begin,
  • repay or redeposit immediately,
  • leave the previous segment's usage pinned for the rest of the rolling cycle.

This creates an attacker-triggerable availability issue:

  • legitimate users can be blocked from borrowing,
  • legitimate users can be blocked from withdrawing,
  • the attacker does not need to keep capital at risk for the rest of the cycle.

The bug is especially impactful because the protocol's public materials describe daily caps as the net amount leaving the system. The implementation instead preserves stale usage across segment boundaries even after the net exposure returns to zero.

Recommended mitigation steps

The limiter needs to net inflows against the segment that originally recorded the outflow, not blindly against the current segment.

There are two practical fixes:

  1. Track outflow with timestamps or a queue of segment contributions so later repayments can unwind the oldest still-live outflow first.

This preserves rolling-window semantics and matches the "net outflow" intent.

  1. Replace the segmented approximation with a data structure that directly represents signed rolling flow over the configured horizon.

This is more invasive but avoids this entire class of cross-segment accounting drift.

The current approach should not be relied on as a netting mechanism:

MOVE
// only reduces the current segment
limiter.reduce_outflow(now, reduced_value);

because the original outflow may have been recorded in a different live segment.

Regression test direction:

  • configure a limiter with multiple segments,
  • add outflow near the end of segment N,
  • reduce the same amount in segment N + 1,
  • assert that total usage returns to zero.

PoC

This PoC is a deterministic numerical reproduction of the limiter state machine.

PoC intent and expected result

Prerequisites:

  • outflow_limit = 1000,
  • outflow_cycle_duration = 24h,
  • outflow_segment_duration = 1h.

Success criteria:

  • after a full borrow+repay pair, usage should return to 0 if the protocol truly tracks net outflow,
  • the current implementation instead leaves usage at 1000 when the repay crosses a segment boundary.

Reproduction Package (Commands + Full PoC Files)

Step 1: Charge the last seconds of one segment

Command(s)

Text
1. At t = 3599, call `add_outflow(3599, 1000)`.

Expected output:

Text
Current usage becomes 1000.

Actual output:

Text
Current usage becomes 1000.

Expected interpretation: This is the baseline charge.

Why this step matters: It records the full limit inside segment 0.

Step 2: Repay in the next segment

Command(s)

Text
2. At t = 3601, call `reduce_outflow(3601, 1000)`.
3. Query `current_usage(3601)`.

Expected output:

Text
Usage should return to 0 because the outflow has been fully unwound and net exposure is zero.

Actual output:

Text
Usage remains 1000 because `reduce_outflow` only mutates segment 1, while segment 0 still holds the original charge.

Expected interpretation: This proves the limiter fails to net a cross-segment unwind.

Why this step matters: This is the griefing condition that keeps the daily cap saturated.

Step 3: Negative control

Command(s)

Text
4. Repeat the scenario, but call `reduce_outflow` before the segment rolls over.

Expected output:

Text
Usage should return to 0.

Actual output:

Text
Usage does return to 0 when add and reduce happen in the same segment.

Expected interpretation: The bug is specifically the cross-segment unwind path, not the same-segment path.

Links to Root Cause: https://github.com/sherlock-audit/2026-03-currentsui-contest-march-2026/blob/main/sui-move-contract/contracts/protocol/sources/internal/market/limiter.move#L78-L94,

https://github.com/sherlock-audit/2026-03-currentsui-contest-march-2026/blob/main/sui-move-contract/contracts/protocol/sources/internal/market/limiter.move#L100-L118,

https://github.com/sherlock-audit/2026-03-currentsui-contest-march-2026/blob/main/sui-move-contract/contracts/protocol/sources/internal/market/limiter.move#L154-L170

The original report as published on Sherlock, by 0xAether. 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

Likely the limiter nets inflows only against the current segment rather than the segment that recorded the original outflow, so cross-segment repayments do not reduce total usage.

Impact

An attacker could keep daily borrow or withdraw caps saturated with only temporary exposure, potentially blocking legitimate users from borrowing or withdrawing for the rest of the cycle.

What the attacker needed

Ability to borrow or withdraw near a segment boundary; sufficient capital to reach the cap temporarily; repay or redeposit after the next segment starts

The fix

The limiter should net inflows against the segment that originally recorded the outflow, for example by tracking outflow contributions with timestamps or using a signed rolling-flow structure.

How it was found

  1. Configure a limiter with a 24-hour cycle split into 1-hour segments and an outflow limit of 1000.
  2. At the last second of a segment, add an outflow of 1000, which charges that segment fully.
  3. After the next segment begins, reduce the outflow by 1000 and query current usage.
  4. Observe that usage remains 1000 because the reduction only touched the new segment.
  5. Repeat the same add and reduce within one segment to confirm usage returns to zero.

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 rate limiter is meant to cap how much can leave the system in a day. This one splits the day into small time buckets and only subtracts repayments from the bucket you are currently in. If you borrow just before a bucket ends and repay just after the next one starts, the old bucket still shows the full amount, so the daily cap looks used up even though you have already paid back.

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.

More from Current Finance

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.