Repository navigation
feat(fapitest): add an embedder-style login UI, and follow nested types in the key-material guard - #1000
Merged
Conversation
TestKeyHolderMatrixCoversEveryKeyField only looked at a field's own type, so a field reaching key material through a struct it points to went unseen: the federation issuers' deps field, a pointer to a Dependencies struct holding the Signer, was not flagged, although its rendering is what printed an Ed25519 key before the issuers gained their redacting Format methods. The guard now indexes the named types the guarded packages and internal/ declare and counts a field as holding key material when its type, through pointers, slices, arrays, map values, channels, generic type arguments, inline structs and those named types, reaches a field that holds it directly. Cycles end at a type already being resolved, and only an outermost negative result is memoized, so a cycle cut short cannot hide a holder found later. Such a field must be covered by a keyHolders case rendering the value that holds it, like a direct one. The newly flagged fields are covered: the issuers' deps (and the shadows their Format methods print), the signer and ephemeral key managers' maps, the client sealers' keyrings, and new cases for a KeyManager built with DeclareCustody and for the interactioncookie and sessioncookie Cookies' jars. None of them prints its key. TestKeyMaterialIndexFollowsNestedTypes checks the detection itself on a synthetic package. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The harness's authorization endpoint approves every interaction at once, so a test of what an embedding application's UI does with the interaction had to build that UI by hand. Harness.EmbedderUI returns an http.Handler in front of the harness's server: a sign-in that sets the UI's own session cookie, an authorization endpoint that keeps the interaction in a cookie server/interactioncookie seals and renders a consent page carrying its tag, and a consent submission that completes the interaction for the signed-in subject, granting what it requested, and answers 303 to the client's redirect URI. A submission without a session the UI issued is refused. Its POSTs refuse cross-origin requests and its pages carry server.AuthorizationPageHeaders. It uses only the server's and interactioncookie's public API, so an embedder can follow the pattern. EmbedderUIOptions.OnInteraction hands a test each interaction begun, as a leaked log line would, and UnsafeRawHandleCookie, for negative tests only, keeps the raw handle in a plain cookie instead. The UI holds its interaction cookie's key, so the key-material matrix gains a case rendering one, and the redaction guard classifies the two new types. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The leak tests built their own embedder, with a plain-cookie and a sealed-cookie bridge. They now use Harness.EmbedderUI, with UnsafeRawHandleCookie for the plain cookie and OnInteraction for the leaked handle, and sign the victim and the attacker in through its sign-in. The scenarios and assertions are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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.



Two test-infrastructure follow-ups from the audit work. Only
fapitestand the mutants file change, and nothing on the wire changes.test: the key-material guard follows nested typesThe guard in
fapitest/key_rendering_guard_test.goflagged only fields that hold a key directly. #986 showed the gap: the federation issuers printed an Ed25519 key through their unexporteddepsfield, a struct holding aSigner, and the guard didn't see it.What the guard does now:
internal/.Fields it newly flagged, all now covered, none of them leaking:
depsand their shadows'Dependencies;keys.signerKeyManager.backends, andcustodyKeyManager, which gets a new case;ephemeral.KeyManager.keysand.decryption;keys;interactioncookieandsessioncookiejars, which get a new case;EmbedderUI.sealed.Checks:
TestKeyMaterialIndexFollowsNestedTypesruns the detection on a small made-up package, including a cycle.keys.KeyManager, still can't be followed.feat(fapitest):Harness.EmbedderUI, a model login and consent UI(*Harness).EmbedderUI(EmbedderUIOptions)returns anhttp.Handlerthat serves an embedder-style UI over the harness's server, using only public APIs so an embedder can copy the pattern.What it serves:
BeginAuthorization, seals the interaction withinteractioncookie, and renders a consent page.Defences on every page: the POSTs refuse cross-origin requests, and the pages carry
server.AuthorizationPageHeaders.The unsafe mode: keeping the raw handle in a plain cookie is reachable only through the explicit
UnsafeRawHandleCookieoption, and is meant for negative tests. The E-3 leak tests from #989 now use the helper, with their scenarios and assertions unchanged. #989's check still holds: with the cookie jar's AEAD check falling back to plaintext, the sealed-cookie test fails.Tests of the helper:
Checks
🤖 Generated with Claude Code