Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Bound OAuth state and LDAP cache growth

未关闭
#95 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
50/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
python

调研方向

从 src/asfquart/generics.py 第 40 行附近以及第 87-93 行开始,跟踪待处理的 OAuth 状态在回调期间是如何存储和移除的。查看 issue 中的清理方案,然后添加定期清理机制和单元测试,以验证过期条目会被移除。完成的标准是:被放弃的状态不再累积,并且长时间运行的进程能够保持稳定的内存使用量。

由索引模型根据 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
派生
14
平均合并
11 小时 58 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/infrastructure-asfquart 的其他 Issue

查看 apache/infrastructure-asfquart 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。