Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Bound OAuth state and LDAP cache growth

オープン
#95 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
50/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python

調査の方向性

src/asfquart/generics.py の40行目付近と87-93行目を起点に、コールバック中に保留中の OAuth state がどのように保存および削除されるかを追跡します。issue にあるクリーンアップの代替案を確認し、その後、期限切れのエントリが削除されることを検証する定期クリーンアップ機構とユニットテストを追加します。放棄された state が蓄積されなくなり、長時間実行されるプロセスが安定したメモリ使用量を維持できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

ASVS bug priority

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.

主要言語
Python
スター
7
フォーク
13
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/infrastructure-asfquart のほかの issue

apache/infrastructure-asfquart の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。