The signing routine took the algorithm name from the caller and passed it into the signer. Nothing stopped a request for a broken hash or a raw, unpadded signature.
What goes wrong
The keys here were meant for modern signatures, RSA with SHA-256 or ECDSA on P-256. But the algorithm name arrived from the caller and went straight into signer construction with no allowlist in the way. If the underlying provider honors arbitrary algorithm strings, a caller asks for a SHA-1 based signature, or a raw signature with no hashing at all, and gets it, produced by your real key.
The key is strong. The algorithm wrapped around it is where the strength actually lives, and that choice was handed to whoever calls the endpoint. Downgrade the hash and you make collisions reachable. Strip the hashing and you open the door to structural forgeries. The algorithm is part of your security policy, so it belongs on the server, pinned, not offered as a request parameter.
The pattern
byte[] sign(String keyId, String algo, byte[] msg) {
var key = keys.get(keyId);
var signer = Signer.getInstance(algo); // whatever the caller sent
signer.init(key);
signer.update(msg);
return signer.sign();
}byte[] sign(String keyId, byte[] msg) {
var key = keys.get(keyId);
// the algorithm is fixed by policy, from the key type
var signer = Signer.getInstance(policyAlgoFor(key));
signer.init(key);
signer.update(msg);
return signer.sign();
}Grounding 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
A signature is a promise your system stands behind. If an attacker can downgrade the algorithm to something forgeable, they can eventually produce signatures you will accept as genuine, using your own key to make them.
Once weak signatures exist in the wild you can no longer tell them from the real ones, and every verifier that trusts this key inherits the problem. Take the choice away from the caller and tie the algorithm to the key.
Check your own code
- Remove algorithm selection from the request and derive it from the key type on the server.
- If you must accept an algorithm name, allowlist the exact approved set and reject everything else.
- Ban SHA-1, raw or NONE signing, and symmetric algorithms wherever a key is meant for asymmetric signing.