Rate limit: the count of windows over the limit never expires, moderators end up blocked

Aperta
#2,760 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
api, backend, security

Direzione di ricerca

Start with security/rate_limiting.py and trace how ratelimit_times and ratelimit_last_blocked_window are updated, then check the configuration for rate_limiting.max_times and rate_limiting.limit_moderator. The issue proposes several policy choices, including an optional moderator limit change, so first identify existing tests for rate limiting and moderator behavior. Done means the chosen policy is implemented and covered by tests for counter expiry and moderator responses.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

The write rate limit (security/rate_limiting.py) counts, for each user, the 15-minute windows in which they went over their limit (ratelimit_times). Once that count goes over rate_limiting.max_times (3), the account is blocked (blocked = true).

ratelimit_times never goes back down: only a moderator unblocking the account (POST /users/unblock) resets it. Four busy windows over the whole life of an account are enough for a block, even months apart.

This now hits moderators doing normal moderation work. The image duplicates tab (#2735) and the orphan images tab invite many writes in a row (merge, delete, dismiss), and the moderator limit is 100 writes per 15 minutes. On 2026-11-25 a moderator working through the duplicates tab got 429 "Rate limit reached" with ratelimit_times = 3: one more window would have blocked their account. Their counters were reset by hand in the database.

Proposal

  1. Make the count expire: reset ratelimit_times when the last window over the limit (ratelimit_last_blocked_window) is older than some period (e.g. 24 h), so only repeated abuse in a short time blocks an account.
  2. Never block moderators automatically (still answer 429 and send the alert mail): a moderator account is known, and blocking it also stops the moderation tools.
  3. Optionally raise rate_limiting.limit_moderator (100 per 15 min).

Related: #1925 (the alert mails).

Lingua principale
Python
Stelle
26
Fork
30
Merge medio
10h 18m
PR unite (30g)
195

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di c2corg/v6_api

Tutte le issue di c2corg/v6_api

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.