Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/cmd/release/shared/attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (v *AttestationVerifier) VerifyAttestation(art *artifact.DigestedArtifact,
return nil, err
}

policy := buildVerificationPolicy(*art)
policy := buildVerificationPolicy(*art, td)
sigstoreVerified, err := verifier.Verify([]*api.Attestation{att}, policy)
if err != nil {
return nil, err
Expand Down Expand Up @@ -99,9 +99,13 @@ func FilterAttestationsByFileDigest(attestations []*api.Attestation, fileDigest
}

// buildVerificationPolicy constructs a verification policy for GitHub releases
func buildVerificationPolicy(a artifact.DigestedArtifact) verify.PolicyBuilder {
func buildVerificationPolicy(a artifact.DigestedArtifact, trustDomain string) verify.PolicyBuilder {
// If no trust domain is specified, default to "dotcom"
if trustDomain == "" {
trustDomain = "dotcom"
}
// SAN must match the GitHub releases domain. No issuer extension (match anything)
sanMatcher, _ := verify.NewSANMatcher("", "^https://.*\\.releases\\.github\\.com$")
sanMatcher, _ := verify.NewSANMatcher("", fmt.Sprintf("^https://%s\\.releases\\.github\\.com$", trustDomain))
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The trust domain parameter is directly interpolated into a regex pattern without validation or sanitization. This could allow regex injection attacks if the trust domain contains special regex characters. Consider validating the trust domain against an allowlist or escaping regex special characters using regexp.QuoteMeta().

Suggested change
sanMatcher, _ := verify.NewSANMatcher("", fmt.Sprintf("^https://%s\\.releases\\.github\\.com$", trustDomain))
escapedTrustDomain := regexp.QuoteMeta(trustDomain)
sanMatcher, _ := verify.NewSANMatcher("", fmt.Sprintf("^https://%s\\.releases\\.github\\.com$", escapedTrustDomain))

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error from verify.NewSANMatcher is being ignored with blank identifier. Given that the regex pattern is now dynamically constructed, this error should be handled to catch potential regex compilation failures.

Copilot uses AI. Check for mistakes.
issuerMatcher, _ := verify.NewIssuerMatcher("", ".*")
certId, _ := verify.NewCertificateIdentity(sanMatcher, issuerMatcher, certificate.Extensions{})

Expand Down
Loading