Skip to content

Unbounded loop over untrusted input can lead to endless data attack

Low
haydentherapper published GHSA-cq38-jh5f-37mq Sep 4, 2024

Package

gomod sigstore-go (Go)

Affected versions

<= 0.6.0

Patched versions

0.6.1

Description

Impact

sigstore-go is susceptible to a denial of service attack when a verifier is provided a maliciously crafted Sigstore Bundle containing large amounts of verifiable data, in the form of signed transparency log entries, RFC 3161 timestamps, and attestation subjects. The verification of these data structures is computationally expensive. This can be used to consume excessive CPU resources, leading to a denial of service attack. TUF's security model labels this type of vulnerability an "Endless data attack," and can lead to verification failing to complete and disrupting services that rely on sigstore-go for verification.

The vulnerable loops are in the verification functions in the package github.com/sigstore/sigstore-go/pkg/verify. The first is the DSSE envelope verification loop in verifyEnvelopeWithArtifact, which decodes all the digests in an attestation can be found here:

for _, subject := range statement.Subject {
for alg, digest := range subject.Digest {
hexdigest, err := hex.DecodeString(digest)
if err != nil {
return fmt.Errorf("could not verify artifact: unable to decode subject digest: %w", err)
}
if alg == artifactDigestAlgorithm && bytes.Equal(artifactDigest, hexdigest) {
return nil
}
}
}

The next loop is in the VerifyArtifactTransparencyLog function, which verifies all the signed entries in a bundle:

for _, entry := range entries {
err := tlog.ValidateEntry(entry)
if err != nil {
return nil, err
}
if !online {
if !entry.HasInclusionPromise() && !entry.HasInclusionProof() {
return nil, fmt.Errorf("entry must contain an inclusion proof and/or promise")
}
if entry.HasInclusionPromise() {
err = tlog.VerifySET(entry, trustedMaterial.RekorLogs())
if err != nil {
// skip entries the trust root cannot verify
continue
}
if trustIntegratedTime {
verifiedTimestamps = append(verifiedTimestamps, entry.IntegratedTime())
}
}
if entity.HasInclusionProof() {
keyID := entry.LogKeyID()
hex64Key := hex.EncodeToString([]byte(keyID))
tlogVerifier, ok := trustedMaterial.RekorLogs()[hex64Key]
if !ok {
// skip entries the trust root cannot verify
continue
}
verifier, err := getVerifier(tlogVerifier.PublicKey, tlogVerifier.SignatureHashFunc)
if err != nil {
return nil, err
}
err = tlog.VerifyInclusion(entry, *verifier)
if err != nil {
return nil, err
}
// DO NOT use timestamp with only an inclusion proof, because it is not signed metadata
}
} else {
keyID := entry.LogKeyID()
hex64Key := hex.EncodeToString([]byte(keyID))
tlogVerifier, ok := trustedMaterial.RekorLogs()[hex64Key]
if !ok {
// skip entries the trust root cannot verify
continue
}
client, err := getRekorClient(tlogVerifier.BaseURL)
if err != nil {
return nil, err
}
verifier, err := getVerifier(tlogVerifier.PublicKey, tlogVerifier.SignatureHashFunc)
if err != nil {
return nil, err
}
logIndex := entry.LogIndex()
searchParams := rekorEntries.NewGetLogEntryByIndexParams()
searchParams.LogIndex = logIndex
resp, err := client.Entries.GetLogEntryByIndex(searchParams)
if err != nil {
return nil, err
}
if len(resp.Payload) == 0 {
return nil, fmt.Errorf("unable to locate log entry %d", logIndex)
}
logEntry := resp.Payload
for _, v := range logEntry {
v := v
err = rekorVerify.VerifyLogEntry(context.TODO(), &v, *verifier)
if err != nil {
return nil, err
}
}
if trustIntegratedTime {
verifiedTimestamps = append(verifiedTimestamps, entry.IntegratedTime())
}
}
// Ensure entry signature matches signature from bundle
if !bytes.Equal(entry.Signature(), entitySignature) {
return nil, errors.New("transparency log signature does not match")
}
// Ensure entry certificate matches bundle certificate
if !verificationContent.CompareKey(entry.PublicKey(), trustedMaterial) {
return nil, errors.New("transparency log certificate does not match")
}
// TODO: if you have access to artifact, check that it matches body subject
// Check tlog entry time against bundle certificates
if !verificationContent.ValidAtTime(entry.IntegratedTime(), trustedMaterial) {
return nil, errors.New("integrated time outside certificate validity")
}
// successful log entry verification
logEntriesVerified++
}

The next loop is the VerifyTimestampAuthority function, which verifies all the RFC 3161 timestamps in a bundle:

for _, timestamp := range signedTimestamps {
verifiedSignedTimestamp, err := verifySignedTimestamp(timestamp, signatureBytes, trustedMaterial, verificationContent)
// Timestamps from unknown source are okay, but don't count as verified
if err != nil {
continue
}
verifiedTimestamps = append(verifiedTimestamps, verifiedSignedTimestamp)
}

Patches

This vulnerability is addressed with sigstore-go 0.6.1, which adds hard limits to the number of verifiable data structures that can be processed in a bundle. Verification will fail if a bundle has data that exceeds these limits. The limits are:

  • 32 signed transparency log entries
  • 32 RFC 3161 timestamps
  • 1024 attestation subjects
  • 32 digests per attestation subject

These limits are intended to be high enough to accommodate the vast majority of use cases, while preventing the verification of maliciously crafted bundles that contain large amounts of verifiable data.

Workarounds

The best way to mitigate the risk is to upgrade to sigstore-go 0.6.1 or later. Users who are vulnerable but unable to quickly upgrade may consider adding manual bundle validation to enforce limits similar to those in the referenced patch prior to calling sigstore-go's verification functions.

Severity

Low

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
High
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
None
Integrity
None
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:N/A:L

CVE ID

CVE-2024-45395

Weaknesses

No CWEs

Credits