fix(vcr/verifier): handle unparseable issuer DID instead of panicking#4302
Open
reinkrul wants to merge 1 commit into
Open
fix(vcr/verifier): handle unparseable issuer DID instead of panicking#4302reinkrul wants to merge 1 commit into
reinkrul wants to merge 1 commit into
Conversation
The signature-check path discarded the error from did.ParseDID(issuer) and dereferenced the resulting nil pointer, crashing the node when a credential carried an unparseable issuer DID (e.g. a did:x509 with trailing unsupported fields, as emitted by the AET ZORG-ID SDK). Capture the parse error and return a clean validation error instead. Fixes #4235 Assisted by AI
Contributor
1 new issue
|
Contributor
|
Coverage Impact This PR will not change total coverage. Modified Files with Diff Coverage (1)
🛟 Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
vcr/verifier/verifier.godiscarded the error fromdid.ParseDID(issuer)on the signature-check path, then dereferenced the resultingnilpointer. An unparseable issuer DID — e.g. adid:x509with trailing unsupported fields, as emitted by the AET ZORG-ID SDK — madeParseDIDreturn(nil, err), so the dereference panicked and crashed the entire node:Reproducible by posting such a credential to
/internal/vcr/v2/holder/{subject}/vc.Fix
Capture the parse error and return a clean validation error:
Why the validator didn't catch it first
Credentials with an unrecognized type fall back to
defaultCredentialValidator, which only checks the issuer is non-empty — it never parses it as a DID. So a malformed issuer reaches the signature-check path untouched.Test
Added a regression test to
TestVerifier_Verifyusingdid:x509:0:sha256:abc::san:otherName:1.2.3.4#extra(valid URI, invalid DID). It asserts acould not parse issuer DIDerror; without the fix it panics.Fixes #4235
Assisted by AI