Bound OAuth state and LDAP cache growth
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 50/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Tranquilla
- Stack tecnologico
- python
- Ambito
- authentication, backend
Direzione di ricerca
Inizia in src/asfquart/generics.py intorno alla riga 40 e alle righe 87-93 per tracciare come gli stati OAuth in sospeso vengono memorizzati e rimossi durante i callback. Esamina le alternative di pulizia nell’issue, quindi aggiungi un meccanismo di pulizia periodica e unit test che verifichino che le voci scadute vengano rimosse. Il lavoro è completato quando gli stati abbandonati non si accumulano più e i processi di lunga durata mantengono un utilizzo stabile della memoria.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Issue: FINDING-276 - No Expiry Cleanup for Stale OAuth State Entries (Memory Leak)
Labels: bug, security, priority:low, asvs-level:L2
ASVS Level(s): L2
Description:
Summary
Expired state entries are only cleaned up when specifically looked up during a callback. If a user initiates an OAuth flow but never completes the callback, the state entry remains in the dictionary indefinitely until process restart, causing gradual memory growth. With ~200 bytes per entry, 1000 abandoned flows would leak ~200 KB. This is a resource leak rather than a security vulnerability, but could impact long-running processes in high-traffic scenarios.
Details
In src/asfquart/generics.py at line 40 and lines 87-93, expired state entries are only cleaned up on lookup, not proactively.
Recommended Remediation
Implement periodic cleanup mechanism.
Option 1: Add async background task that runs every 5 minutes to clean expired states:
async def _cleanup_expired_states():
current_time = time.time()
expired = [s for s, d in pending_states.items() if d['timestamp'] < (current_time - workflow_timeout)]
for state in expired:
pending_states.pop(state, None)
Option 2: Probabilistic cleanup on each request (e.g., 10% of requests trigger cleanup).
Option 3: Migrate to Redis with automatic TTL-based expiry.
Acceptance Criteria
- Periodic cleanup mechanism implemented
- Memory leak eliminated
- Long-running processes maintain stable memory usage
- Unit tests verify cleanup logic
References
- Source reports: L2:10.4.7.md
- Related findings: FINDING-272
- ASVS sections: 10.4.7
Priority
Low
The LDAP_CACHE dictionary is a module-level in-memory cache with no size limit, no eviction policy, and no background cleanup. Entries are only overwritten when the same userid is looked up again. The TTL (3600s) is checked for staleness (to determine if a re-query is needed) but expired entries are never removed from memory. Over the lifetime of the process, the cache grows monotonically as new users are encountered.
- Lingua principale
- Python
- Stelle
- 7
- Fork
- 13
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di apache/infrastructure-asfquart
-
bug priority
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Document OAuth callback consistency rulesForse già presa @Marrshal15 l’ha presa 11 giorni fa. Apertadocumentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
apache/infrastructure-asfquart#126 · 1 commento ·
-
ASVS priority
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
apache/infrastructure-asfquart#85 · 1 commento ·
-
Triage and track asfquart issuesForse già presa @sbp l’ha presa 10 giorni fa. Aperta
apache/infrastructure-asfquart#134 · 1 assegnatario ·
Tutte le issue di apache/infrastructure-asfquart
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
UKGovernmentBEIS/control-arena#917 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
debpalash/VoiceStudio#2937 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
aws-samples/sample-per-model-bedrock#261 ·
I maintainer di solito rispondono entro 1 giorno