Advanced OAuth
Transaction tokens
On this page
Introduction
Inside a company's network, one request from Ada can pass through many internal services, each calling the next. A "transaction token", written Txn-Token, carries who Ada is and what she asked for through that whole chain. Signari issues them, following draft-ietf-oauth-transaction-tokens-11, on datatracker.ietf.org, which is in IETF Working Group Last Call at the Internet Engineering Task Force.
The draft calls the service that issues them a "Transaction Token Service" (TTS). Here, that is Signari. An application asks for a Txn-Token with a token exchange at the ordinary token endpoint. Each internal service then passes it on in its own header.
An application needs permission to exchange tokens, and the trust domain among its audiences, as Configuration describes.
The problem
An access token proves who asked at the edge. Six services deep, the seventh has no way to know where the request it is serving came from. It might be a person, a batch job, or the fifth service deciding on its own to delete something.
So internal services either trust their callers completely, or each one re-authenticates the person. The first trusts every caller equally, as a flat network does. The second is slow.
A Txn-Token carries the subject, an immutable transaction ID and the authorization context down the whole chain. It is a short-lived signed JSON Web Token (JWT, see the glossary). It is scoped to one "trust domain": a group of systems that share a common set of security controls and policies.
Using it
A Txn-Token request is an RFC 8693 token exchange, with a different
requested_token_type, at the ordinary token endpoint. So client authentication,
revocation checking and session liveness are the ones that already work, rather
than a second implementation of each.
A request looks like this:
HTTPPOST /oauth2/tokenAuthorization: Basic <client credentials>grant_type=urn:ietf:params:oauth:grant-type:token-exchange&requested_token_type=urn:ietf:params:oauth:token-type:txn_token&audience=trust-domain.example&scope=openid profile&subject_token=<access token>&subject_token_type=urn:ietf:params:oauth:token-type:access_token&request_context={"req_ip":"203.0.113.9","authn":"pwd"}&request_details={"action":"BUY","ticker":"MSFT"}
Signari answers with the token in access_token:
JSON{"token_type": "N_A", "issued_token_type": "urn:ietf:params:oauth:token-type:txn_token", "access_token": "<JWT>"}
token_type: "N_A" is the draft's literal value, not a bug. A Txn-Token is not a
bearer token for an Authorization header, and saying "Bearer" would invite a
workload to use it as one.
Between workloads it travels in its own header:
TextTxn-Token: <JWT>
It is not Authorization, and the draft is explicit about that. Workloads use that
header for their own purposes. A proxy that rewrites it would lose the transaction
context.
What a token looks like
The token's header says what kind of token it is:
JSON{"typ": "txntoken+jwt", "alg": "ES256", "kid": "…"}
Its body carries the transaction:
JSON{"iss": "https://id.example", "aud": "trust-domain.example", "txn": "jr-WM28kjwYD7Nilq3FQB0V_Q8tpe8QfmERpyGPFBic", "sub": "551049cd-…", "req_wl": "tts-gateway", "scope": "openid profile", "tctx": {"action": "BUY", "ticker": "MSFT"}, "rctx": {"req_ip": "203.0.113.9", "authn": "pwd"}}
The rules for a chain
Each hop of a chain, such as gateway → orders, follows these rules:
txn never changes | It ties every hop to one transaction. A hop that could mint a new one would break the trail at that hop |
sub and aud never change | A replacement that could change the subject would be a privilege escalation |
tctx never changes | What is being done does not change from one service to the next |
req_wl does change | Each hop says who it is, taken from client authentication, never the request body. A workload that could name itself could name somebody else |
rctx does change | The environment legitimately differs per hop |
| Scope only narrows | A service asking for more authority than it was given is the attack this format exists to stop |
| A replacement never outlives its predecessor | Otherwise a chain extends its own life one hop at a time and a five-minute token becomes permanent across enough services |
Signari refuses these eight attacks, each with the error shown:
Texthop 2 widens scope back to profile invalid_scopehop 2 invents a scope never granted invalid_scopereplacement into a different trust domain invalid_targeta trust domain the client may not mint for invalid_targeta txn-token presented as an access token invalid_grantan access token presented as a txn-token invalid_grantinitial request asking beyond the access token invalid_scopea garbage subject token invalid_grant
The two type-confusion refusals come from the distinct typ. A resource server
that accepted at+jwt and txntoken+jwt interchangeably would let one be
presented as the other. They carry different authority, which is what RFC 8725's
explicit-typing rule is for.
Why an identity provider must issue these
A Txn-Token asserts who the subject is and what they were allowed to do. Only the party that authenticated them can make that statement reliably. A standalone service has to be told, and a token whose subject came from the request body proves nothing.
For example, once the person signs out, the same unexpired subject token is refused:
Textsession live ISSUEDafter the user signs out, same unexpired token refused: the session behind the subject token has ended
A standalone transaction token service cannot do that, because it does not know the person signed out. Every internal service would keep honouring a token minted from an ended session until it expired, and the internal services have no way to check either.
Configuration
An application needs may_exchange, and the trust domain in
exchange_audiences. signari client set-exchange sets both, with
-may-exchange and -exchange-audiences.
An empty audience list means none may be minted. An empty list is not permission for everything, so a forgotten configuration allows nothing.
Lifetime is 5 minutes by default, 15 maximum. It is short on purpose: a Txn-Token is minted for one transaction in flight. A token that outlived the transaction would be a bearer credential left on a network where every service can read it.
How Signari meets draft-11
Signari implements the text of draft-11 itself. Every claim §9.2 makes REQUIRED is in every Txn-Token Signari issues:
| §9.2 REQUIRED claim | emitted |
|---|---|
iat, exp, aud, txn, sub, scope, req_wl | all seven |
The other requirements hold like this:
- Under §9.1,
typistxntoken+jwt, andverifyTxnTokenrequires it. An access token presented as a Txn-Token is refused, which is the confusion the distincttypexists to prevent. - Under §9.2, a Txn-Token with no
expis malformed, and is refused. See a token with no expiry. - Under §11.2,
subject_token_typeis enumerated, not defaulted. A type Signari does not accept is refused, and is never read as an access token. Arefresh_tokenis refused by name: §11.2 excludes it, and §13.3 explains why. - The issuance rules of §11.3, and the
Txn-Tokenheader of §12.1, hold as the draft writes them. - Under §11.4,
token_typeis the literalN_A, andissued_token_typeis the txn_token URN.refresh_tokenis absent from the response struct, which has three fields. So §11.4's "MUST NOT include" cannot be violated by an edit. - Under §13.4, a Txn-Token never contains the presented access token. See the context claims.
- Under §13.6, requested scope ≤ the subject token's: enforced, and read from the verified token rather than the form. A caller cannot describe its own token as carrying anything, and thereby choose its own ceiling.
- Under §13.15, Signari maintains the Call Chain, which a TTS MUST do, in the
req_wl_chainclaim. - Under §13.15, the four rules on replacement all hold:
txn,subandaudare copied from the verified previous token, so they cannot be modified.- Scope may narrow but never widen.
- The call chain is appended from the previous token's history, not from anything the caller supplies.
- The trust domain cannot change mid-chain.
- Nothing is issued from a token that has expired.
VerifyAccessTokenAnychecks theexpof a presented access token, andverifyTxnTokentheexpof a Txn-Token being replaced.
Signari is stricter than the draft in one place. The draft's §6 and §13.15 both permit a Txn-Token to outlive the token it came from, "subject to the policy of the TTS". Signari caps it instead. A Txn-Token's expiry is clamped to that of the subject token, and a replacement's to that of its predecessor.
A chain that can extend its own life one hop at a time turns a five-minute token into a permanent one, across enough services. The draft's own "SHOULD limit the number of times a Txn-Token is replaced", in §13.15, exists because of that risk. Capping removes the risk rather than bounding it.
The Call Chain claim
The claim is req_wl_chain, an array of workload identifiers, oldest first,
including the current one. The draft's §13.15 leaves the mechanism out of scope,
and §9.2 permits additional claims.
It is set from the first token, rather than only from the first replacement. So a consumer never has to special-case hop one.
Across three workloads, the chain grows like this:
Texthop 1 gateway chain=[tts-gateway]hop 2 orders chain=[tts-gateway, tts-orders]hop 3 ledger chain=[tts-gateway, tts-orders, tts-ledger]
The chain is bounded at 32 hops. It is built from the previous token, never from the request, so a caller cannot write its own history.
It is also copied rather than appended in place. Otherwise one token replaced twice would have the two branches overwrite each other.
The context never carries the presented token
The draft says, in §13.4:
When creating Txn-Tokens, the Txn-Token MUST NOT contain the access token presented to the external endpoint. If an access token is included in a Txn-Token, an attacker may extract the access token from the Txn-Token, and replay it to any Resource Server that can accept that access token. Txn-Token expiry does not protect against this attack since the access token may remain valid even after the [Txn-Token has expired].
tctx and rctx are taken from the request body, as request_details and
request_context, and signed into the token. Suppose a workload puts its
incoming Authorization header into request_context: for tracing, for
debugging, or because it looked like useful context. It would embed a long-lived
bearer credential in a short-lived token, which is forwarded to every service
in the transaction. And the access token outlives the Txn-Token carrying it.
The requirement is written on the TTS, because the TTS is what creates the token.
So CheckContext refuses such a request with invalid_request, before anything
is minted.
The check is a substring match rather than equality. The realistic shape is
not {"token": "eyJ..."} but {"headers": {"authorization": "Bearer eyJ..."}}.
§13.4 is about the value being extractable, not about how it was framed. Nested
structures are covered, because the comparison is against the serialised JSON.
The two maps are also bounded: 8 KiB across both combined, not per map, since a
limit per map is doubled by splitting the payload across tctx and rctx.
Caller input inside something Signari signs deserves a limit anyway. This token
also rides an HTTP header on every hop. So its size is paid for repeatedly, by
every workload in the chain, rather than once by whoever sent it.
Each rule has a test that fails without it:
| Rule | Test |
|---|---|
| The context never contains the presented token | TestTheContextClaimsCannotCarryTheSubjectToken |
| The bound is on both maps together | TestTheContextClaimsAreBounded |
A token with no expiry is refused
§9.2 makes exp REQUIRED, so a Txn-Token without one is malformed, not one that
never expires. verifyTxnToken refuses it outright, and so does Replace, before
the clamp that stops a replacement outliving its predecessor. A check that ran
only when exp was present would let such a token verify, never expire, and be
replaced indefinitely, each hop with a fresh full lifetime. That is what §13.15's
"MUST NOT issue a new Txn-Token when the Txn-Token being replaced has expired"
forbids.
Nobody else can make such a token. A Txn-Token must be signed by Signari's own
key and carry typ=txntoken+jwt, and every path that mints one sets an expiry.
Replace keeps its own check because it is exported, and a future caller may not
verify first.
verifyTxnToken decides whether the token presented for replacement is real, so
every rule in §13.15 rests on it. These tests fail without the checks:
| Rule | Test |
|---|---|
verifyTxnToken refuses a Txn-Token with no exp | TestATransactionTokenWithoutAnExpiryIsRefused |
Replace refuses a predecessor with no exp | TestReplacingATokenWithNoExpiryIsRefused |
| A replacement never outlives its predecessor | TestAReplacementNeverOutlivesWhatItCameFrom |
Changed Signari v0.2