SelfIssuedTokenPrecheck rejects valid did:web DIDs with percent-encoded path segments
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- java
- Ambito
- authentication, backend
Direzione di ricerca
Start with SelfIssuedTokenPrecheck.java and SelfIssuedTokenPrecheckTest; read the existing malformed and well-formed DID cases and the hardening rationale from #1200 and PR #1203. Compare the proposed path-segment rules with the related Connector resolver issue #6293, since the safe validation options depend on that resolver's behavior. Done means valid percent-encoded path segments pass while the URL-changing cases remain rejected; run the focused precheck tests.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Report
Describe the Bug
SelfIssuedTokenPrecheck.checkDid() (core/lib/common-lib) rejects a did:web DID when a path segment contains a
percent-encoded character. Example: did:web:example.com%3A8443:participants:acme%28EU%29 fails with
"Malformed did:web identifier". This DID is valid under DID Core.
The precheck runs before every self-issued token is verified: the Issuer credential request
(DcpHolderTokenVerifierImpl), the presentation query (SelfIssuedTokenVerifierImpl), the credential offer
(DcpHolderCoreExtension) and the Storage API (StorageApiController). So a participant with such a DID can be
created and its DID can be published, but it cannot get a credential or answer a presentation query.
ParticipantManifestValidator in the same release accepts DID Core idchar (%XX) in did:web DIDs. So IdentityHub
is not consistent with itself.
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
A self-issued token with iss = did:web:example.com%3A8443:participants:acme%28EU%29 and
kid = did:web:example.com%3A8443:participants:acme%28EU%29#key-1 passes the precheck. Verification continues with DID
resolution and the signature check.
Observed Behavior
The precheck fails with Malformed did:web identifier 'did:web:example.com%3A8443:participants:acme%28EU%29'.
The Issuer answers the credential request with 401 ("ID token verification failed"). The holder's credential
request ends in an error state.
did:web:example.com%3A8443:participants:acme (no escape) passes.
Steps to Reproduce
Steps to reproduce the behavior:
- Add this test to
SelfIssuedTokenPrecheckTest:
@ParameterizedTest
@ValueSource(strings = {
"did:web:example.com%3A8443:participants:acme%28EU%29",
"did:web:example.com:user:%C3%A4lice"
})
void checkDid_percentEncodedPathSegment_succeeds(String did) {
assertThat(SelfIssuedTokenPrecheck.checkDid(did)).isSucceeded();
}
-
Run it. Both cases fail with
Malformed did:web identifier. -
End to end: create a participant context with DID
did:web:<host>:participants:acme%28EU%29and request a credential
from an Issuer that runs IdentityHub. The Issuer answers401.
Context Information
- Used version: EDC IdentityHub
1.0.0-RC8(we reproduced it with the RC8 jar). 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:- eclipse-edc/Connector#6293: 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). - This issue: IdentityHub
SelfIssuedTokenPrecheckrejects such DIDs (token verification).
- eclipse-edc/Connector#6293: Connector
- Affected code:
SelfIssuedTokenPrecheck.java, line 36:
// a domain name, optionally followed by a percent-encoded port, then optional colon-separated path segments
private static final Pattern DID_WEB = Pattern.compile("did:web:[A-Za-z0-9._-]+(%3[Aa][0-9]{1,5})?(:[A-Za-z0-9._-]+)*");
- 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), so the segment is percent-encoded (acme%28EU%29).
Detailed Description
Why the check exists. The strict pattern is deliberate. Issue #1200 and PR #1203 added it as hardening:
resolving a did:web is an outbound HTTP request, and the Connector's did:web resolver percent-decodes the whole
DID document URL. PR #1203: "A crafted did:web could also change the resolved URL's path or host through
percent-decoding." Issue #1200 names %2F, %3F, %23 and %40. The tests pin this:
did:web:example.com%2Fadmin, did:web:example.com%3Fx=, did:web:example.com%23, did:web:user%40internal.host
and did:web:example.com:path%3A8080 must fail.
We agree with that goal. But the pattern blocks every escape in a path segment, also the ones that cannot change
the URL, such as %28 (() or %C3%A4 (ä). These are valid DIDs.
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
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.
The did:web method does not restrict path segments more than DID Core does. It decodes only the port colon. So a
path segment keeps its escapes in the document URL, and an escape cannot change the path, query or host. The danger
named in #1200 comes from the resolver decoding path escapes, which the did:web specification does not do. We
reported that in eclipse-edc/Connector#6293.
Possible Implementation
Option A (now, one line). Allow percent-encoding in path segments, but keep rejecting the escapes that change
a URL when it is decoded: %2F (/), %3F (?), %23 (#), %25 (%, double decoding), %5C (\, which
OkHttp treats as /) and %3A (:). The host part does not change, so %40 in the host stays rejected.
- private static final Pattern DID_WEB = Pattern.compile("did:web:[A-Za-z0-9._-]+(%3[Aa][0-9]{1,5})?(:[A-Za-z0-9._-]+)*");
+ private static final Pattern DID_WEB = Pattern.compile("did:web:[A-Za-z0-9._-]+(%3[Aa][0-9]{1,5})?(:(?:[A-Za-z0-9._-]|%(?!2[Ff]|3[Ff]|23|25|5[Cc]|3[Aa])[0-9A-Fa-f]{2})+)*");
We ran the patched pattern against the existing test lists:
- All current "well-formed" cases still pass.
- All current "malformed" cases still fail, including
did:web:example.com:path%3A8080. - New:
...:acme%28EU%29and...:%C3%A4licepass....:a%2Fb,...:a%3fb,...:a%23b,...:a%252Fb,
...:a%5Cband...:a%zzfail.
Option A still rejects some valid DIDs, for example a segment with %3F (acme%3Fbeta for the identifier acme?beta).
Option B (after the Connector resolver is fixed). When the resolver keeps path escapes (eclipse-edc/Connector#6293), no
escape in a path segment can change the URL. Then the precheck can accept all of DID Core idchar in path
segments and keep the strict host rule:
private static final Pattern DID_WEB = Pattern.compile("did:web:[A-Za-z0-9._-]+(%3[Aa][0-9]{1,5})?(:(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})+)*");
With option B, did:web:example.com:path%3A8080 becomes valid and moves to the "well-formed" test list. It is a
valid DID, and with the fixed resolver its URL is https://example.com/path%3A8080/did.json.
We suggest option A now, and option B together with the Connector fix.
- Lingua principale
- Java
- Stelle
- 46
- Fork
- 65
- Merge medio
- 1g 5h
- PR unite (30g)
- 26
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di eclipse-edc/IdentityHub
-
triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eclipse-edc/IdentityHub#1296 ·
I maintainer di solito rispondono entro 1 giorno
-
triage
Difficoltà 4/5 1-2 giorni Idoneità per principianti 48/100
eclipse-edc/IdentityHub#1286 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Credential status check queries the status list before the expiry check, so expired credentials can end in ERRORForse già presa @paullatzelsperger l’ha presa 6 giorni fa. Apertatriage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 42/100
eclipse-edc/IdentityHub#1282 · 4 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
question triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
eclipse-edc/IdentityHub#1271 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Issuer: add support for `issuancePolicies`Forse di nuovo libera @paullatzelsperger l’ha presa 545 giorni fa e non c’è nessuna pull request aperta. Apertadcp enhancement
eclipse-edc/IdentityHub#694 · 5 commenti · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di eclipse-edc/IdentityHub
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
cloudfoundry/uaa#4194 ·
I maintainer di solito rispondono entro 1 giorno
-
ui: 進捗状況線ダイアログが日本語表示で英語のままApertaarea: ui priority: medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
tetsuji16/microProject#1721 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 2 giorni
-
The engine's "loaded, but had errors" message leaves out which library and line each error is inAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
cqframework/clinical_quality_language#1980 ·
I maintainer di solito rispondono entro 3 giorni
-
windows-sys 0.101.0Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 61/100