Original sources · POC — architecture & contracts
Step 6 checklist — isolated PDS filter
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):
- Exposing
MandateDpopFilteras its own@Beanmade 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@Beanmethod instead. ContentCachingRequestWrapperdoesn'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-rolledCachedBodyRequestthat replays the same buffered bytes on everygetInputStream()call.
Pre-flight facts confirmed before writing code
-
Ed25519Verifierworks with plain Nimbus, no Tink/BouncyCastle needed for sign/verify - No Caffeine dependency needed — plain
ConcurrentHashMap+ lazy purge-on-write -
McpPrincipalrecord and its consumers need no changes -
pds.platform.*/pds.dpop.*/pds.mcp.canonical-uriconfig 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 ownbad_tokenresponse instead of Spring's nativeinvalid_token, plus confirming/accounts/meand/account-link/assertare unaffected
New code — all done
-
PdsPlatformProperties,PdsDpopProperties—@ConfigurationProperties, mirroringPdsLinkingProperties's existing pattern -
DpopReplayCache—ConcurrentHashMap<String,Instant>, lazy purge on write -
PdsAssertionKeyService.publicKey()/.thumbprint()accessors added -
MandateDpopFilter— all 19 steps, in order, againstCachedBodyRequest(see bug #2 above for why notContentCachingRequestWrapper)- 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 cleanactive:true) - steps 6–12 (
cnfthumbprint, 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_auditDENY 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 /mcpandGET /mcp
- steps 1–4 (delegation JWT: scheme, signature via lazy
-
SecurityConfigsplit into two chains — and further split into two@Configurationclasses (SecurityConfig+ newMcpSecurityConfig), not just two@Beanmethods in one class — see "bugs found" below for why
Bugs found fixing this (beyond the two above) — all resolved
- A
@WebMvcTestslice test (UserControllerUnitTest, testing the unrelated Keycloak chain) failed to load its context because it@ImportsSecurityConfig, which — once it also declared the MCP chain's@Bean— needed beans (PdsPlatformPropertiesetc.) that slice never scans. Fixed by moving the MCP chain into its ownMcpSecurityConfigclass, 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 ano_mandate_contexttool error) is retired now that the filter exists. Rewritten down to one test verifying the new, correct behavior: an unauthenticated client can't even completeinitialize()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/meand/pds-jwks.json(unrelated chains) unaffected - Real end-to-end happy path (S1): fresh
initkeypair → real minted mandate via the platform stub → realconfig.json→ real outil-localruntime→ real DPoP-signedtools/list+tools/call get_balance+tools/call list_transactionsagainst 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 got403 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 (wrongaud), 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. DrivesMandateDpopFilter.doFilterInternaldirectly with real signed material (RSA delegation JWTs, Ed25519 DPoP proofs, real PDS-signed account-link assertions via the realPdsAssertionKeyServicebean) against an in-process JDKHttpServertest 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.mdrow 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 inMcpPrincipal.java,GetBalanceTool.java,ListTransactionsTool.javaclass docs andoutil-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.javaclass docs, and an older (pre-step-6) stale note inplatform/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 —
MandateDpopFilternow checks the JSON-RPCmethodbefore step 1; if it'sinitialize,notifications/initialized, ortools/list, the request skips all 19 steps entirely (no verification, no audit row, no principal). All three have to be exempt together, not justtools/list— Streamable HTTP's session handshake is strictly ordered, so a caller can't reachtools/listwithout completinginitializefirst.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_dpopas before. - 4 new
MandateDpopFilterTestcases (3 discovery methods pass through unauthenticated, one confirmstools/callwith zero auth headers still denies) +McpRouteIntegrationTestrewritten (it previously asserted the opposite, pre-fix behavior — that was correct at the time, now retired). 41/41mvn testgreen, no flakiness across repeated runs. -
contracts.md§2 (the canonical wire contract) andpds/spec.md§9 updated with the exemption;contracts.mdrow 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.