The whole point of a key vault is that the secret never leaves it. One helper loaded the private bytes and returned them to the caller as a string.
What goes wrong
A key vault earns its keep by exposing operations and nothing else. You can sign with the key, decrypt with the key, wrap another key. What you should never be able to do is read the key back out. This helper broke that. It took an alias the caller controls, loaded the matching private key, encoded the bytes, and returned them in a list of strings.
Once a private key is a return value it stops being a secret. It lands in logs, in a heap dump, in the body of the next service call, on the screen of whoever is debugging. You can rotate a leaked password in an afternoon. Rotating a leaked signing key means re-issuing everything that key ever vouched for, and hoping nobody kept a copy of the old material.
The pattern
List<String> getKey(String alias) {
var entry = keystore.load(alias);
byte[] raw = entry.privateKeyBytes();
List<String> out = new ArrayList<>();
out.add(hex(raw));
return out; // the private key just left the vault
}byte[] signWith(String alias, byte[] message) {
var entry = keystore.load(alias);
// the key stays inside; only the result crosses out
return entry.sign(message);
}
// there is no accessor that returns raw key bytes, everGrounding 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 any code path can return raw key material, every caller becomes a place your key can leak from. An attacker doesn't have to break your crypto. They ask the API for the key and walk away with it.
The fix is a boundary, not a patch. Wrap the key so callers get verbs (sign, decrypt, wrap) and never the noun. If a getter for private bytes exists anywhere, assume someone will call it in production.
Check your own code
- Grep for any method whose return type carries key bytes or a hex or base64 key string.
- Confirm your key wrapper exposes only operations, with no getter for raw private material.
- Check that key lookups keyed by caller input also carry an authorization check on that alias.