Accelerated Rate Limit Refill via Block Timestamp Control
The rate limiter contract refills capacity based on the difference between the current block timestamp and the last update time. An attacker who is a block proposer can set the block timestamp up to 25 seconds ahead, causing the rate limit to refill faster than intended, potentially allowing them to bypass the limit.
- Disclosed after under an hour
#48804 [SC-Insight] Accelerated Rate Limit Refill via Block Timestamp Control
Submitted on Jul 8th 2025 at 03:59:28 UTC by @a090325 for Audit Comp | Folks Smart Contract Library
- Report ID: #48804
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/Folks-Finance/algorand-smart-contract-library/blob/main/contracts/library/RateLimiter.py
- Impacts:
- Bypass of the rate limit beyond set parameters
Description
Brief/Intro
Capacity can be re-filled to the maximum value (limit) if (Global.latest_timestamp - rate_limit_bucket.last_updated.native) is greater than or equal to (rate_limit.duration). So an attacker can exhaust capacity in block n-1. Then when being chosen as block proposer, he can set timestamp of block n further into the future so that in block n+1: (Global.latest_timestamp - rate_limit_bucket.last_updated.native) is greater than or equal to (rate_limit.duration) to refill capacity to the maximum value (limit) if (rate_limit.duration) is small enough. Please be noted that Global.lastest_timestamp is the timestamp of block n (controlled by attacker).
On Algorand, a block’s timestamp can be at most 25 seconds further into the future than the previous block timestamp. So any rate limit with duration less than 25 seconds can be refilled to maximum value just after two blocks (~ 7 seconds) by exploiting this vulnerability. Generally, any rate limit can be refilled faster than intended (since the refilled amount is proportional to the difference between Global-lastest_timestamp and rate_limit_bucket.last_updated.native) but the effect is less significant if the rate_limit.duration.native is large.
Vulnerability Details
- In _update_capacity () function, capacity can be refilled to maximum capacity (limit) if time_delta >= rate_limit_bucket.duration.native:
# increase capacity by fill rate of <limit> per <duration> without exceeding limit
time_delta = Global.latest_timestamp - rate_limit_bucket.last_updated.native
new_capacity_without_max = rate_limit_bucket.current_capacity.native + (
(rate_limit_bucket.limit.native * time_delta) // rate_limit_bucket.duration.native
)
# update capacity and last updated timestamp
self.rate_limit_buckets[bucket_id].current_capacity = rate_limit_bucket.limit \
if new_capacity_without_max > rate_limit_bucket.limit else ARC4UInt256(new_capacity_without_max)
self.rate_limit_buckets[bucket_id].last_updated = ARC4UInt64(Global.latest_timestamp)
- The refilled amount is:
(rate_limit_bucket.limit.native * time_delta) // rate_limit_bucket.duration.native
)
- So if time_delta is greater than or equal to rate_limit_bucket.duration.native, capacity can be refilled to maximum value (rate_limit_bucket.limit.native) in this line:
self.rate_limit_buckets[bucket_id].current_capacity = rate_limit_bucket.limit \
if new_capacity_without_max > rate_limit_bucket.limit else ARC4UInt256(new_capacity_without_max)
Impact Details
- Rate limits with a duration shorter than 25 seconds can be fully refilled just two blocks later (approximately 7 seconds in real time), due to allowable timestamp manipulation. Even longer-duration rate limits can be partially refilled faster than intended under the same conditions.
- Since only block proposers can influence timestamps, an attacker must be consistently selected and well-funded to carry out repeated exploits.
- If the rate limit protects critical operations (e.g., fund withdrawals), this vulnerability could have serious consequences, especially given its repeatability.
References
- https://github.com/algorandfoundation/specs/blob/master/dev/ledger.md
- https://developer.algorand.org/articles/developer-improvements-in-go-algorand-316/?from\\_query=25%20seconds
Proof of Concept
Proof of Concept
- Set up a rate limit bucket using the library with the following parameters:
- Limit: 1000
- Duration: 21 seconds (approximately 6 blocks)
- At block n-1, Alice (an attacker) fully consumes the bucket's capacity.
- Under normal conditions, the bucket would be refilled at t + 21s (real time) or block n + 6 (block time).
- At block n, Alice is selected as the block proposer.
- She sets the block’s timestamp 25 seconds ahead of real time (within the allowed t_delta limit).
- Because block n's timestamp is artificially ahead, the contract sees the 21-second duration as already elapsed.
- At block n + 1 (just ~3.5 seconds later in real time), Alice is able to consume the bucket again, bypassing the intended rate limit.
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
Impact
Rate limits with a duration shorter than 25 seconds can be fully refilled just two blocks later, and longer-duration limits can be partially refilled faster than intended, potentially allowing bypass of critical operations like fund withdrawals.
What the attacker needed
Attacker must be a block proposer; rate limit duration less than 25 seconds for full refill
How it was found
- Set up a rate limit bucket with a limit of 1000 and a duration of 21 seconds.
- At block n-1, the attacker fully consumes the bucket's capacity.
- At block n, the attacker is selected as block proposer and sets the block timestamp 25 seconds ahead.
- At block n+1, the attacker can consume the bucket again because the contract sees the duration as elapsed.
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 a security control that restricts how often an action can be performed, like limiting withdrawals to once per hour. This report shows that because the contract uses the block's timestamp to decide when to reset the limit, and because a block proposer can choose a timestamp up to 25 seconds in the future, they can make the limit reset early. This means they could perform actions more frequently than allowed.
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.