Skip to content

fix: address PR #301 review comments#302

Open
leifj wants to merge 2 commits intoSUNET:masv/infra/releasefrom
sirosfoundation:fix/review-comments-301
Open

fix: address PR #301 review comments#302
leifj wants to merge 2 commits intoSUNET:masv/infra/releasefrom
sirosfoundation:fix/review-comments-301

Conversation

@leifj
Copy link
Contributor

@leifj leifj commented Mar 11, 2026

Addresses all 5 Copilot review comments on PR #301:

  1. strings.TrimLeft unsafe for URL scheme stripping (handler_openid4vp.go)

    • Use url.Parse() + parsedURL.Host instead of strings.TrimLeft to extract the DNS name for the x509_san_dns: client_id.
  2. MakeSDJWT doesn't validate scope/VCT URL (SSRF risk) (handlers.go)

    • Look up CredentialConstructor by req.Scope — reject unknown scopes.
    • Enforce that caller-provided vct_url and integrity match the configured values, preventing arbitrary URL injection.
  3. vct_url/integrity not validated as required (handlers.go)

    • Added validate:"required,url" to VCTUrl and validate:"required" to Integrity in CreateCredentialRequest.
  4. UIMetadata uses vctm.VCT instead of resolved URL (handlers_ui.go)

    • Prefer GetVCTURL() (the resolved URL used in credentials/DCQL queries), falling back to vctm.VCT only when the URL is empty.
  5. fetchVCTM has no timeout/size limit (methods.go)

    • Use a dedicated HTTP client with 30-second timeout instead of http.DefaultClient.
    • Wrap response body with io.LimitReader capped at 1 MiB to prevent excessive memory usage.

Also adds SetVCTURL/SetIntegrity methods to CredentialConstructor and updates issuer tests to populate credential constructors with matching VCT URL/integrity values.

- Use url.Parse instead of strings.TrimLeft for x509_san_dns client_id
- Validate scope against credential constructors in MakeSDJWT (SSRF prevention)
- Enforce VCT URL and integrity match configured values
- Add validate:required,url to VCTUrl and validate:required to Integrity
- Use resolved VCT URL in UIMetadata (prefer GetVCTURL over VCTM.VCT)
- Add 30s timeout and 1MiB size limit to fetchVCTM HTTP client
- Add SetVCTURL/SetIntegrity methods to CredentialConstructor for testing
@leifj leifj force-pushed the fix/review-comments-301 branch from e56c070 to 9b63c46 Compare March 12, 2026 09:12
The issuer and apigw load VCTMs independently, and their cached
integrity hashes can diverge when caches refresh at different times.
Remove the cross-cache integrity comparison in MakeSDJWT; the scope
and VCT URL checks prevent SSRF, and BuildCredentialWithSigner already
verifies integrity against the actual fetched VCTM content.
@sonarqubecloud
Copy link

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.

1 participant