VVeritia documentation

Original sources · POC — architecture & contracts

Step 6 checklist — isolated PDS filter

poc-code/step-6-checklist.md POC EN updated 2026-12-01 12 KBraw file

Summarised in: Status & testing · Open questions

Step 6 — implementation checklist

Not frozen — update freely as work lands. Design is fixed in contracts.md §2 (the 19-step verification order) and pds/spec.md §9 (the two-chain architecture, attention points, spike corrections). This file just tracks how far the implementation has gotten.

Started 2026-09-19, after step 5b was deliberately deferred in favor of this — 6 fixes a live bug (Spring Security 6.5's native DPoP-scheme recognition intercepting /mcp/** before permitAll applies, found during step 5's manual testing) that would otherwise sabotage whatever 5b builds on top of it. See contracts.md row 5's status note and outil-local/MANUAL-TESTING.md for how that bug was found and worked around.

Core implementation DONE and live-verified 2026-09-19 — the full happy path works end-to-end for the first time in this project (real mandate → real outil-local DPoP signing → real PDS verification → real balance data back). Two real bugs found and fixed along the way (both documented in code comments, not just here):

  1. Exposing MandateDpopFilter as its own @Bean made Spring Boot auto-register it as a global servlet filter, answering every request in the app (not just /mcp/**) — fixed by constructing it inline inside the chain's @Bean method instead.
  2. ContentCachingRequestWrapper doesn't make the request body re-readable for a second consumer downstream (it's built for logging after a handler reads the body, not pre-reading before one does) — the MCP handler got an empty body once this filter's own bsha check had already drained the stream. Fixed with a small hand-rolled CachedBodyRequest that replays the same buffered bytes on every getInputStream() call.

Pre-flight facts confirmed before writing code

  • Ed25519Verifier works with plain Nimbus, no Tink/BouncyCastle needed for sign/verify
  • No Caffeine dependency needed — plain ConcurrentHashMap + lazy purge-on-write
  • McpPrincipal record and its consumers need no changes
  • pds.platform.* / pds.dpop.* / pds.mcp.canonical-uri config keys already existed, unconsumed until now
  • Verified live: the two-chain split does stop Spring Security 6.5's DPoP-scheme auto-recognition from touching /mcp/** — confirmed by reproducing the exact original bug (Authorization: DPoP garbage) and seeing this filter's own bad_token response instead of Spring's native invalid_token, plus confirming /accounts/me and /account-link/assert are unaffected

New code — all done

  • PdsPlatformProperties, PdsDpopProperties — @ConfigurationProperties, mirroring PdsLinkingProperties's existing pattern
  • DpopReplayCache — ConcurrentHashMap<String,Instant>, lazy purge on write
  • PdsAssertionKeyService.publicKey() / .thumbprint() accessors added
  • MandateDpopFilter — all 19 steps, in order, against CachedBodyRequest (see bug #2 above for why not ContentCachingRequestWrapper)
    • steps 1–4 (delegation JWT: scheme, signature via lazy RemoteJWKSet, alg/typ, iss/exp/nbf/iat ±60s, aud)
    • step 5 (introspection, RestClient, fail-closed on anything but a clean active:true)
    • steps 6–12 (cnf thumbprint, DPoP proof parse+verify, PoP key match, htm/htu, proof freshness, bsha, replay)
    • step 13 (tool allow-list, JSON-RPC body parsed via Jackson, skipped for GET/non-tools/call)
    • steps 14–18 (account-link assertion re-verify against the locally held assertion key)
    • step 19 (McpPrincipal → PreAuthenticatedAuthenticationToken)
    • deny path: mcp_call_audit DENY row (skipped only when step 1 itself fails — no JWS to correlate against), WWW-Authenticate: DPoP error="<code>", JSON body, correct status
    • authenticates both POST /mcp and GET /mcp
  • SecurityConfig split into two chains — and further split into two @Configuration classes (SecurityConfig + new McpSecurityConfig), not just two @Bean methods in one class — see "bugs found" below for why

Bugs found fixing this (beyond the two above) — all resolved

  • A @WebMvcTest slice test (UserControllerUnitTest, testing the unrelated Keycloak chain) failed to load its context because it @Imports SecurityConfig, which — once it also declared the MCP chain's @Bean — needed beans (PdsPlatformProperties etc.) that slice never scans. Fixed by moving the MCP chain into its own McpSecurityConfig class, so a test that only needs the Keycloak chain doesn't drag in MCP dependencies.
  • McpRouteIntegrationTest (3 tests) was written against the pre-step-6 world where /mcp/** was fully open — its entire premise (initialize() with no auth succeeding, landing in a no_mandate_context tool error) is retired now that the filter exists. Rewritten down to one test verifying the new, correct behavior: an unauthenticated client can't even complete initialize() any more.

Tests

  • Full existing suite green after all of the above: 26/26 (GetBalanceToolTest, ListTransactionsToolTest, AccountControllerTest, AccountLinkControllerTest, UserControllerUnitTest, McpRouteIntegrationTest)
  • Real jar boot + live curl: reproduced the original interception bug and confirmed it's gone; confirmed /accounts/me and /pds-jwks.json (unrelated chains) unaffected
  • Real end-to-end happy path (S1): fresh init keypair → real minted mandate via the platform stub → real config.json → real outil-local runtime → real DPoP-signed tools/list + tools/call get_balance + tools/call list_transactions against the real PDS → real balance/transaction data back
  • Revocation (S4), live: revoked the same mandate mid-session via POST /mandates/:jti/revoke, next call correctly got 403 revoked_or_unknown
  • Done 2026-09-19: MandateDpopFilterTest (pds/src/test/java/.../mcp/) — a dedicated unit-test class exercising the rest of the scenario matrix with deliberately-forged inputs: S2 (pop_key_mismatch), S3 (expired), S5 (wrong aud), S6 (replay), S7 (tampered body), S8 (introspection down, fail-closed), S9 (tool not allowed), S14 (tampered assertion signature), S15 (assertion/value mismatch), plus a baseline happy-path regression check. Drives MandateDpopFilter.doFilterInternal directly with real signed material (RSA delegation JWTs, Ed25519 DPoP proofs, real PDS-signed account-link assertions via the real PdsAssertionKeyService bean) against an in-process JDK HttpServer test double (support/PlatformTestDouble.java) standing in for the platform's JWKS + introspection endpoints — no mocking of Nimbus/Spring internals. 10/10 green; full suite 36/36 green.

Verification against outil-local — done

  • Re-ran the loopback-vs-real-PDS comparison from step 5, this time against the real PDS — no more Spring-Security-DPoP-interception 401, full real flow works
  • outil-local/MANUAL-TESTING.md's note about the interception bug updated 2026-09-19 — no longer says "pending build step 6," now says it's fixed and the happy path is live-verified against the real PDS

Cross-cutting

  • contracts.md row 6 — flipped to ✅ done 2026-09-19
  • pds/spec.md §9/§10 — stale "not built yet" notes updated 2026-09-19; also fixed the same staleness in McpPrincipal.java, GetBalanceTool.java, ListTransactionsTool.java class docs and outil-local/MANUAL-TESTING.md (all found during this pass, not just the two files originally flagged)
  • 2026-09-25 doc-freshness re-audit found more of the same staleness pattern missed on 2026-09-19: outil-local/README.md, GetBalanceToolTest.java/ListTransactionsToolTest.java class docs, and an older (pre-step-6) stale note in platform/stub/TESTING.md. All fixed.

Bug found in the 2026-09-25 re-audit — discovery exemption never implemented

pds/spec.md §8 documents "discovery (tools/list) is left public for the POC" — the platform stub's registration-time POST /discover (contracts §5.2, mcp-discover.ts) calls a not-yet-mandated PDS's initialize→notifications/initialized→tools/list with no auth at all, since there's nothing to grant a mandate over before the tool catalog is known. This was never actually wired into MandateDpopFilter — the filter blocked all unauthenticated /mcp/** traffic, silently breaking the demo's own live registration step (demo/script.md, /admin/register → Discover) against a real, step-6-protected PDS. Confirmed live before fixing: curl -X POST http://localhost:8081/mcp -d '{"method":"initialize",...}' (no auth headers) → 401 missing_dpop.

  • Fixed 2026-09-25 — MandateDpopFilter now checks the JSON-RPC method before step 1; if it's initialize, notifications/initialized, or tools/list, the request skips all 19 steps entirely (no verification, no audit row, no principal). All three have to be exempt together, not just tools/list — Streamable HTTP's session handshake is strictly ordered, so a caller can't reach tools/list without completing initialize first. tools/call (the only operation touching real account data) is never exempt.
  • Live-reverified with the exact curl sequence that found the bug: unauthenticated initialize → 200, notifications/initialized → 202, tools/list → real tool list, tools/call (still unauthenticated) → 401 missing_dpop as before.
  • 4 new MandateDpopFilterTest cases (3 discovery methods pass through unauthenticated, one confirms tools/call with zero auth headers still denies) + McpRouteIntegrationTest rewritten (it previously asserted the opposite, pre-fix behavior — that was correct at the time, now retired). 41/41 mvn test green, no flakiness across repeated runs.
  • contracts.md §2 (the canonical wire contract) and pds/spec.md §9 updated with the exemption; contracts.md row 6 updated with a follow-up-fix note.

A narrower, known limitation found while re-verifying (2026-09-25) — not fixed, documented

Re-testing with @modelcontextprotocol/inspector --cli --method tools/list (no auth) still fails with missing_dpop, even though tools/list is exempt. Root cause, confirmed via PDS debug logs: the inspector's Streamable HTTP client opens a GET /mcp request (the session-bound SSE stream) as part of connecting, interleaved with the initialize/notifications/initialized POSTs. GET /mcp carries no body, so the filter's method-based exemption (which only inspects POST JSON-RPC bodies) can't recognize it as a discovery call — it gets the normal, fully-gated 401, and that appears to fail the whole CLI session.

This does not affect the product's actual discovery flow: platform/stub/src/mcp-discover.ts (what POST /discover really calls) never opens a GET request — verified by reading its source, only three plain POSTs. It only affects generic Streamable HTTP clients (like the reference inspector tool) that proactively open a GET stream regardless of intent. Left as a documented limitation rather than fixed, since exempting GET /mcp entirely is a materially bigger security decision (an entire request type, not 3 specific harmless JSON-RPC methods) than what was already approved — a call for whoever owns the product to make deliberately, not a silent follow-on fix. Documented in pds/TESTING.md §7, pds/spec.md (quickstart + build-order note), and demo/script.md's pre-flight check (which used this exact broken command — replaced with a working curl equivalent, since it would otherwise give a presenter a false negative live).

Step 6 is fully done — including this follow-up — with the GET-stream limitation above tracked as a known, deliberately-deferred gap, not an oversight.

Generated 2026-11-30 by documentation/build.mjs · edit the Markdown, never this HTML.