Your endpoint hands caller-supplied bytes to a hardware-backed signing key and returns a trusted signature. It checks the caller's role and nothing about what they are signing.
What goes wrong
An endpoint takes bytes from the request body and asks a hardware-backed key to sign them. The only guard is a role check. If you hold the role, you can submit any content you like and get back a signature that the rest of the system, and possibly other systems, will treat as authentic.
A signing key is supposed to attest to specific things, like a particular token or a particular build. When the endpoint puts no constraint on what gets signed, it stops being a signing service and becomes a signing oracle. Nothing ties the request to a purpose or to the caller who made it. The key will sign a forged authorization payload as happily as a legitimate one.
Role-based access answers who can call the function. It says nothing about whether this caller should be allowed to produce this particular signature. Those are different questions, and only one of them is being asked.
The pattern
@RequireRole('signer')
def sign(request):
payload = request.body.bytes # attacker-chosen
signature = hsm.sign(KEY_ID, payload)
return { 'signature': signature } # trusted everywhere
# no check on what payload is, or who it is for@RequireRole('signer')
def sign(request):
doc = parseAndValidate(request.body) # known shape only
requireOwnership(caller, doc.subject) # caller's own data
requirePurpose(doc.type, allowedPurposes)
payload = canonicalize(doc) # server builds bytes
return hsm.sign(keyFor(doc.type), payload)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
The blast radius depends on what that signature buys. If it authenticates messages between services, an attacker mints trusted messages. If it signs entitlements or updates, they sign their own. A signature your infrastructure trusts by default is one of the highest-value primitives you expose, and an unconstrained signing route gives it away to everyone who cleared the role gate.
The rule that holds up: never sign raw caller input. Build the thing to be signed on the server from validated fields and tie it to the caller and a purpose. Use a key scoped to that purpose so one leak does not authorize everything.
Check your own code
- List every endpoint that signs data and note what builds the payload
- Require the server, not the caller, to assemble what gets signed
- Bind each signature to a caller, a resource, and a purpose
- Scope keys per purpose so one route cannot forge another's output