The vulnerability is a JWT algorithm confusion issue where the verification logic would trust the alg field from the unverified JWT header if the corresponding JSON Web Key (JWK) did not specify an algorithm. The analysis of the patch commit 190f6e28e2ca85ce3d1f2f54db1310f5f3eab134 confirms this.
The core of the flaw was in the verifyWithJwks function in src/utils/jwt/jwt.ts. The line alg: (matchingKey.alg as SignatureAlgorithm) || header.alg, demonstrates that the function would use the header.alg as a fallback, which is controlled by the attacker. This allowed an attacker to dictate the verification algorithm.
The patch addresses this by introducing a mandatory alg parameter in the public-facing jwk middleware (src/middleware/jwk/jwk.ts), which specifies an allowlist of asymmetric algorithms. This list is then passed to verifyWithJwks. The updated verifyWithJwks function now rejects symmetric algorithms outright and validates the JWT's algorithm against the provided allowlist, removing the dangerous fallback behavior.
Two functions are identified as vulnerable:
verifyWithJwks: Contains the flawed logic of trusting the JWT header's alg parameter.
jwk: The middleware entry point that uses verifyWithJwks without enforcing any algorithm restrictions, thus exposing the vulnerability.
Both functions would be present in a runtime profile or stack trace when the vulnerability is triggered.