Skip to content

[Bug] ReDoS Vulnerability in Regex Search (No Protection) / 正则搜索存在 ReDoS 漏洞(无防护) #131

@SunYanbox

Description

@SunYanbox

Location / 位置: regex_search_tool.py:133, workspace.py:81

User-provided regex patterns are compiled directly with re.compile(pattern) without any ReDoS protection.
用户提供的正则表达式直接通过 re.compile(pattern) 编译,没有任何 ReDoS 防护。

The following safeguards are missing / 缺失以下防护措施:

  • re.TIMEOUT timeout limit / 超时限制
  • Complexity upper bound detection / 复杂度上限检测
  • Per-match timeout monitoring / 单次匹配耗时监控

Malicious or accidental catastrophic patterns such as (a+)+b or (x+x+)+y can cause exponential backtracking on specific inputs.
恶意或意外的灾难性模式(如 (a+)+b(x+x+)+y)在特定输入上会导致指数级回溯。

Since workspace.search_content uses ThreadPoolExecutor (workspace.py:106), a ReDoS attack does not just hang a single search — it exhausts the thread pool and blocks the entire tool system's concurrency.
由于 workspace.search_content 使用了 ThreadPoolExecutorworkspace.py:106),ReDoS 不仅会卡住单次搜索,还会耗尽线程池,阻塞整个工具系统的并发能力。

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions