The vulnerability is a Server-Side Request Forgery (SSRF) in Centrifugo's JWT validation logic for dynamic JWKS endpoints. The root cause is an incorrect order of operations in the VerifyConnectToken and VerifySubscribeToken functions. These functions would parse an incoming JWT and extract values from its claims (specifically iss and aud) to construct a URL for fetching the JSON Web Key Set (JWKS). This construction happened before the JWT's signature was verified.
An unauthenticated attacker could craft a JWT with a forged iss or aud claim pointing to a server they control. When Centrifugo processed this token, the jwks.Manager.fetchKey function would make an HTTP request to the attacker's URL. This allows the attacker to scan the server's internal network, access cloud metadata services to steal credentials, or serve a malicious JWKS file to bypass authentication entirely.
The patch addresses this by reordering the logic. It ensures that the JWT's signature is verified first. Only after a token is confirmed to be authentic are its claims used for any further processing, such as constructing a JWKS URL. Additionally, the patch introduces validation to restrict the values that can be used in the JWKS URL template, preventing path traversal and limiting the allowed values to a predefined set.