The Function get_current_capacity() returns wrong value when bucket is infinite
The get_current_capacity() function returns the initial limit value for a bucket with zero duration (infinite capacity) instead of indicating infinite capacity. An attacker or user relying on this value could be misled about the actual remaining capacity.
- Disclosed after under an hour
#49061 [SC-Insight] The Function `get_current_capacity()` returns wrong value when bucket is infinite
Submitted on Jul 11th 2025 at 06:51:31 UTC by @c3phas for Audit Comp | Folks Smart Contract Library
- Report ID: #49061
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/Folks-Finance/algorand-smart-contract-library/blob/main/contracts/library/RateLimiter.py
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
When we call the function get_current_capacity() with the id of a bucket that has an infinite capacity, ie zero duration, the function returns the capacity as the value set when creating the bucket. ie if we set limit as 100, the capacity would be 100.
Vulnerability Details
According to the docs, a bucket with a duration of zero is considered an infinite bucket, meaning infinite capacity. For this reason when we check if the bucket has capacity by calling has_capacity() it always returns True. Function such as consume_amount do not modify such a bucket as we should always be able to consume from it.
The problem is for any one relying on the function get_current_capacity() maybe on their frontend to determine how much capacity is left, the function would be returning a finite value which can be misleading if they build their logic around this function.
Impact Details
Any front end relying on the result of get_current_capacity() would be reading the wrong value.
References
Proof of Concept
Proof of Concept
- Create a bucket with a duration of zero(infinite bucket) passing limit as 5
- The current capacity of the bucket would in turn be set to 5.
- If we call
get_current_capacity()it would return 5. - For someone monitoring this value, they might think we only have five requests left for this bucket and could center their logic around 5, reducing the amount for every amount consumed.
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 function does not special-case buckets with zero duration, so it returns the stored limit rather than an infinite value.
Impact
Any front end relying on the result of get_current_capacity() would be reading the wrong value, which could lead to incorrect logic about remaining capacity.
What the attacker needed
Bucket with zero duration (infinite)
How it was found
- Create a bucket with a duration of zero (infinite bucket) passing limit as 5.
- The current capacity of the bucket is set to 5.
- Call get_current_capacity() and it returns 5.
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 bucket with zero duration is meant to have infinite capacity, so you can always consume from it. But a function that reports the current capacity returns the original limit number instead of saying it's infinite. This could confuse anyone using that number to decide how many actions are left.
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.