Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banned user can continue making requests after the rate limit duration expires #77

Open
AntonyZ89 opened this issue Feb 18, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@AntonyZ89
Copy link

Currently, the isRateLimited function enforces a request limit based on a specific time window. If a user exceeds this limit, they should be banned for an additional period before being allowed to make new requests.

Problem:

The current implementation does not correctly check if a user is banned. The isRateLimited function only verifies whether the user has exceeded the request limit within the rate limit period (options.limit.duration).

This leads to unexpected behavior:

When a user exceeds the request limit, they are blocked only until the rate limit duration expires.
After this time, the user can continue making requests, completely ignoring the additional ban period.

Cause of the issue:

The isRateLimited function does not track a banned state. Currently, it only checks if the request count (req.count) exceeds the limit and compares the elapsed time since the last request to options.limit.duration, without considering options.limit.ban.

Attempted Fix:

I tried to solve this issue but couldn't, as it requires adding a new functionality to properly track and enforce the ban period. The current implementation lacks a way to persist and check if a user is banned beyond the rate limit duration.

@rrd108
Copy link
Owner

rrd108 commented Feb 22, 2025

Thanks for reporting. I will back to my normal life on 12 March. I will look into this after that.

@rrd108 rrd108 added the bug Something isn't working label Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants