Skip to content

fix(oid4vp): skip the client-side verifier trust check when the DC-API callback has no transport context - #467

Open
leifj wants to merge 4 commits into
release/sirosidfrom
fix/dcapi-trust-skip-no-transport
Open

leifj wants to merge 4 commits into
release/sirosidfrom
fix/dcapi-trust-skip-no-transport

Conversation

@leifj

@leifj leifj commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

What

The QR link opens the DC-API callback page before the WebSocket transport connects. transportContext is null, and the optional chain transportContext?.trustEvaluators.evaluateVerifierTrust() returns undefined. !undefined?.trusted is always true, so the 'untrusted verifier' refusal fires unconditionally before the engine's own server-side evaluation — which handles this correctly — is ever consulted.

Every cross-device presentation failed with 'untrusted verifier' on the phone while the wallet-backend showed zero flow activity — found live in the WRPAC drill.

The change

The client-side trust check runs only when a transport context exists. Without one, the engine's server-side evaluation makes the actual trust decision (proven working in earlier rounds: 'Trust evaluation with x5c', cert_count=2, decision true).

Also: the useCallback dependency updated from transportContext?.trustEvaluators to transportContext (the exhaustive-deps warning it was suppressing).

@leifj
leifj requested a review from a team as a code owner November 17, 2026 20:49
@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d231a87

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wallet-frontend Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Credential presentation can proceed without a verifier trust decision when transport context is null, and the provider-presence guard does not address the WebSocket startup-readiness failure.

2 open issues
What changed in this PR

This PR aims to prevent premature “untrusted verifier” refusals during DC-API callback startup in the wallet’s OpenID4VP flow.

Changes:

  • Allows processing to continue without a client-side trust result when transport context is absent.
  • Adds explanatory comments and logging for that case.
  • Updates the callback dependency to track the full transport context.
File Description
src/​hooks/​useOID4VPFlow.ts Changes DC-API trust gating, adds diagnostic context, and updates callback dependencies.

Review effort: Balanced

})
: undefined;

if (trustResult && !trustResult?.trusted) {
Comment thread src/hooks/useOID4VPFlow.ts Resolved
…VP 1.0 §8.1)

The client-held direct_post.jwt response relayed the sign handler's bare
vp_token string through verbatim. The final spec requires vp_token to be
a JSON object with one member per Credential Query - the key the query's
id, the value an array of its presentations - and verifiers enforcing
that shape reject the bare string with malformed/invalid response (found
live in the WRPAC drill: every cross-device presentation against
siros-verifier-core v0.1.4 failed at this last hop, after the JWE
envelope itself verified clean).

A bare token is now restructured under the sign request's
credentialsToInclude credential query ids, mirroring the engine's own
non-encrypted builder exactly (newline-split, count-checked, a repeated
query id collected in order) - the builder direct_post.jwt bypasses by
relaying this JWE verbatim. An already-object response passes through.
The §8.1 object-form fix landed only in the JARM builder the WebSocket
transport uses. The phone's QR/link flow takes another path: the
callback page opens as a companion window (window.opener), answers the
sign handler, and hands JSON.parse(vpToken) to DCAPISession - a
JSON-quoted single token parses to a bare string at runtime (the
Record<> type is decorative in JS), so the DC-API path still encrypted
the bare string and final-spec verifiers kept rejecting it.

Extract the restructure into a shared restructureDcqlVpToken (the
JARM builder delegates to it) and wrap at the DC-API caller with the
selection's own credential query ids. A JSON-quoted token now unwraps
to the token itself before the object form is built.
…I callback has no transport context

The QR link opens the callback page before the WebSocket transport
connects; transportContext is null and the optional chain
transportContext?.trustEvaluators.evaluateVerifierTrust() returns
undefined. !undefined?.trusted is always true, so the 'untrusted
verifier' refusal fires unconditionally before the engine's own
server-side evaluation — which handles this correctly — is ever
consulted.

The client-side check now runs only when a context exists; without
one, the engine makes the actual trust decision. Found live in the
WRPAC drill: every cross-device presentation failed with 'untrusted
verifier' on the phone while the wallet-backend showed zero flow
activity.
@leifj
leifj force-pushed the fix/dcapi-trust-skip-no-transport branch from 03b5248 to e1f86c6 Compare November 17, 2026 21:00
@leifj
leifj requested a balanced review from Copilot November 17, 2026 21:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The DC-API path can disclose credentials without any verifier trust evaluation when the transport context is absent, creating a critical trust-policy bypass.

3 open issues

Review effort: Balanced

`DCQL vp_token has ${tokens.length} tokens but ${ids.length} credentials selected`,
);
}
const byQueryId: Record<string, string[]> = {};

@smncd smncd left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think rather than skipping the trust check, we should decouple the trust evaluators from the transport context, the could sit in their own context. I would prefer that approach regardless of if we skip checking trust here or not (which I don't think we should, unless necessary).

Comment on lines +5 to +16
Fix the client-held `direct_post.jwt` (JARM) response to carry `vp_token` in the
OpenID4VP 1.0 §8.1 object form: a JSON object with one member per Credential
Query, the key the query's `id`, the value an array of that query's
presentations. A bare vp_token string is now restructured under the sign
request's `credentialsToInclude` credential query ids — the same newline-split,
count-checked, in-order restructure the engine's own non-encrypted path
performs (go-wallet-backend's `buildDCQLVPToken`, which direct_post.jwt
bypasses by relaying the client's JWE verbatim). Verifiers enforcing the final
shape (including the OIDF conformance suite's own client) reject the previous
bare-string form with `malformed`/`invalid response` — found live in the SIROS
WRPAC drill, where every cross-device presentation against
siros-verifier-core v0.1.4 failed at this last hop.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changesets are meant to be a short summary, not a detailed one. Summarise what the PR does, and if necessary, add more than one changeset.

The evaluators sit in their own TrustEvaluatorProvider — a sibling of
the transport provider, not a child — so routes that run before a
transport connects (the DC-API callback page) evaluate trust the same
way the main app does. The provider resolves the backend token through
the same session-based mechanism the transport uses, independently.

The handleDCAPIRequest hook consumes the evaluators from the new
context instead of the transport context — the trust check now fires
on every route, not just where a transport is established.
@leifj
leifj requested review from smncd and a balanced review from Copilot November 18, 2026 10:38
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
51.2% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Credential presentation can proceed without a verifier trust decision when the evaluator context is absent, creating a fail-open security path.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment on lines +48 to +62
const getAuthToken = () => authToken ?? '';
const evaluateIssuerTrust = createIssuerTrustEvaluator({
httpClient,
backendUrl: BACKEND_URL,
getAuthToken,
tenantId,
});
const evaluateVerifierTrust = createVerifierTrustEvaluator({
httpClient,
backendUrl: BACKEND_URL,
getAuthToken,
tenantId,
});
return { evaluateIssuerTrust, evaluateVerifierTrust };
}, [tenantId, authToken, httpClient]);
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.

3 participants