Part 3 of 17 · 3 min read
An audience-less token is a key that opens every door it's shown to
A token without a named destination is accepted anywhere it is presented, which turns one login into a master key.
Think of a hotel key card that works at every hotel in the chain, rather than just the one you checked into. It is convenient for you. It is also exactly the reason a thief would want to steal it rather than a single room's key.
In plain words: the audience is the one resource a token was issued for, and token passthrough -- a server accepting tokens that were not issued to it and forwarding them downstream -- is forbidden because it turns a single-purpose credential into one that works anywhere it is shown, which is the same shape of mistake as the confused deputy attack, where a service uses its own authority on a stranger's behalf because it was tricked into thinking the request was legitimate.
A worked example. A token issued for https://calendar.example/api, presented at the notes server, is accepted (200, data returned) when the audience is not checked and refused (401) when it is. Separately, in the confused-deputy experiment, a proxy with no consent step of its own sends an attacker a victim's authorization code with the victim seeing zero consent screens (the third party's cookie skipped its own screen); adding per-client consent at the proxy makes the victim see one screen naming the attacker's real redirect address, and a person who looks declines -- no code sent.
The key lines. From code/mini-auth/protected.py:
# from code/mini-auth/protected.py
if self.check_audience and claims.get("aud") != CANONICAL:
return self._deny(401, challenge("invalid_token", description="token was not issued for this server"), "invalid token: wrong audience")
Read it as: CANONICAL is this one server's own address, compared against claims.get("aud") with simple equality. The entire audience check is one string comparison. That is also why it is the check people skip most often. Nothing else in the request looks wrong when it is missing. The problem only shows up when a token meant for a different service is reused here.
Audience, token passthrough, confused deputy
The audience is the resource a token was issued for; a server must check that it names this server. Token passthrough is a server accepting tokens not issued to it and forwarding them downstream, which is forbidden. The confused deputy is a service tricked into using its own authority on a stranger's behalf.
Example: a calendar-scoped token being accepted at the notes server is a passthrough-shaped hole, and a proxy that skips its own consent step because a cookie already approved a different client is a confused-deputy-shaped one -- both let a credential meant for one purpose do work it was never issued for.
For the curious If passthrough is forbidden, what does an agent do across several hops?
Not reuse the token (passthrough) and not mint one that just claims trust. Part 14 covers the standard answer: exchange the token for a new one, scoped to the next hop, with an explicit record of which agent is actually presenting it.