By Sergio Atenciano7 min read

The token signs who, not what

A signed token that authenticates the actor, sitting next to an object identifier the signature never covers, looks secure and is not.

Signed tokens give a justified sense of safety: no one can forge them without the key. The problem is not the signature, it is what it spans. A bug that shows up again and again is a token that correctly signs the identity of its bearer, while the object it acts on rides in a separate field the signature never touches.

The signature authenticates who. The object identifier says what. If the second is not inside what was signed, the server trusts a value the client controls, and it does so precisely because the token next to it seemed to guarantee everything.

A generic example

Picture a link to download an attachment. It carries a signed token identifying the user and, beside it, the attachment number:

GET /download?user_token=<signed: user=Ana>&attachment=5501

# The signature proves the token is Ana's.
# "attachment=5501" is not inside the signature.
# Change 5501 to 5502 and you download someone else's file.
pseudo-HTTP

Its inverse, which confuses

The opposite shape exists, and telling them apart saves time: a token that signs the object but never checks the actor. There the signature guarantees which resource it is, but anyone with the link can use it, because it binds the action to no person.

They are two different bugs with the same look. One is missing the object inside the signature; the other is missing the actor in the check. Before you report or fix, say in one sentence which of the two halves you are holding: it saves an argument and avoids a duplicate.

Where to look for it

  • Download links, previews and signed exports, where the resource sits in a parameter separate from the token.
  • Webhooks and callbacks with a shared secret that validates the origin but does not bind the event to an account.
  • Invitation or reset tokens that sign the invitee and accept a separate target identifier.
  • Anywhere you see a signed value and, beside it, a plain number or identifier.

The fix

The rule is simple: what the signature guarantees must include everything the server will take as true. If the object matters to the access decision, the object goes inside what is signed.

  • Put the object identifier inside the signed payload, not next to it.
  • And even then, check ownership at serving time: the signature says what was asked for, not who may have it today. State changes; a revocation or an owner change must count.
  • Do not use one secret to sign things of different classes: a token valid for one should not be valid for another.

The takeaway

A signature only protects what it signs. When you see a token beside a loose identifier, ask exactly what the signature covers. If the object falls outside it, the security is apparent: the lock is real, but the door next to it is open.

Everything here is generic. We never describe a specific flaw in a client or a bug-bounty program, neither while it is unfixed nor after.

Back to research