A signing endpoint let the request choose the JWS algorithm. Without a strict allowlist, that opens the door to alg none and public-key confusion attacks.
What goes wrong
JWS has carried the same wound for years: trusting the alg field. This endpoint took the algorithm from the request and forwarded it to the signer, with no visible allowlist rejecting the dangerous values.
That brings back the classic failures. A caller asks for alg none and gets an unsigned token that some verifiers still wave through. A caller asks for HMAC while the service is built around RSA, and your public key becomes the shared HMAC secret, so anyone holding that public key can sign valid tokens. Or a caller simply selects a deprecated variant that is cheaper to attack. The set of algorithms your system accepts is a server decision. Write it down as a fixed list and refuse everything outside it, on the signing side and the verifying side both.
The pattern
String issue(Claims claims, String alg) {
var header = new Header(alg); // alg comes from the request
var signer = signerFor(alg); // "none", "HS256", "RS256"...
return header + "." + encode(claims)
+ "." + signer.sign(header, claims);
}private static final Set<String> ALLOWED = Set.of("RS256", "ES256");
String issue(Claims claims) {
String alg = "ES256"; // fixed by policy
var signer = signerFor(alg);
return sign(new Header(alg), claims, signer);
}
// the verifier also pins ALLOWED and rejects "none" outrightGrounding and reachability were confirmed. The exploit-path gate would not conclude without the calling code, so the finding was held and an evidence request was raised instead of being reported as fact.
Why it matters to you
If tokens carry identity in your system, an attacker who controls the algorithm can forge identity. alg none and key-confusion attacks turn signed by us into signed by anyone, and every service downstream that trusts these tokens inherits the hole.
This one deserves urgency. Pin the algorithm on both sides, refuse alg none, and verify against the algorithm you expect rather than the one the token claims for itself.
Check your own code
- Pin signing and verification to a fixed allowlist of asymmetric algorithms.
- Reject alg none and any symmetric algorithm on endpoints that use asymmetric keys.
- Verify each token against the algorithm you expect, never the one named in its header.