Skip to content

test(contract): add the §10.1 rule-8 guardrail regression tests - #43

Merged
ilpanich merged 1 commit into
mainfrom
claude/rule8-guardrail-tests
Aug 4, 2026
Merged

test(contract): add the §10.1 rule-8 guardrail regression tests#43
ilpanich merged 1 commit into
mainfrom
claude/rule8-guardrail-tests

Conversation

@ilpanich

@ilpanich ilpanich commented Aug 4, 2026

Copy link
Copy Markdown
Owner

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.

The AxiamUser extractor is structurally safe: it resolves exactly one thing from app_data — a JwksVerifier — and decides on the token it pulled off the request.

The Actix-specific risk worth pinning

app_data is a type-keyed bag, and a production app will very plausibly register its AxiamClient there too for its own outbound calls. That puts a second credential within reach of the extractor even though it is structurally safe today. These tests register exactly that and assert the extractor ignores it.

Tests (3)

  • rule8_rejects_a_failed_caller_token_with_an_app_session_in_app_data — an app-owned credential (genuinely valid, so a substitution would succeed) sits in app_data alongside the verifier. The caller's expired token must still be refused, and the rejection must not surface the app's principal.
  • rule8_the_extractor_consults_only_the_credential_on_the_request — the positive half: with both present, the injected identity is the caller's. A guard that preferred the ambient credential would pass the negative test while still being wrong.
  • rule8_a_missing_verifier_fails_closed_rather_than_falling_back — with no verifier registered, the extractor must fail rather than look around app_data for something else that could authenticate the request.

Falsified: injecting the SEC-085 fallback into middleware/actix.rs fails test 1 with "a caller whose token failed verification was admitted as …".

Verified locally: cargo test --test actix_extractor_test --features actix — 21 passed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SkTHvZQMV47t3UwkEtmB1D


Generated by Claude Code

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
@ilpanich
ilpanich merged commit 7e7b7b8 into main Aug 4, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants