VulnWatch by ve1ve2
high 7.8 EPSS 0.87%

GHSA-r7hm-rjvg-xx7j / CVE-2026-129302: Guard Core: Quadratic ReDoS in built-in detection pattern freezes the event loop with a single request

Source:
GitHub Security Advisories
Published:
Fetched:
Updated:
Affects:
guard-core

https://github.com/advisories/GHSA-r7hm-rjvg-xx7j ↗

ghsapipCWE-400CWE-1333

Guard Core: Quadratic ReDoS in built-in detection pattern freezes the event loop with a single request ### Summary A polynomial (quadratic) regular-expression denial of service in guard-core's built-in penetration-detection patterns allows any unauthenticated remote client to freeze **every** endpoint of an application for seconds per request, using only the default configuration. The triggering request completes without any detection match — no ban counter increments, no rate-limit violation is recorded — so it can be repeated indefinitely. Since guard-core 3.5.0, only *custom* patterns are executed through the compiler's timeout-protected `create_safe_matcher()`; all built-in patterns run as a bare, inline `pattern.search(content)` directly on the asyncio event loop. guard-core ≤ 3.4.0 ran built-ins through the safe matcher (verified in the 3.4.0 wheel, `_check_regex_pattern`), so this is a **regression introduced in 3.5.0** — and it silently undoes the protection credited to GHSA-rrf6-pxg8-684g (CVE-2025-54365) and the unbounded-quantifier remediation of GHSA-j47q-rc62-w448 (CVE-2025-53539) for every stock pattern, despite the changelog advertising "Safe regex execution with configurable timeouts to prevent ReDoS attacks." ### Details **1. The pattern** — `guard_core/handlers/suspatterns_handler.py:519` (master `08780f1`), the built-in template-injection detector: ```python r"\{\{\s*[^\}]+(?:system|exec|popen|eval|require|include)\s*\}\}" ``` On an input of `{` repeated N times, every one of the N−1 positions starts a `\{\{` match attempt and `[^\}]+` scans to end-of-string and backtracks once per position → O(N²). Note the sibling pattern at `:524` (`\{\%\s*[^\%]+...`) is **not** vulnerable — its delimiter `%` is excluded from the character class, keeping scans bounded — which confirms the root cause is the unbounded, non-excluding `[^\}]+`. **2. The unprotected execution path** — `guard_core/handlers/suspatterns_handler.py:910-926`: ```python if compiler: if category == "custom": safe_matcher = compiler.create_safe_matcher(pattern) # executor + timeout match = safe_matcher(content) ... else: match = pattern.search(content) # ← inline, NO timeout ``` In enhanced mode (the default whenever a `SecurityConfig` is present — `_supports_enhanced_config()` is a duck-type attribute check a stock config always passes), all built-in patterns execute inline **inside the async coroutine**, blocking the event loop for the full scan. In guard-core ≤ 3.4.0, `_check_regex_pattern()` routed *every* pattern through `self._compiler.create_safe_matcher(pattern.pattern)` (verified in the 3.4.0 wheel, `suspatterns_handler.py:565-567`) or, without a compiler, through `_check_pattern_with_timeout` (4-worker pool + per-pattern timeout). The `category == "custom"` exemption appeared in 3.5.0. **3. Default reachability** — penetration detection is on by default (`enable_penetration_detection=True`), query parameters are scanned by default (`guard_core/utils.py:843-865`), and the default scan windo Affected packages: pip:guard-core Patched: guard-core 3.13.0

Linked vulnerabilities (6)

CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Guard Core: Quadratic ReDoS in built-in detection pattern freezes the event loop with a single request

CWE: CWE-400, CWE-1333Aliases: CVE-2026-129302, CVE-2025-54365, CVE-2025-53539, GHSA-rrf6-pxg8-684g, GHSA-j47q-rc62-w448
CVE-2026-129302 high 7.5 EPSS 0.53% (p45) NVDCVE.orgGHSAGHSAGHSA
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H

Guard Core: Quadratic ReDoS in built-in detection pattern freezes the event loop with a single request

CWE: CWE-400, CWE-1333Aliases: GHSA-r7hm-rjvg-xx7j, CVE-2025-54365, CVE-2025-53539, GHSA-rrf6-pxg8-684g, GHSA-j47q-rc62-w448NVD: Received
CVE-2025-54365 high 7.8 EPSS 0.87% (p60) NVDCVE.org
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:H/SC:N/SI:N/SA:N/E:P/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

fastapi-guard is a security library for FastAPI that provides middleware to control IPs, log requests, detect penetration attempts and more. In version 3.0.1, the regular expression patched to mitigate the ReDoS vulnerability by limiting the length of string fails to catch inputs that exceed this limit. This type of patch fails to detect cases in which the string representing the attributes of a <script> tag exceeds 100 characters. As a result, most of the regex patterns present in version 3.0.1 can be bypassed. This is fixed in version 3.0.2.

CWE: CWE-20, CWE-185, CWE-1333NVD: Analyzed
CVE-2025-53539 medium 6.9 EPSS 0.48% (p42) NVDCVE.org
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X

FastAPI Guard is a security library for FastAPI that provides middleware to control IPs, log requests, and detect penetration attempts. fastapi-guard's penetration attempts detection uses regex to scan incoming requests. However, some of the regex patterns used in detection are extremely inefficient and can cause polynomial complexity backtracks when handling specially crafted inputs. This vulnerability is fixed in 3.0.1.

CWE: CWE-1333NVD: Analyzed

Also reported by (1)