{"vuln_id":"GHSA-gm9r-hvc9-96gv","aliases":["CVE-2026-129304"],"description":"Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern","published_at":"2026-11-19T22:50:33Z","modified_at":"2026-11-19T23:00:36.659118Z","first_seen_at":"2026-11-21T19:15:19.375314Z","severity":"medium","severity_source":"ghsa","cvss_score":5.4,"cvss_vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:L/A:L","cwe":["CWE-20"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":null,"epss_percentile":null,"nvd_status":null,"enriched_at":null,"links":{"nvd":"https://github.com/advisories/GHSA-gm9r-hvc9-96gv"},"matched_alias":null,"items":[{"id":10710,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-gm9r-hvc9-96gv: Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern","summary":"Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern\n\n### 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.logi\n\nAffected: PyPI:guard-core\n\nFixed in: 3.13.0\n\nReferences:\nhttps://github.com/Guard-Core/guard-core/security/advisories/GHSA-gm9r-hvc9-96gv\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-129304\nhttps://github.com/Guard-Core/guard-core/pull/68\nhttps://github.com/Guard-Core/guard-core/commit/c07239fa1c5aa93e3f179440e79dad652977d3e4\nhttps://github.com/Guard-Core/guard-core/releases/tag/3.13.0\nhttps://github.com/rennf93/guard-core","url":"https://osv.dev/vulnerability/GHSA-gm9r-hvc9-96gv","published_at":"2026-11-19T22:50:33Z","updated_at":"2026-11-19T23:00:36.659118Z","fetched_at":"2026-11-21T19:15:55.946121Z","severity":"medium","cvss_score":5.4,"epss":0.00244,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"guard-core","vuln_id":"CVE-2026-129304","vuln_ids":["CVE-2026-129304","GHSA-GM9R-HVC9-96GV"],"tags":["osv","pypi","fix-available"],"cluster_id":2163,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10710","html":"https://vulnwatch.ve1ve2.com/item/10710"}},{"id":2368,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-gm9r-hvc9-96gv / CVE-2026-129304: Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern","summary":"Guard Core: Unvalidated X-Forwarded-For-derived string used as a Redis key component and interpolated into a KEYS glob pattern\n\n### 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.logi\n\nAffected packages: pip:guard-core\nPatched: guard-core 3.13.0","url":"https://github.com/advisories/GHSA-gm9r-hvc9-96gv","published_at":"2026-11-19T22:50:33Z","updated_at":"2026-11-19T22:50:34Z","fetched_at":"2026-11-21T19:15:18.416783Z","severity":"medium","cvss_score":5.4,"epss":0.00244,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"guard-core","vuln_id":"CVE-2026-129304","vuln_ids":["CVE-2026-129304","GHSA-GM9R-HVC9-96GV"],"tags":["ghsa","pip","CWE-20"],"cluster_id":2163,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2368","html":"https://vulnwatch.ve1ve2.com/item/2368"}},{"id":6259,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129304: Guard Core is an API security core engine for the FastAPI-Guard, FlaskAPI Guard, and DjAPI Guard adapters. From 1.0.0 until 3.13.0, _extract_from_forwarded_hea…","summary":"Guard Core is an API security core engine for the FastAPI-Guard, FlaskAPI Guard, and DjAPI Guard adapters. From 1.0.0 until 3.13.0, _extract_from_forwarded_header() in guard_core/utils.py returns the selected X-Forwarded-For entry without validating that it is an IP address. In deployments configured with trusted_proxies where the selected entry is attacker-controlled, the arbitrary client_ip string reaches BehaviorTracker in guard_core/handlers/behavior_handler.py and is interpolated into Redis key names and blocking KEYS glob patterns. Glob metacharacters can cause one request to count other clients' behavior events, embedded separators can disturb key parsing, and rotating identities can create unbounded keys while repeatedly scanning the shared Redis keyspace. A non-IP identity can also reach a ban action and cause an uncaught validation error. This issue is fixed in version 3.13.0.\n\nReferences:\nhttps://github.com/Guard-Core/guard-core/commit/c07239fa1c5aa93e3f179440e79dad652977d3e4\nhttps://github.com/Guard-Core/guard-core/pull/68\nhttps://github.com/Guard-Core/guard-core/releases/tag/3.13.0\nhttps://github.com/Guard-Core/guard-core/security/advisories/GHSA-gm9r-hvc9-96gv","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129304","published_at":"2026-11-16T20:19:01.350000Z","updated_at":"2026-11-18T18:19:07.850000Z","fetched_at":"2026-11-21T19:15:31.482033Z","severity":"medium","cvss_score":5.4,"epss":0.00244,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129304","vuln_ids":["CVE-2026-129304","GHSA-GM9R-HVC9-96GV"],"tags":["CWE-20"],"cluster_id":2164,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/6259","html":"https://vulnwatch.ve1ve2.com/item/6259"}}]}