Repository navigation
fix(server)!: bind stored digests to the issuer, and namespace access-token revocation keys - #967
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
osanderson
force-pushed
the
fix/issuer-separated-keys
branch
2 times, most recently
from
November 25, 2026 12:37
811a9f4 to
3dc36f6
Compare
… issuer The digests an authorization code, a refresh token and a CIBA auth_req_id are stored under (NewAuthorizationCode.CodeHash, NewRefreshToken.TokenHash, NewBackchannelAuthentication.AuthReqIDHash) did not include the server's issuer. Two servers of different issuers sharing one store found each other's records, and the store spent a code or a CIBA approval, or reported a code reused and so revoked what it had issued, before the server refused the record as another issuer's. A client of one issuer could therefore burn a code or auth_req_id the other had issued. Each digest is now the SHA-256 of a domain-separation prefix, the length-prefixed issuer, the existing length-prefixed binding where there is one, and the value: - codes: "fapigo authorization code v2" (new prefix), issuer, instance key, PKCE challenge, redirect URI, DPoP key, code; - refresh tokens: "fapigo refresh token", issuer, token (was the plain SHA-256 of the token); - auth_req_ids: "fapigo auth_req_id v2" (new prefix), issuer, instance key, DPoP key, auth_req_id. An unbound request is no longer stored under the plain SHA-256 of its auth_req_id, so the crafted preimage that once shared a bound request's digest no longer does; malformed auth_req_ids are still refused before any poll. A value presented to a server of another issuer sharing the store is now unknown to the store, and neither found nor consumed. Stores are unaffected: memstore, sqlstore and custom stores key records by whatever digest the server passes. BREAKING CHANGE: every refresh token issued before the upgrade is unknown afterwards and refused, so clients must re-authorize to get a new one. Authorization codes and CIBA requests in flight at deploy fail once. No code changes are needed; plan the deploy around the forced re-authorization. UPGRADING.md has the details. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server now stores a refresh token under a digest of a prefix, its issuer and the token rather than the plain SHA-256 of the token. Two server-flow tests looked an issued refresh token up in the store under the plain digest, so their "the token is gone" checks passed whatever the store did. They now derive the server's digest, and the revoked-grant test first checks the token is found under it before revoking. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When an authorization code is reused, the server revoked the access token first issued from it under that token's own key alone: a JWT's jti, or an opaque token's hex SHA-256. That key carries no issuer, so with servers of different issuers sharing one revocation store, one issuer's revoked jti also refused another issuer's token with the same jti. The server now writes two revocation records for that token: the key namespaced by its issuer, "access-token:" then the issuer's length in bytes, ":", the issuer and the key (grantrevocation.AccessTokenKey), whose prefix keeps it apart from the "grant:" and "code-grant:" keys, and, during a transition, the raw key as before, so resource servers not yet upgraded and checkers that know only the raw form still refuse the token. The code record still stores the raw key (IssuedAccessTokenKey); both forms are derived from it at reuse, so records written by older servers revoke both forms too. Stored data: one more revocation record per reused code, under the new key form; nothing else changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Verify checked a token's own revocation key only in its raw form (a JWT's jti, an opaque token's hex hash). The server now also revokes a token under that key namespaced by its issuer, so a revocation one issuer records for a jti doesn't refuse another issuer's token sharing the store. Verify now asks about the namespaced key first, when the resolver reports the token's issuer, then the raw key, so a revocation an older server wrote still refuses the token. Both go in the same IsAnyRevoked batch for a store that has it (six keys at most now). A resolver reporting no issuer is checked under the raw key alone. The RevocationChecker docs describe both forms and that the raw one will be dropped in a later release, and UPGRADING.md says what a custom sink or checker must accept. Stored data: none; this only adds a lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Covers the issuer in the authorization code, refresh token and auth_req_id digests, the issuer-namespaced and raw access token revocation keys the server writes on code reuse and the resource server checks (one at a time and in a batch), and the length prefix that splits a namespaced key one way only. Re-anchors the existing srv-code-reuse-audit-access-token-failure mutant on the reuse revocation loop that replaced the single Revoke call it targeted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The revoked-grant and registry race tests looked an issued refresh token up under the issuer-bound digest only. sqlstore's tests also run against the fapigo release its go.mod requires, which still stores the plain SHA-256, so there the setup check failed. They now look a token up under both digests, newest first, so they hold against either release; the setup check still requires the token to be found before its removal is checked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They ship in the release after 0.84.0: the namespaced revocation key joins the issuer-bound digests under their own heading. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
osanderson
force-pushed
the
fix/issuer-separated-keys
branch
from
November 25, 2026 13:39
3dc36f6 to
26a1b16
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Breaking. This makes two decided changes to stored keys, from the audit's defence-in-depth list (G.3; coverage gap F-15). Two authorization servers that share a store can no longer burn each other's codes, refresh tokens or
auth_req_ids. A token revoked by one issuer is now recorded under a key naming that issuer.fix(server)!: digests bound to the issuerThe keys that authorization codes, refresh tokens and CIBA
auth_req_ids are stored under didn't include the server's issuer. A token presented to another issuer sharing the store was found, and spent, beforeownsRecordrefused it.Each digest is now the SHA-256 of these parts, in order:
Specifically:
fapigo authorization code v2, followed by the issuer, instance key, PKCE challenge, redirect URI, DPoP key and the code.fapigo refresh token, followed by the issuer and the token. This was a plain SHA-256.auth_req_ids:fapigo auth_req_id v2, followed by the issuer, instance key, DPoP key and theauth_req_id. Unbound requests are no longer stored under a plain SHA-256.Code-grant IDs, CIBA grant IDs and grant-registry keys derive from these digests, so they change for new records too.
What breaks on upgrade. UPGRADING.md has a section under v0.85.0, the release this ships in.
invalid_grant), so users must authorize again.No code changes are needed; plan the deploy around the forced re-authorization. memstore and sqlstore key records by whatever the server passes, so they need no change. Two sqlstore tests that looked tokens up by the plain hash, which made their checks pass vacuously, are fixed in a separate
test(sqlstore)commit.fix(server)andfix(resource): issuer-namespaced revocation keys (dual write)grantrevocation.AccessTokenKey(issuer, key)givesaccess-token:followed by the length-prefixed issuer and the key. The length prefix is there because an issuer path may contain@, so thegrant:keys'@separator can't be used here. These keys can't collide with thegrant:orcode-grant:keys.IssuedAccessTokenKey, so records written by older servers revoke both too.resource.Verifychecks the namespaced key first, when the resolver reports an issuer, then the raw one, both singly and in theIsAnyRevokedbatch. Older resource servers still find the raw key.RevocationChecker,RevocationSinkand related docs describe both forms, and say the raw form will be dropped in a later release. UPGRADING.md has a note under v0.85.0 for custom sinks or checkers that restrict a key's shape or length.Conformance: running, since an upgraded server rejects pre-upgrade codes, refresh tokens and
auth_req_ids.Tests
auth_req_idaren't found, while the owning issuer still completes each flow.srv-code-digest-redirect-uriis still killed too.🤖 Generated with Claude Code