Skip to content

fix(api): enforce shared global rate limit#23

Merged
listlessbird merged 1 commit into
mainfrom
fix/issue-20-global-rate-limit
Mar 3, 2026
Merged

fix(api): enforce shared global rate limit#23
listlessbird merged 1 commit into
mainfrom
fix/issue-20-global-rate-limit

Conversation

@listlessbird
Copy link
Copy Markdown
Owner

@listlessbird listlessbird commented Mar 3, 2026

Summary

  • wire GLOBAL_LIMIT into SlowAPI limiter as an application-wide shared limit
  • add SlowAPIMiddleware so application limits are enforced
  • keep memory:// backend for current single-deployment setup

Validation

  • uv run ruff check src/api/rate_limit.py src/api/main.py

Closes #20

@listlessbird listlessbird merged commit 11787a1 into main Mar 3, 2026
0 of 2 checks passed
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9229514767

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +28 to +30
key_func=_get_connecting_ip,
default_limits=[],
application_limits=[GLOBAL_LIMIT],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Use a shared key for the global application limit

application_limits=[GLOBAL_LIMIT] is still keyed by the limiter key_func, and _get_connecting_ip returns a per-client IP, so this change enforces 200/minute per IP instead of a single shared cap across all clients. In practice, aggregate traffic can exceed the intended global ceiling whenever requests come from multiple client IPs (or a distributed attacker), so the DOS guard described by GLOBAL_LIMIT is not actually enforced.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Detail Bug] API rate limiting: global shared limit is not enforced, enabling distributed DoS bypass

1 participant