Skip to content

Design: exchange between Issuers

Status: implemented as an experimental option. The protocol contract specifies the behavior, and the deployment guide shows how to run it. This page keeps the rationale behind the design's choices.

Summary

An Issuer can accept a token from another Issuer that it trusts, in place of an admission code. The receiving Issuer, called B here, checks the token with the source Issuer's public key, records it as spent, and issues its own token, batch, or credit credential. Origins keep trusting exactly one Issuer and see only that Issuer's tokens.

Exchange lets small communities keep their own admission policies while sharing a large anonymity set. It also lets specialized admission services, such as a personhood check, a payment service, or a voter registry, feed many application Issuers. It lets users move between Issuers without new invitations. Concepts and vocabulary defines the terms used here.

Why exchange instead of Origins that trust several Issuers

RFC 9577 allows an Origin to offer several challenges, one per Issuer. RFC 9576 Section 6.2 warns that each Issuer whose tokens a Client holds leaks about a bit of information to the Origin, so privacy loss grows exponentially with the number of Issuers. It recommends that Clients bound their active issuance configurations. If each small community ran its own Issuer and Origins accepted all of them, every redemption would reveal the user's community.

With exchange, only B learns which source Issuer a user came from, and only at exchange time. Origins that trust B see one anonymity set: everyone who holds B's tokens. The reverse-flow draft describes the same loop in its Section 2.3: an Issuer may require a token from elsewhere before issuing its own. Freebird's standing tokens already use that path.

Letting one Origin trust several Issuers is not planned unless an application needs several large, equivalent Issuers. Running one Issuer on several hosts for availability is a separate problem that this design does not address.

An exchange step by step

Client                          Issuer B                    Issuer A (source)
  |  1. GET /freebird/exchange/a -->|                               |
  |<-- 401 + challenge naming A ----|                               |
  |     as issuer and B as origin   |                               |
  |                                 |                               |
  |  2. blinded request + A admission ----------------------------->|
  |<----------------------------------------------- blind signature |
  |     (unblind into an A token bound to B's challenge)            |
  |                                 |                               |
  |  3. blinded request + A token ->|                               |
  |                                 | check A token with A's key,   |
  |                                 | record it as spent            |
  |<------------ B blind signature -|                               |
  1. Challenge. The client asks B for the exchange challenge of source a. B answers 401 with an RFC 9577 challenge whose issuer_name is A's name, whose origin_info is B's name, and whose token-key is A's current public key.
  2. Source token. The client obtains an A token for that challenge in the usual way, spending whatever admission A requires. The challenge is hidden inside the blinded request, so A does not learn that the token will be exchanged at B.
  3. Exchange. The client sends B a blinded token request, with the A token in Authorization: PrivateToken token="…" instead of a Freebird-Admission code. B checks the token, records the spend, and signs. The client unblinds B's signature into an ordinary B token.

Sources are managed like applications

A new store, exchange.sqlite in B's state directory, holds the trusted sources, their followed keys, spend records, daily usage, and the history of the published trust list. init-issuer-exchange creates the store, and the config switch exchange = true serves the exchange routes, following the pattern of app admission. The config file stays flat, so sources live in the store and are managed with commands. Each command uses the control socket while B serves and opens the store directly while B is stopped:

exchange-add <issuer-state-dir> <name> <source-issuer-name> <directory-url> <daily-cap> \
  [--ca <pem>] [--rate <n>] [--output ordinary|scoped:<scope>|credit] [--cutoff <unix>] [--notice-hours <n>]
exchange-set <issuer-state-dir> <name> [--cap <n>] [--rate <n>] [--output …] [--cutoff <unix>]
exchange-remove <issuer-state-dir> <name>
exchange-list <issuer-state-dir>

Each source has these settings:

Setting Meaning
Name 1–64 lowercase letters, digits, and -, as for applications. It appears in the challenge URL.
Source issuer name and directory URL Where B reads the source's RFC 9578 directory, over HTTPS with Web PKI roots or one configured CA.
Daily cap The most exchanges B accepts from this source per UTC day. It bounds the damage if the source is compromised or dishonest.
Rate How many tokens one exchanged token buys, from 1 up to batch_size. The default is 1.
Output What an exchange produces: ordinary tokens, one scoped:<scope> token (needs public_metadata), or one credit credential (needs credit_amount). The default is ordinary.
Key cutoff Optional. B accepts only source keys that started signing before this Unix time.
Notice hours How much notice a new source key needs before B installs it. The default is key_notice_hours. A source that does not announce keys ahead of time can be given 0, as described below.

exchange-add reads the source's directory, prints the source's current key ID, and installs that key, as setup-origin does. The operator confirms the key ID with the source's operator. Each exchange-add also draws a random 32-byte source epoch, which enters the exchange challenge, so that removing and re-adding a source invalidates every token obtained for the old challenge. exchange-remove stops accepting the source immediately.

B follows each source's keys

B runs one key follower per source, with the same code and rules as a following Origin. It reads the source's directory at startup and every five minutes. It installs an announced type-2 key whose not-before is at least the source's notice hours away, holds at most one pending key, and retires a superseded key 420 seconds after its successor starts. It logs each change with the prefix exchange follower:. A failed fetch or a malformed directory changes nothing.

Issuers outside Freebird, such as the Private Access Token Issuers, may replace their keys without announcing them ahead of time. A follower with any notice would never install their new keys, so the operator can give such a source 0 notice hours. B then installs the key that the source's directory lists as current as soon as it sees it, logs the installation, and publishes the source's notice hours in the trust list. When a client presents a token from a key that B does not know, from a source with 0 notice hours, B rereads that source's directory at once, at most once a minute per source, so that a rotation does not stall exchanges until the next five-minute check.

Whoever can serve a source's directory can add a key that B accepts. The notice period, the one-pending-key rule, logging, the key cutoff, and the daily cap limit the effect of a takeover, but they do not prevent it. With 0 notice hours, a takeover of the source's directory, through its TLS certificate or DNS, gets a key accepted at once, so only the daily cap and the rate limit the damage until someone notices.

The exchange challenge

GET /freebird/exchange/<name> returns 401 with WWW-Authenticate: PrivateToken challenge="…", token-key="…", naming the source's current key. An unknown or removed source returns 404. The challenge is an RFC 9578 type-2 TokenChallenge:

  • issuer_name is the source's issuer name.
  • origin_info is B's own issuer name.
  • redemption_context is HMAC-SHA256(admission generation, "freebird-exchange-v1" || source epoch || uint8(len(name)) || name).

The challenge is fixed for each source. It has no hourly component, so every client sees the same challenge for a source, and the header carries no max-age. A client can obtain a source token long before it exchanges it, so the time when the source issued the token no longer has to be close to the time when B exchanges it, which weakens timing correlation. A source token stays exchangeable for as long as B accepts its key: until 420 seconds after the key's successor starts, when B's follower retires the key. Source tokens are therefore longer-lived bearer secrets, and clients must keep them as private as admission codes.

POST /freebird/exchange/<name> serves browsers that obtain the source token themselves. It takes an ordinary issuance body and answers 401 with the same challenge when the request carries no source token. When the browser retries the identical request with a token, B exchanges it for the blinded request in the body, with only the named source's keys eligible. B checks the body before answering 401, so a browser never spends a source token on a request that cannot succeed.

Deriving the context from the admission generation means that admission recovery invalidates every outstanding exchange challenge. The source epoch means that removing and re-adding a source does the same for that source. Because the route only computes a header from stored state and writes nothing, render-nginx serves it without a rate limit, like the standing-token route.

B checks a source token before signing

At POST /private-token/issue, a request without Freebird-Admission may carry a type-2 token in Authorization. Standing tokens use the same header with type 0xDA7A, so the token type tells the two apart. B processes the request in this order:

  1. Parse the request body. A malformed body returns 422 and spends nothing. A body that does not match the source's output kind returns 400 and spends nothing. For example, a credential request to a source whose output is ordinary is refused.
  2. Find the source. B looks up the token's key ID among the keys that it follows. An unknown key, a removed source, or a key that started after the source's cutoff returns 403.
  3. Check the token. B reconstructs the source's fixed exchange challenge and verifies the signature with the source's key. Any mismatch returns 403.
  4. Record the spend. In one durable transaction, B checks the source's daily cap, records the spend under the key ID, challenge digest, and nonce, and counts the exchange. A replayed token returns 403. A reached cap returns 429 with Retry-After set to the next UTC midnight.
  5. Sign. B signs only after the commit. A lost response spends the source token, as a lost response spends an admission code.

B keeps a spend record until it retires the source key that signed the token, plus 120 seconds, and then prunes it. Records therefore grow with each source's daily cap times the number of days its key stays current.

Outputs and rates

  • ordinary buys up to rate type-2 tokens in one generic batch. A rate above 1 needs batch_size of at least that rate. Clients should request exactly rate tokens.
  • scoped:<scope> buys one scoped token for that scope. With max_token_lifetime_hours, its expiry follows the default rule for app admission codes, unless the operator sets a fixed expiry with --expires <unix>. A fixed expiry follows the app-admission rules: it falls on a whole hour, between one hour and max_token_lifetime_hours ahead at the time of the exchange. Outside that window, B refuses the exchange without spending the source token. Every admission path for one scope, whether app codes, puzzles, or exchange, should use the same expiry, so that the expiry does not split the scope's users.
  • credit buys one credential holding credit_amount credits.

Different rates per source let B treat partners differently, for example 5 tokens per exchange for an established partner and 1 for a new one. The tokens that B issues are identical whatever their source, so the rate and output are visible only to B.

Key cutoffs support migration and recovery

A source's key cutoff makes B accept only keys that started signing before a given time. B refuses to install a later key, and it refuses tokens from any later key that it already holds. Two situations use it:

  • Migration. When an Issuer shuts down or a community moves, the new Issuer adds the old one as a source with a cutoff at the shutdown time. Users carry their standing over without new invitations.
  • Recovery after a key compromise. The cutoff is set to before the compromise, so tokens from keys that an attacker may have planted are refused.

B takes each key's start time from the best evidence that it has, in this order:

  1. The source's published key history, which every Freebird Issuer serves.
  2. The key's not-before time in the source's directory, when B saw the key announced ahead of time.
  3. The time when B first saw the key.

The rule fails closed: a key that B cannot place before the cutoff is refused. Migration therefore needs a source that publishes a key history, and exchange-add and exchange-set warn when a source with a cutoff publishes none.

The trust list is published and hash-chained

B publishes its sources at GET /freebird/exchange-sources, so that users and auditors can see which Issuers it trusts and on what terms:

{
  "format": "freebird-exchange-sources-v1",
  "issuer-name": "b.example",
  "versions": [
    {
      "version": 1,
      "sources": [
        {"name": "a", "issuer-name": "a.example", "directory": "https://a.example/.well-known/private-token-issuer-directory",
         "rate": 1, "output": "ordinary", "expires": null, "cutoff": null, "notice-hours": 1,
         "token-keys": ["<key ID>"]}
      ],
      "chain": "<hex>"
    }
  ],
  "head": "<hex>"
}

Every exchange-add, exchange-set, exchange-remove, and source key change appends a version. The chain works like the key history's: chain_0 = SHA-256("freebird-exchange-sources-v1\0" || u16(len(name)) || name || E_0) and chain_i = SHA-256(chain_{i-1} || E_i), where E_i is the canonical encoding of version i. The list publishes everything that affects users' tokens or anonymity. It does not publish daily caps: they describe business volume, do not affect anonymity, and would tell an attacker the exact damage budget of a compromised partner. render-nginx serves the route like the key history.

Anyone who saves a head can check that a later list extends it. As with the key history, the chain cannot stop B from showing different lists to different readers. Readers who compare heads detect that. Operators can record each head with a public timestamping service or transparency log, so that the receipts give independent, timestamped evidence of which list B published when. RFC 9576 and the reverse-flow draft (Section 6.1) both recommend this kind of consistency check.

Recovery, rotation, and backups

  • Admission recovery rotates the admission generation, which invalidates every outstanding exchange challenge, and clears exchange spend records. Like app keys, every source is disabled so that a restored store cannot bring back a removed source. The operator re-adds sources after recovery.
  • B's own key rotation is unaffected. Source keys change only through the followers.
  • Backups and the recovery catalog include exchange.sqlite.

What each party learns

Party Learns Does not learn
Source Issuer A That someone obtained an A token, and when. That the token was exchanged, or where. The challenge is hidden in the blinded request.
Issuer B Which source each exchange came from, when, and from which network address through nginx. The user's identity at A, or where B's tokens are later spent.
Origins that trust B That a valid B token arrived. Which source, if any, the user came through.

Timing can still link the steps. A client that obtains an A token and exchanges it within a second is easy to correlate for anyone who sees both A and B, especially one operator who runs both. Because the exchange challenge is fixed, a client can obtain its source token well before the exchange, which weakens that link.

Security properties and limits

  • B trusts each source's admission policy. A compromised or dishonest source can obtain up to its daily cap times its rate in B tokens per day.
  • Trust is non-transitive in configuration but transitive in effect. If B trusts A and A accepts tokens from C, then C's users can reach B in two exchanges. Each step is a separate operator's decision, and per-source caps bound each one.
  • Cycles can amplify tokens. If A and B trust each other with rates whose product exceeds 1, a user can turn one token into more by exchanging around the cycle, limited only by the daily caps. When an operator gives a source a rate above 1 and that source publishes a Freebird trust list, exchange-add and exchange-set read the list. If it includes B with a rate whose product with B's rate exceeds 1, they refuse unless the operator passes --allow-amplification. Each later refresh of that list logs a warning instead of disabling the source. Longer cycles are not detected, because a complete check would have to crawl every partner's list, and sources outside Freebird publish none. The daily caps bound them.
  • B makes outbound HTTPS requests to each source's directory. The independent review must cover this client, as it covers the Origin's. A systemd drop-in permits the Issuer's outbound connections, as the remote-Issuer drop-in does for the Origin.
  • Exchange is not availability. Origins still depend on B being up.

Interaction with other features

  • Batches: a rate above 1 uses the generic batch format.
  • App admission and proof-of-work: unchanged. Exchange is one more way to admit a client, and it does not charge any application's daily cap.
  • Reverse flow and standing tokens: B's tokens behave the same whatever their admission. A standing-token output is out of scope for the first version.
  • Credits: the credit output buys a credential. Credit tokens cannot be a source, because only their own Issuer can verify them.
  • Scoped source tokens: out of scope for the first version. Sources must issue type-2 tokens.

SDK additions

  • Browser package: an exchange: { name, source: { issuer, admission | standing }, expires? } option, accepted wherever admission and standing are, makes B's tokens come from an exchange. B's tokens must be bound to an Origin's challenge for B, so exchange is an admission method rather than a separate call. The client fetches B's exchange challenge, checks that it names the source and a key from the source's directory, obtains the source token with the source admission, and presents it at B.
  • Server package: fetchTrustList and verifyTrustList({ issuerName, previousHead }) check the published trust list, as fetchKeyHistory and verifyKeyHistory do for key history.

Accepting tokens from public Issuers

Apple's Private Access Tokens are type-2 tokens. If B accepts a Private Access Token Issuer as a source, Safari users can be admitted through Apple's device attestation, with no puzzle or invitation. Research in November 2026 found this technically plausible but not ready to plan around:

  • The protocol allows it. RFC 9578 Section 6 says any Origin can choose a publicly verifiable Issuer and verify its tokens with the public key, without the Issuer's permission. Apple's WWDC22 session specifies type 0x0002 and names the challenge's issuer by hostname.
  • The public Issuers are for testing. Apple names Cloudflare (demo-pat.issuer.cloudflare.com) and Fastly (demo-issuer.private-access-tokens.fastly.com) as test Issuers. Their directories use the older path /.well-known/token-issuer-directory, and their format must be checked against RFC 9578. Cloudflare's production Issuers are managed engagements, and Fastly describes its public endpoint as for development only. New Private Access Token Issuers register with Apple, so a Freebird Issuer cannot become one on its own.
  • Safari's behavior shapes it. Safari and apps that use URLSession answer challenges automatically, with the user signed in to an Apple ID and Automatic Verification on (the default). A failure leaves the original 401. Apple publishes no rate limits and does not promise to answer every challenge.
  • Cloudflare's research Issuer is also verifiable. pp-issuer-public.research.cloudflare.com publishes an RFC 9578 directory with a type-2 key. Clients obtain its tokens through an attestation step such as Turnstile or the Silk browser extension. Cloudflare calls it experimental.
  • No published terms forbid exchanging these tokens, but that is not permission. Confirm with each Issuer's operator before relying on it.

A live test with Safari

In December 2026, Safari 27.2 on macOS 27.2.1 was tested on a MacBook Air against Cloudflare's test Issuer, with pages and Issuers on loopback (localhost and 127.0.0.1) over plain HTTP:

Case Safari's answer
Top-level navigation, origin_info equal to the request's host Token
origin_info empty Token
origin_info naming another host No token
origin_info with the request's port appended No token
Same-origin fetch() Token
Cross-origin fetch() to the challenging host, after a CORS preflight Token
POST with a body Token on a retry with the identical body

Every token verified against Cloudflare's key and was bound to the served challenge. Freebird's own exchange-add read Cloudflare's directory, including its relative issuer-request-uri, and installed its key with 0 notice hours. A token that Safari produced for a real Freebird exchange challenge, captured by a test page, was exchanged at that Issuer (200), and the resulting token was redeemed at its Origin (200), with the replay refused (401) and a second exchange of the same Safari token refused (403).

Three consequences follow:

  • The challenge must come from the host that its origin_info names. Freebird's exchange challenge names this Issuer, so a page must fetch it from the Issuer's own host, which the existing route already does. Serving it from the Origin's host is unnecessary.
  • The Issuer's name must not include a port, because Safari compares origin_info with the host alone.
  • Safari attaches the token only to its own retry, which scripts cannot read. The request that receives the 401 must therefore complete the exchange itself, which the GET challenge route cannot do.

The test did not cover iOS, real cross-site domains, or Apple's rate limits.

Safari completes an exchange on the POST route

POST /freebird/exchange/<name> closes that gap, and the browser package's exchange: { name, native: true } option uses it. A second test with the same setup, against the same Cloudflare source, had a page post a blinded request to the route, once from the same origin and once across origins (another port on localhost, with the CORS headers that Freebird sends for a configured origin). In both cases Safari received the 401, retried the identical request with a Private Access Token, and the page read B's 200 response; across origins, one preflight covered both requests. The finalized token was redeemed at B's Origin (200) and its replay refused (401); a second exchange of the same Safari token was refused (403).

The browser package's native path was tested outside Safari, through nginx TLS, with a fetch that plays the browser's part. Running it in Safari needs an HTTPS Issuer whose name has no port.

Acceptance criteria

The implementation meets these criteria:

  1. init-issuer-exchange and exchange = true create and serve the routes. The Issuer refuses to start if the switch is on and the store is missing or invalid.
  2. exchange-add, exchange-set, exchange-remove, and exchange-list work offline and over the control socket. Removal takes effect immediately.
  3. A follower per source installs and retires keys under the notice, one-pending-key, and cutoff rules, takes start times from the best evidence, and logs each change. A source with 0 notice hours installs a new current key at once, and an unknown key from it triggers a directory reread at most once a minute.
  4. GET /freebird/exchange/<name> returns the source's fixed challenge, derived from the admission generation and the source epoch, which the pinned @cloudflare/privacypass-ts client can satisfy against a live source Issuer. Re-adding a source invalidates tokens for its old challenge. POST to the same route answers 401 with that challenge and exchanges a token on the retry.
  5. Issuance accepts a valid source token in place of admission. It refuses a malformed body, a mismatched output kind, an unknown or cut-off key, a wrong challenge, a replay, and a reached cap with the statuses above, and it spends nothing before the request is valid.
  6. Rates, outputs (including a fixed scoped expiry and its window), caps, and the direct-pair amplification check are enforced. Spend records last until the source key's retirement plus 120 seconds. Tests cover concurrent exchanges of the same token, a crash before commit, and a commit failure.
  7. Admission recovery invalidates outstanding exchange challenges and disables every source. The recovery catalog covers the exchange store.
  8. /freebird/exchange-sources publishes a hash-chained trust list without daily caps, and the server package verifies it, including prefix continuity.
  9. The browser and server packages provide the SDK additions above, with tests.
  10. A live drill runs two Freebird Issuers through nginx TLS. It exchanges A tokens at B, redeems the B tokens at an Origin that trusts only B, and checks the refusal cases.
  11. render-nginx serves /freebird/exchange/ (for GET and POST) and /freebird/exchange-sources without a rate limit, and a systemd drop-in permits the Issuer's outbound connections to source directories.
  12. The protocol contract, concepts page, security policy (including the review scope for the new HTTPS client), roadmap, and deployment guide describe the feature.