test(contract): add the §10.1 rule-8 guardrail regression tests - #29
Merged
Conversation
CONTRACT.md §10.1 rule 8 — "subject of the decision" — was the one part of the local-verification set with no regression test outside PHP, TypeScript and Python. §15.1 hand-verified that every guard rejects correctly, so this closes a missing guardrail rather than a live defect. Rules 1-7 ask whether the token is good. Rule 8 asks whether it is the token the decision is even about. SEC-085 satisfied all seven and was still an authentication bypass: the PHP guard routed a failed verification into a second, successful one against the application's own session, admitting the caller as the app's service account. Each test asserts its precondition rather than assuming it: a second, fully valid credential for a more privileged principal is first shown to pass the same guard, so a fallback would genuinely have succeeded. Without that, the tests would pass merely because nothing was available to substitute — the trap the PHP reference test documents at length. Every test was falsified by injecting the SEC-085 fallback into the guard and confirming it fails. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SkTHvZQMV47t3UwkEtmB1D
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.
Adds the CONTRACT.md §10.1 rule-8 guardrail regression tests — the one part of the local-verification set with no test outside PHP, TypeScript and Python.
The rule
Rules 1-7 ask whether the token is good. Rule 8 asks whether it is the token the decision is even about. SEC-085 satisfied all seven and was still an authentication bypass: the PHP guard routed a failed verification into a second, successful one against the application's own session, admitting the caller as the app's service account.
This SDK is structurally safe from that shape —
Middlewaretakes a verifier and a configured tenant, never a logged-in client — so these tests pin the property rather than fix a defect. §15.1 hand-verified every guard already rejects correctly; this closes a missing guardrail.Tests (3)
Rule8_GuardDecidesOnTheCallerTokenAndNoOther— arecordingVerifierwraps the real verifier (deliberately not a stub that always fails), so a fallback would genuinely succeed. Asserts exactly one credential was consulted and it was the caller's expired token, and that the healthy token was never seen.Rule8_NoIdentityIsInjectedOnRejection— the consequence that made SEC-085 a bypass rather than a mere error: the request continued carrying an identity.UserFromContextmust be empty.Rule8_GuardInputExposesNoSecondCredential— reflects over thejwksVerifierinterface (exactly one method,VerifyAccessToken) and theMiddlewaresignature, failing if anything session-shaped ever appears. Keeps the property from being quietly undone by widening the interface later.Falsified: injecting the SEC-085 fallback into
nethttp.gofails test 1 with "the guard admitted a caller whose token failed verification".Verified locally:
go test ./...green.🤖 Generated with Claude Code
https://claude.ai/code/session_01SkTHvZQMV47t3UwkEtmB1D
Generated by Claude Code