#48747 [SC-Insight] Consider emitting BucketConsumed for infinite buckets in RateLimiter
Description
Brief/Intro
Vulnerability Details
def _consume_amount(self, bucket_id: Bytes32, amount: UInt256) -> None:
"""Consumes an amount inside a bucket.
Args:
bucket_id: The bucket to consume from.
amount: The amount to consume.
Raises:
AssertionError: If the bucket is unknown.
AssertionError: If there is insufficient capacity.
"""
# fails if bucket is unknown
self._update_capacity(bucket_id)
# ignore if duration is zero
rate_limit_bucket = self._get_bucket(bucket_id)
if not rate_limit_bucket.duration.native:
# <-------------- consider emitting BucketConsumed here
return
# ensure there is enough capacity
assert amount <= rate_limit_bucket.current_capacity, "Insufficient capacity to consume"
# consume amount
new_capacity = rate_limit_bucket.current_capacity.native - amount.native
self.rate_limit_buckets[bucket_id].current_capacity = ARC4UInt256(new_capacity)
emit(BucketConsumed(bucket_id, amount))Impact Details
References
Proof of Concept
Proof of Concept
Previous#48717 [SC-Insight] RateLimiter current capacity can be permanently held at zeroNext#48885 [SC-Low] No items length check in remove_item leads to a revert with an underflow
Was this helpful?