CVE-2026-129304: Guard Core Unvalidated X-Forwarded-For-derived String Used As Vulnerability

MODERATE
Advisory Identifier: GHSA-gm9r-hvc9-96gv
CVSS 5.4
CWE-20
Published
Advisory Summary

CVE-2026-129304 is a MODERATE (CVSS 5.4) unvalidated x-forwarded-for-derived string used as vulnerability (CWE-20: Improper Input Validation) affecting Guard Core libraries in the PyPI ecosystem. The issue involves unvalidated x-forwarded-for-derived string used as a redis key component and interpolated into a keys glob pattern. Remediation is available by upgrading affected packages to version 3.13.0.

CVE-2026-129304 at a Glance

CVE Identifier CVE-2026-129304
GHSA Identifier GHSA-gm9r-hvc9-96gv
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-20: Improper Input Validation
Affected Product Guard Core
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.4

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

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

How to Fix CVE-2026-129304

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-129304, 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. 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 `_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: ```python 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: 1. **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 client `9.9.9.9` hit an endpoint 3 times (threshold=3 rule), then a single attacker request carrying `XFF: *` issued the pattern `behavior_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`). 2. **Unbounded key-space growth + blocking scans.** Each request creates a **new unique key** (`f"{key}:{current_time}"`) and then issues a blocking `KEYS` scan 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. 3. **Error path.** A tripped `ban` action passes the non-IP string to `ip_ban_manager.ban_ip()`, whose `ipaddress` validation raises `ValueError` uncaught in the behavioral processor — the request 500s. ### PoC ```python 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).

CVE-2026-129304 Affected Guard Core Versions

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

References

Frequently Asked Questions

What is CVE-2026-129304?
CVE-2026-129304 is a security vulnerability in Guard Core involving Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern under CWE-20: Improper Input Validation.
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-129304?
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-129304?
CVE-2026-129304 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:L/A:L.
What CWE is associated with CVE-2026-129304?
CVE-2026-129304 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check PyPI dependencies for CVE-2026-129304?
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-gm9r-hvc9-96gv",
  "modified" : "2026-11-19T22:50:33Z",
  "published" : "2026-11-19T22:50:33Z",
  "aliases" : [ "CVE-2026-129304" ],
  "summary" : "Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern",
  "details" : "### Summary\n\n`_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:\n\n```python\nkey = f\"behavior:usage:{endpoint_id}:{client_ip}\"\nawait self.redis_handler.set_key(\"behavior_usage\", f\"{key}:{current_time}\", \"1\", ttl=rule.window)\npattern = f\"behavior_usage:{key}:*\"\nkeys = await self.redis_handler.keys(pattern)      # blocking KEYS, O(N) over keyspace\n```\n\nSame 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`).\n\n### Details\n\nThree consequences, in increasing severity:\n\n1. **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 client `9.9.9.9` hit an endpoint 3 times (threshold=3 rule), then a single attacker request carrying `XFF: *` issued the pattern `behavior_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`).\n2. **Unbounded key-space growth + blocking scans.** Each request creates a **new unique key** (`f\"{key}:{current_time}\"`) and then issues a blocking `KEYS` scan 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.\n3. **Error path.** A tripped `ban` action passes the non-IP string to `ip_ban_manager.ban_ip()`, whose `ipaddress` validation raises `ValueError` uncaught in the behavioral processor — the request 500s.\n\n### PoC\n\n```python\nimport asyncio\nfrom types import SimpleNamespace\nfrom guard_core.models import SecurityConfig\nfrom guard_core.utils import extract_client_ip\n\nclass CIHeaders(dict):\n    def get(self, key, default=None):\n        for k, v in self.items():\n            if k.lower() == key.lower():\n                return v\n        return default\n\nclass FakeRequest:\n    def __init__(self, xff):\n        self.state = SimpleNamespace()\n        self.client_host = \"10.0.0.1\"          # the TRUSTED proxy\n        self.headers = CIHeaders({\"X-Forwarded-For\": xff})\n\nasync def main():\n    config = SecurityConfig(trusted_proxies=(\"10.0.0.1\",), enable_redis=False)\n    ip = await extract_client_ip(FakeRequest(\"*\"), config)\n    print(repr(ip))        # -> '*'  (arbitrary string, no validation)\n\nasyncio.run(main())\n```\n\nThen `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).\n\n### Impact\n\nIntegrity 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).\n\n**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).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "guard-core"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.0"
      }, {
        "fixed" : "3.13.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/Guard-Core/guard-core/security/advisories/GHSA-gm9r-hvc9-96gv"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-129304"
  }, {
    "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-20" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-19T22:50:33Z",
    "nvd_published_at" : "2026-11-16T20:19:01Z"
  }
}