Skip to content
Business logic Audit finding Intermediate

Updating rate limit for addresses restores their entire buffer amount

When the buffer cap for an address is updated, the address's stored buffer is reset to the full new cap, allowing the address to spend its entire buffer again. An attacker could front-run the update to spend their buffer, then have it replenished and spend it a second time.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel

MultiRateLimited.sol#L280

When the bufferCap is updated for an address in _updateAddress, the address’s allowed buffer (bufferStored) is replenished to the entire bufferCap.

The address could frontrun the updateAddress call and spend their entire buffer, then the buffer is replenished and they can spend their entire buffer a second time.

Recommended Mitigation Steps

Keep the old buffer value, capped by the new bufferCap:

+ uint256 newBuffer = individualBuffer(rateLimitedAddress);

  rateLimitData.lastBufferUsedTime = block.timestamp.toUint32();
  rateLimitData.bufferCap = _bufferCap;
  rateLimitData.rateLimitPerSecond = _rateLimitPerSecond;
- rateLimitData.bufferStored = _bufferCap;
+ rateLimitData.bufferStored = min(_bufferCap, newBuffer);

ElliotFriedman (Volt) confirmed and commented:

Good catch!


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

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 update function sets the stored buffer directly to the new cap instead of preserving the existing buffer amount capped by the new limit.

What the attacker needed

Ability to front-run the update transaction

The fix

The buffer should be set to the minimum of the new cap and the existing buffer, rather than resetting to the new cap.

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 limit controls how much of something (like tokens) an address can use over time. The contract stores a 'buffer' that refills gradually. When the limit is changed, the code mistakenly refills the buffer to the maximum immediately, so someone can use their full allowance twice by timing the change.

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 by cmichel

View all

196 more disclosed reports, best first.

More from Volt Protocol contest

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.