did:web resolver percent-decodes path segments, so the DID document URL is wrong, and the document id is not checked
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 54/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
調査の方向性
Start with WebDidUrlResolver.apply() and WebDidResolver.toDidDocument() in extensions/common/iam/decentralized-identity/identity-did-web; read the did:web Read steps cited in the issue. The reproduction cases in WebDidUrlResolverTest show the URL behavior to check, and the resolver reproduction describes the missing document ID check. Done means encoded path segments remain encoded and a document with a different ID is rejected; the issue notes related IdentityHub work is separate.
索引モデルが issue の本文から書いたものです。
説明
Bug Report
Describe the Bug
WebDidUrlResolver (module extensions/common/iam/decentralized-identity/identity-did-web) percent-decodes the
whole DID document URL. The did:web specification decodes only the port colon of the domain.
So a DID with a percent-encoded character in a path segment resolves to a different URL:
%28becomes(. The server gets a different path.%3Fbecomes?. The rest of the path becomes a query string. The request goes to the parent path, and that
can be the DID document of a different DID.
WebDidResolver then returns the fetched document without checking that its id equals the requested DID.
did:web "Read (Resolve)" step 7 requires this check.
The code is the same on v1.0.0-RC8 and on main.
This is one of three related issues about percent-encoded did:web path segments (see Context Information).
Expected Behavior
did:web:example.com%3A8443:participants:acme%28EU%29resolves to
https://example.com:8443/participants/acme%28EU%29/did.json.did:web:example.com%3A8443:participants:acme%3Fbetaresolves to
https://example.com:8443/participants/acme%3Fbeta/did.json.- If the fetched document has an
idthat is not the requested DID, resolution fails.
Observed Behavior
did:web:example.com%3A8443:participants:acme%28EU%29resolves to
https://example.com:8443/participants/acme(EU)/did.json.did:web:example.com%3A8443:participants:acme%3Fbetaresolves to
https://example.com:8443/participants/acme?beta/did.json. The HTTP request has path/participants/acmeand
querybeta/did.json. An IdentityHub serves a DID document at/<path>(seeDidWebParser), so this returns the
document ofdid:web:example.com%3A8443:participants:acme.WebDidResolveraccepts that document.DidResolverRegistryImplcaches it under the requested DID.
DidPublicKeyResolverImplthen selects a verification method from it. None of them compares the documentid
with the requested DID.
Steps to Reproduce
Steps to reproduce the behavior:
- Add this test to
WebDidUrlResolverTest(same package, because the class is package-private):
@ParameterizedTest
@CsvSource({
"did:web:example.com%3A8443:participants:acme%28EU%29, https://example.com:8443/participants/acme%28EU%29/did.json",
"did:web:example.com%3A8443:participants:acme%3Fbeta, https://example.com:8443/participants/acme%3Fbeta/did.json"
})
void apply_keepsPercentEncodedPathSegments(String did, String expectedUrl) {
var resolver = new WebDidUrlResolver(true);
assertThat(resolver.apply(did)).isEqualTo(expectedUrl);
}
- Run it. Both cases fail:
expected: "https://example.com:8443/participants/acme%28EU%29/did.json"
but was: "https://example.com:8443/participants/acme(EU)/did.json"
expected: "https://example.com:8443/participants/acme%3Fbeta/did.json"
but was: "https://example.com:8443/participants/acme?beta/did.json"
- For the missing
idcheck: serve, athttps://<host>/participants/acme, a DID document with
"id": "did:web:<host>:participants:acme". CallWebDidResolver.resolve("did:web:<host>:participants:acme%3Fbeta").
The resolver requestshttps://<host>/participants/acme?beta/did.json. By code reading, the result succeeds and
contains the document of the other DID: no code path compares the documentidwith the requested DID.
Context Information
- Used version: EDC Connector
1.0.0-RC8. Also present onmain(checked 2026-11-30). - OS: not OS-specific.
- Related issues: this is one of three issues about percent-encoded did:web path segments. All three must be
fixed for such DIDs to work end to end:- This issue: Connector
WebDidUrlResolverdecodes path segments, andWebDidResolverdoes not
check the documentid(resolving side). - eclipse-edc/IdentityHub#1296: IdentityHub
DidWebParserbuilds the DID from the decoded request path (serving side). - eclipse-edc/IdentityHub#1297: IdentityHub
SelfIssuedTokenPrecheckrejects such DIDs (token verification).
- This issue: Connector
- Affected code:
WebDidUrlResolver.apply()line 65, andWebDidResolver.toDidDocument(). - We run EDC Connector and IdentityHub in a dataspace where each participant has a did:web DID. The last path
segment is the participant's identifier from an external registry. Such identifiers can contain characters outside
[A-Za-z0-9._-], for exampleacme(EU)oracme?beta, so the segment is percent-encoded (acme%28EU%29,
acme%3Fbeta).
Detailed Description
The current code on main:
// WebDidUrlResolver.java
var identifier = extractIdentifier(did);
var url = identifier.toString();
if (identifier.getPath().length() == 0) {
url += WELL_KNOWN;
}
return URLDecoder.decode(url + "/" + DID_DOCUMENT, StandardCharsets.UTF_8); // line 65
// WebDidResolver.java, toDidDocument()
var didDocument = mapper.readValue(content.getContent(), DidDocument.class);
return Result.success(didDocument);
Specification. DID Core 1.0, section 3.1 "DID Syntax" (https://www.w3.org/TR/did-1.0/#did-syntax):
method-specific-id = *( *idchar ":" ) 1*idchar
idchar = ALPHA / DIGIT / "." / "-" / "_" / pct-encoded
pct-encoded = "%" HEXDIG HEXDIG
So acme%28EU%29 and acme%3Fbeta are valid DID path segments.
did:web Method Specification, "Read (Resolve)" (https://w3c-ccg.github.io/did-method-web/#read-resolve):
- Replace ":" with "/" in the method specific identifier to obtain the fully qualified domain name and optional path.
- If the domain contains a port percent decode the colon.
- Generate an HTTPS URL to the expected location of the DID document by prepending https://.
- If no path has been specified in the URL, append /.well-known.
- Append /did.json to complete the URL.
- Perform an HTTP GET request to the URL ...
- Verify that the ID of the resolved DID document matches the Web DID being resolved.
Step 2 decodes only the port colon. No step decodes path segments, so %28 stays %28 in the URL. Step 7 is not
implemented.
RFC 3986, section 2.2 (https://www.rfc-editor.org/rfc/rfc3986#section-2.2) also says that URIs which differ by
replacing a reserved character with its percent-encoded octet are not equivalent. /participants/acme%28EU%29 and
/participants/acme(EU) are different paths for the server.
Why the decoding is there (history). We think the decoding of path segments is not intended:
- The first version (
DidFunctions.resolveDidDocumentUrl) usedURI.getSchemeSpecificPart(), which also decodes. - Issue #1652 ("
WebDidResolverdoes not support domain port") reported thatdid:web:example.com%3A3000:user:alice
resolved tohttps://example.com/3000/user/alice. PR #1701 fixed it: it reads the raw part, replaces:with/,
and then URL-decodes the full URL. That decodes the port colon, but also every other escape. - The tests cover only the port (
"HTTPS WITH DOMAIN PORT"). No test covers an escape in a path segment. - We found no decision record about this.
Impact.
- DIDs with an encoded path segment cannot be resolved. With
%3F,%23or%2F, the request goes to another URL. - With no
idcheck, a DID can resolve to the document of another DID. Its verification methods are then used for
the requested DID. Whether a token is then accepted depends on the verification method ids in that document. - IdentityHub added a strict did:web shape check (eclipse-edc/IdentityHub#1200, eclipse-edc/IdentityHub#1203) because escapes such as
%2F,%3F,
%23and%40"are decoded into the resolution URL, where they can change the path or host". That check now
rejects valid DIDs such as...:acme%28EU%29(see eclipse-edc/IdentityHub#1297). When the resolver keeps path
escapes and checks the documentid, that protection can live in the resolver, and the IdentityHub check can
accept DID Coreidchar.
Possible Implementation
Decode only the port colon in the domain. Keep path segments as they are. Reject a path segment that is not
1*idchar, and reject any other escape in the domain. Then check the document id.
--- a/extensions/common/iam/decentralized-identity/identity-did-web/src/main/java/org/eclipse/edc/iam/did/web/resolution/WebDidUrlResolver.java
+++ b/extensions/common/iam/decentralized-identity/identity-did-web/src/main/java/org/eclipse/edc/iam/did/web/resolution/WebDidUrlResolver.java
@@
-import java.net.URLDecoder;
-import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.function.UnaryOperator;
+import java.util.regex.Pattern;
@SuppressWarnings("HttpUrlsUsage")
class WebDidUrlResolver implements UnaryOperator<String> {
private static final String DID_SCHEME = "did";
private static final String DID_METHOD_PREFIX = "web:";
private static final String DID_DOCUMENT = "did.json";
private static final String WELL_KNOWN = "/.well-known";
+ // DID Core: 1*idchar, idchar = ALPHA / DIGIT / "." / "-" / "_" / pct-encoded
+ private static final Pattern PATH_SEGMENT = Pattern.compile("(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})+");
@@
if (identifier.getPath().length() == 0) {
url += WELL_KNOWN;
}
- return URLDecoder.decode(url + "/" + DID_DOCUMENT, StandardCharsets.UTF_8);
+ return url + "/" + DID_DOCUMENT;
@@
- var host = part.substring(DID_METHOD_PREFIX.length()).replace(':', '/');
- return new URL(scheme + "://" + host);
+ var segments = part.substring(DID_METHOD_PREFIX.length()).split(":", -1);
+ // did:web Read step 2: only the port colon of the domain is percent-decoded
+ var domain = segments[0].replaceFirst("%3[Aa]", ":");
+ if (domain.contains("%")) {
+ throw new IllegalArgumentException("Invalid DID format, the domain may only percent-encode the port colon: " + did);
+ }
+ var path = new StringBuilder();
+ for (var i = 1; i < segments.length; i++) {
+ if (!PATH_SEGMENT.matcher(segments[i]).matches()) {
+ throw new IllegalArgumentException("Invalid DID format, invalid path segment '%s': %s".formatted(segments[i], did));
+ }
+ path.append('/').append(segments[i]);
+ }
+ return new URL(scheme + "://" + domain + path);
}
--- a/extensions/common/iam/decentralized-identity/identity-did-web/src/main/java/org/eclipse/edc/iam/did/web/resolution/WebDidResolver.java
+++ b/extensions/common/iam/decentralized-identity/identity-did-web/src/main/java/org/eclipse/edc/iam/did/web/resolution/WebDidResolver.java
@@
var didDocument = mapper.readValue(content.getContent(), DidDocument.class);
+ // did:web Read step 7
+ if (!didKey.equals(didDocument.getId())) {
+ return Result.failure("DID document id '%s' does not match the resolved DID '%s'".formatted(didDocument.getId(), didKey));
+ }
return Result.success(didDocument);
We checked the patched mapping with OkHttp HttpUrl.get():
| DID | URL | OkHttp encoded path |
|---|---|---|
did:web:w3c-ccg.github.io |
https://w3c-ccg.github.io/.well-known/did.json |
/.well-known/did.json |
did:web:example.com%3A3000:user:alice |
https://example.com:3000/user/alice/did.json |
/user/alice/did.json |
did:web:example.com%3A8443:participants:acme%28EU%29 |
https://example.com:8443/participants/acme%28EU%29/did.json |
same, no query |
did:web:example.com%3A8443:participants:acme%3Fbeta |
https://example.com:8443/participants/acme%3Fbeta/did.json |
same, no query |
did:web:user%40internal.host |
rejected | |
did:web:example.com%3A80%3A81 |
rejected |
The existing WebDidUrlResolverTest cases still pass.
Note: the id check can break deployments that serve a document whose id differs from its DID. Such documents
are already invalid under did:web. A setting to turn the check off could ease the migration, if needed.
The serving side has the matching problem: IdentityHub DidWebParser builds the DID from the decoded request path
(eclipse-edc/IdentityHub#1296).
- 主要言語
- Java
- スター
- 429
- フォーク
- 302
- 平均マージ
- 10時間 46分
- マージ済み PR(30日)
- 75
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
eclipse-edc/Connector のほかの issue
-
Implement conditional extension loading (DR 2026-11-24)対応中かも @paullatzelsperger が 5 日前に担当しました。 オープンfeature_request triage
eclipse-edc/Connector#6275 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
feature_request stale triage
難易度 5/5 1週間以上 初心者へのやさしさ 18/100
eclipse-edc/Connector#6235 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Don't hold a DB connection during token validation of incoming negotiation and transfer messagesオープンfeature_request triage
難易度 4/5 3〜5日 初心者へのやさしさ 54/100
eclipse-edc/Connector#6183 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
feature_request triage
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
eclipse-edc/Connector#6182 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
feature_request triage
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
eclipse-edc/Connector#6178 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
eclipse-edc/Connector の issue をすべて見る
似ている issue
-
triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
eclipse-edc/IdentityHub#1296 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
cloudfoundry/uaa#4194 ·
メンテナーはふだん 1 日以内に返信
-
area: ui priority: medium
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
tetsuji16/microProject#1721 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
The engine's "loaded, but had errors" message leaves out which library and line each error is inオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
cqframework/clinical_quality_language#1980 ·
メンテナーはふだん 3 日以内に返信