fix(trust): enforce §3 invariant 3 — ignore X-Trust-Level from non-loopback callers#107
Closed
hyperpolymath wants to merge 1 commit into
Closed
fix(trust): enforce §3 invariant 3 — ignore X-Trust-Level from non-loopback callers#107hyperpolymath wants to merge 1 commit into
hyperpolymath wants to merge 1 commit into
Conversation
…opback callers
`BojRest.TrustPolicy.satisfies?/3` previously accepted `X-Trust-Level:
authenticated|internal` from any caller, leaving §3 invariant 3 of the
http-capability-gateway contract unenforced at the BoJ side. Adds a clause
between `:public` and `:authenticated` that rejects every non-loopback
non-`:public` request regardless of header value:
def satisfies?(_required, _trust, false), do: false
This is the BoJ-side half of the defence-in-depth pair whose gateway-side
half landed in http-capability-gateway#11. §4 (back-side bind isolation)
still defends in depth in practice.
Test updates
------------
* `phase_c_seam_test.exs` — 5 previously `@tag skip:` tests now live and
passing (4 router-level + 1 function-level §3 invariant assertions).
* `trust_policy_test.exs:52` — pre-existing test asserted the leak; flipped
to refute, plus a companion test for the loopback-honours path.
* `router_test.exs:404,417` — pre-existing tests asserted the leak via
`assert conn.status in [200, 500]`; flipped to `assert conn.status == 403`
with the §3-conformant body assertions.
Verification
------------
* §3-specific suites (`phase_c_seam_test` + `trust_policy_test`): 20/20.
* Full `mix test`: 184/186 (2 pre-existing failures in `catalog_test`/
`catalog_properties_test` re: `qdrant-mcp`/`whisper-mcp` having
`auth.method` values `api_key`/`optional_api_key` not in the schema's
known set — confirmed red on clean main; baseline rot, unrelated).
Refs hyperpolymath/standards#98 (Phase C close-out).
Refs hyperpolymath/standards#91 (HCG tier-2 channel).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
Superseded by #106 (parallel session landed the equivalent fix earlier today, merged at 08:02Z). Verified identical: same one-line clause |
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.
Summary
def satisfies?(_required, _trust, false), do: falsetoBojRest.TrustPolicy.satisfies?/3— the BoJ-side enforcement of http-capability-gateway contract §3 invariant 3.phase_c_seam_test.exstests to live (they pass unchanged as the comment promised); updates 3 pre-existing tests that asserted the leak (trust_policy_test.exs:52,router_test.exs:404/417) to assert the §3-conformant behavior.Test plan
mix test test/phase_c_seam_test.exs test/trust_policy_test.exs— 20/20 green (the 4 new live §3 router tests, the 1 new live §3 function-level test, plus the unchanged positive controls and pre-existing TrustPolicy unit tests).mix test— 184/186. Two pre-existing failures (catalog_test/catalog_properties_testflaggingqdrant-mcpandwhisper-mcpauth.methodvaluesapi_key/optional_api_keynot in the schema's known set) confirmed red on clean main; baseline rot, unrelated to §3. Should be tracked separately if not already.Why these three pre-existing tests had to flip
trust_policy_test.exs:52androuter_test.exs:404,417literally asserted the §3 leak (non-loopback caller withX-Trust-Level: authenticated|internalallowed through). They were written before the §3 finding surfaced; the §3 fix necessarily inverts their expected outcome.Refs hyperpolymath/standards#98 (Phase C close-out).
Refs hyperpolymath/standards#91 (HCG tier-2 channel).
🤖 Generated with Claude Code