-
Notifications
You must be signed in to change notification settings - Fork 35
Description
The spec says:
expected_origins: REQUIRED when signed requests defined in Appendix A.3.2 are used with the W3C Digital Credentials API [w3c.digital_credentials_api]. An array of strings, each string representing an origin of the Verifier that is making the request. The Wallet can detect replay of the request from a malicious Verifier by comparing values in this parameter to the origin asserted by the Web Platform.
However, the spec seems to be missing details of how expected_origins is to be processed.
What should happen when:
-
expected_originsis empty- Issue: It's unclear whether the implementation should accept any origin or reject all requests when
expected_originsis empty. - Example Case: If
expected_originsis an empty array, should the implementation treat this as allowing any origin or blocking all origins? - WG meeting 11.12.25: final text: empty array must be rejected
- Issue: It's unclear whether the implementation should accept any origin or reject all requests when
-
expected_originscontains an invalid origin or URLs- Issue: Should the implementation reject the entire list or simply ignore invalid entries if it contains invalid origins?
- Example Case: If
expected_originscontains entries like["1://2", "https://foo.com"], should the presence of1://2cause the whole list to be rejected, or should it just ignore1://2and drop it on the floor? - WG meeting 11.12.25: Note: expected origins could be web origins or other kind of origins, such as Android package names. The wallet is supposed to treat it as a string, not as a URL.
- Question: How do we ensure that the string provided by the platform to the wallet is formatted the same way on all platform?
-
expected_originscontains a non-https origin- Issue: It is unclear whether non-https origins should be allowed.
- Example Case: If
expected_originsincludes["gopher://foo:123"], should this entry be accepted or rejected? - WG meeting 11.12.25: does not matter
-
expected_originscontains a relative or absolute path, or an empty string- Issue: Should paths be resolved against a base URL or be considered invalid? How should empty strings be handled?
- Example Case: If
expected_originsincludes relative or absolute paths like[".", "/"]or an empty string like[""], should these be resolved against a base URL or rejected? - WG meeting 11.12.25: does not matter, as the origin is not being resolved
-
expected_originscontains URLs with paths, query, and/or fragments- Issue: It is unclear whether origins with paths, query parameters, or fragments should be normalized (e.g., removing paths, queries, and fragments) or considered invalid.
- Example Case: If
expected_originscontains URLs such as["https://foo.com/path?query=1#fragment"], should these be normalized to just the origin or be rejected? - WG meeting 11.12.25: does not matter
-
expected_originscontains duplicates- Issue: Should duplicates be removed or cause the entire list to be rejected?
- Example Case: If
expected_originsincludes["https://foo.com", "https://foo.com"], should the duplicates be removed or should this result in an error? - WG meeting 11.12.25: just checking the match, no need to detect duplicates
-
expected_originscontains non-string entries- Issue: Should all entries in
expected_originsbe converted to strings? By implication,expected_originsshould be defined as a WebIDLUSVStringto ensure proper handling of Unicode and type conversions. - Example Case: If
expected_originsincludes entries like["https://foo.com", null, "https://bar.com"], should non-string entries be converted to strings or cause an error? - WG meeting 11.12.25: would not match, non string would not match definition, must be rejected
Explanation: Defining
expected_originsas a WebIDLUSVStringensures that all entries are properly handled as strings, accommodating Unicode characters correctly. This is important because URLs can contain Unicode characters, and usingUSVStringhelps to normalize these characters to their Unicode Scalar Value (USV) form, ensuring consistency and preventing issues related to encoding and type mismatches. - Issue: Should all entries in
-
Handling of Localhost and Intranet URLs
- Issue: Should URLs pointing to
localhostor intranet addresses be treated with special consideration, especially regarding security implications? - Example Case: If
expected_originscontains["https://localhost"]or["https://192.168.1.1"], should these be allowed given they are local resources?
- Issue: Should URLs pointing to
-
Normalization of URLs
- Issue: During normalization, the URLs should be stripped of their query parameters, fragments, and paths. The primary concern is ensuring that only the origin part (scheme, host, port) is used.
- Example Case: If
expected_originsincludes["https://foo.com/path?query=1#fragment"], should it be normalized to["https://foo.com"]before comparison?
Recommendation: Each URL should be parsed using the WHATWG URL parser, and only the origin should be added to a set to avoid duplicates. This ensures that the origins are consistently and correctly normalized, enhancing security and preventing ambiguity.
To ensure proper handling of expected_origins, we recommend defining it as follows in WebIDL:
dictionary OpenID4VPRequest {
sequence<USVString> expected_origins;
};Further, the spec is missing validation step. Here's a start:
Validator and Processor for OpenID4VPRequest
This section defines an algorithm to validate and process the expected_origins array in an OpenID4VPRequest dictionary. The output will be a set of normalized origins, safely discarding query, fragments, paths, etc.
Algorithm
-
Input:
- An
OpenID4VPRequestdictionary |request|, containing:expected_origins: A sequence ofUSVString.
- An
-
Output:
- A set of normalized origins.
-
Steps:
-
Check if
expected_originsis empty:- If
expected_originsis empty, throw aTypeErrorindicating thatexpected_originsmust not be empty.
- If
-
Let
origins_setbe an empty set. -
For each
origininexpected_origins:-
Parse the URL:
- Let
urlbe the result of parsingoriginusing the URL parser withnullas the URL base. - If parsing
originfails, throw aTypeErrorindicating an invalid URL.
- Let
-
Check scheme:
- If
url's scheme is not "https", throw aTypeErrorindicating an unsupported URL scheme. - ISSUE: Should
localhostand intranet addresses be allowed? (e.g.,https://localhostorhttps://192.168.1.1). Probably not.
- If
-
Extract origin:
- Let
normalized_originbe the result of running the origin serialization steps onurl.
- Let
-
Check for duplicates:
- If
origins_setcontainsnormalized_origin, continue.
- If
-
Add to set:
- Add
normalized_origintoorigins_set.
- Add
-
-
Check if
origins_setis empty:- If
origins_setis empty, throw aTypeErrorindicating that no valid origins were found.
- If
-
Return the set:
- Return
origins_set.
- Return
-