Advisories for Pypi/Guard-Core package

2026

Guard Core: Whitespace-collapse preprocessing permanently disables the CRLF-anchored http-splitting and command-injection detectors in the default detection mode

In the default "enhanced" detection mode, ContentPreprocessor.preprocess() collapses all whitespace (re.sub(r"\s+", " ", content), guard_core/detection_engine/preprocessor.py:137 on master 08780f1; :384 in the 3.12.0 sdist) before pattern matching. This erases every \r and \n from the scanned value, rendering two built-in detectors structurally unmatchable regardless of input: http_split — guard_core/handlers/suspatterns_handler.py:540: r"[\r\n]\s*(?:HTTP/[0-9.]+|Location:|Set-Cookie:)" requires a literal \r or \n, which no longer exists after preprocessing; cmd_injection — r"\n\s*(?:bash|sh|…)\s+-c\b" — same structural death. The downstream …

Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern

_extract_from_forwarded_header() (guard_core/utils.py:172-181 in 3.12.0; :179 on master 08780f1) returns the selected X-Forwarded-For entry without any ipaddress validation. When that entry is attacker-controlled, an arbitrary string becomes client_ip and flows into BehaviorTracker (guard_core/handlers/behavior_handler.py:83-102), which interpolates it verbatim into both a Redis key name and a KEYS glob pattern: key = f"behavior:usage:{endpoint_id}:{client_ip}" await self.redis_handler.set_key("behavior_usage", f"{key}:{current_time}", "1", ttl=rule.window) pattern = f"behavior_usage:{key}:*" keys = await self.redis_handler.keys(pattern) # blocking KEYS, O(N) over keyspace Same shape …

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

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 …