Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern
Summary
_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 in track_return_pattern() (behavior_handler.py:135-142). redis_handler.keys() maps to the blocking Redis KEYS command (guard_core/handlers/redis_handler.py:265-275).
Details
Three consequences, in increasing severity:
- Cross-client counter contamination.
X-Forwarded-For: *makes the glob match every client's behavior-usage keys for the endpoint. Verified with a fake-Redis harness: a client9.9.9.9hit an endpoint 3 times (threshold=3 rule), then a single attacker request carryingXFF: *issued the patternbehavior_usage:behavior:usage:app.login:*:*, counted the victim's events, and tripped the rule on its first request. An embedded:also shifts which key segment is parsed as the timestamp (behavior_handler.py:94-100). - Unbounded key-space growth + blocking scans. Each request creates a new unique key (
f"{key}:{current_time}") and then issues a blockingKEYSscan whose cost grows with total keys — on the shared Redis instance, degrading every guard-core instance using it. Rotating arbitrary XFF strings multiplies distinct keys without bound. - Error path. A tripped
banaction passes the non-IP string toip_ban_manager.ban_ip(), whoseipaddressvalidation raisesValueErroruncaught in the behavioral processor — the request 500s.
PoC
import asyncio
from types import SimpleNamespace
from guard_core.models import SecurityConfig
from guard_core.utils import extract_client_ip
class CIHeaders(dict):
def get(self, key, default=None):
for k, v in self.items():
if k.lower() == key.lower():
return v
return default
class FakeRequest:
def __init__(self, xff):
self.state = SimpleNamespace()
self.client_host = "10.0.0.1" # the TRUSTED proxy
self.headers = CIHeaders({"X-Forwarded-For": xff})
async def main():
config = SecurityConfig(trusted_proxies=("10.0.0.1",), enable_redis=False)
ip = await extract_client_ip(FakeRequest("*"), config)
print(repr(ip)) # -> '*' (arbitrary string, no validation)
asyncio.run(main())
Then BehaviorTracker.track_endpoint_usage("app.login", "*", rule) issues KEYS behavior_usage:behavior:usage:app.login:*:* — matching other clients' keys (full fake-Redis script: poc_xff_redis.py, available on request).
Impact
Integrity and availability of the behavioral-analytics subsystem and the shared Redis instance, in deployments where the extracted XFF position is attacker-controllable. No data exposure; not reachable with default settings (trusted_proxies defaults empty).
Fix: validate the extracted XFF entry with ipaddress.ip_address() before returning it from extract_client_ip() (fall back to the connecting IP on failure); escape glob metacharacters (*?[]) in anything interpolated into a KEYS pattern — or replace the KEYS+per-request-key design with an atomic counter / Lua sliding window (the rate-limit Lua script already shows the right shape).
Betroffene Software
Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.
| Plattform | Paket | Anfällige Versionen | Behoben in |
|---|---|---|---|
| Python (PyPI) | guard-core | >= 1.0.0, < 3.13.0 | 3.13.0 |
Verweise
- https://github.com/Guard-Core/guard-core/security/advisories/GHSA-gm9r-hvc9-96gv
- https://nvd.nist.gov/vuln/detail/CVE-2026-129304
- https://github.com/Guard-Core/guard-core/pull/68
- https://github.com/Guard-Core/guard-core/commit/c07239fa1c5aa93e3f179440e79dad652977d3e4
- https://github.com/Guard-Core/guard-core/releases/tag/3.13.0
- https://github.com/rennf93/guard-core
- CVSS-Vektor
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:L/A:L- Schwäche (CWE)
CWE-20- Plattform
- Python (PyPI)
- Paket
guard-core- Veröffentlicht
- 19.11.2026
- Aktualisiert
- 20.11.2026 00:17
Quellen und Lizenzen
OSV / GitHub Advisory Database - GHSA-gm9r-hvc9-96gv - CC BY 4.0
Schwachstellenhistorie: guard-core
Alle veröffentlichten Schwachstellen dieses Pakets (Python (PyPI)), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.
- Einträge insgesamt
- 3
- Erste → letzte
- 11.2026 11.2026
- Ohne Fix
- 0
- In Angriffen ausgenutzt
- 0
Verteilung nach Schweregrad
- Hoch 1
- Mittel 1
- Niedrig 1
Veröffentlichungen pro Jahr
- 2026: 3
-
Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern dieser Eintrag
Erkennen Sie Schwachstellen in Ihrer Anwendung
Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.