# GHSA-PGPM-J729-QCVH: Cross-step artifact comparison downgrades to the weakest shared hash, allowing SHA-1-collision artifact substitution

- Database: GitHub
- Severity: CVSS 1.0 (Low)
- Published: 2026-07-10
- Modified: 2026-08-20

## Tracked as

- [CVE-2026-77305](https://cve.now/CVE-2026-77305.md): go-witness: Cross-step artifact comparison downgrades to the weakest shared hash, allowing SHA-1-collision artifact substitution

## Affected versions

- github.com/in-toto/go-witness (Go): through v0.11.0
- github.com/in-toto/witness (Go): through v0.11.0

## Description

## Summary

Artifact equality silently downgrades to the weakest hash function the two digest sets have in
common. An attacker who presents an artifact described only by a weak digest (SHA-1) is deemed equal
to a fully-described trusted artifact when the SHA-1 values match, even though the strong (SHA-256)
digests differ or are absent.

## Impact

Integrity-check downgrade on the cross-step artifact chain. Any policy that relies on `artifactsFrom`
to enforce that one step consumes the artifacts produced by another can be satisfied with a file that
differs under SHA-256 but collides under SHA-1, letting a tampered artifact pass as the trusted one.
The scope is integrity (not confidentiality or availability).

**Real-world exploitation conditions.** The attacker needs:

1. **Functionary access to one linked step**, so they can submit a collection whose material/product
   digest set they control (`PR:H`).
2. **A SHA-1 (chosen-prefix) collision** with the target artifact. These are demonstrated and within
   reach of a resourced attacker, which is why attack complexity is rated High (`AC:H`).

Given both, the inter-step integrity guarantee is broken without detection. Deployments that pin only
SHA-256 in their own tooling are still exposed, because the comparison accepts a SHA-1-only
counterparty.

## Details

`DigestSet.Equal` (`cryptoutil/digestset.go:128-144`) compares only the hash functions the two sets
have **in common**, and returns true if any common-hash digest matches and none differ:

```go
func (ds *DigestSet) Equal(second DigestSet) bool {
    hasMatchingDigest := false
    for hash, digest := range *ds {
        otherDigest, ok := second[hash]
        if !ok { continue }            // a hash present on only one side is ignored
        if digest == otherDigest { hasMatchingDigest = true } else { return false }
    }
    return hasMatchingDigest
}
```

If the attacker's digest set omits the strong hash, the strong hash is never compared (`continue`),
and equality reduces to whatever weak algorithm both sides happen to carry. The comparison strength
therefore collapses to the weakest shared algorithm, and a SHA-1-only set can be declared equal to a
SHA-256+SHA-1 artifact on the basis of the SHA-1 value alone.

This `Equal` is the integrity primitive behind `compareArtifacts` (`policy/policy.go:396-413`), which
enforces that a step's materials match the artifacts of the step it references via `artifactsFrom`.
A downgrade here means inter-step file integrity can be satisfied by a colliding-but-different file.

## Proof of Concept

No CLI-only PoC is provided: `witness run` always records artifact digests with SHA-256 (and gitoid),
so a SHA-1-only digest set cannot be produced through the standard tool. Exercising the downgrade
requires a hand-crafted or tampered collection (which an attacker who controls a functionary can
produce) or a custom attestor. The defect in the comparison primitive is isolated directly by the
following standalone Go test, which depends on no helpers:

```
git clone https://github.com/in-toto/go-witness && cd go-witness
git checkout v0.11.0   # also present in v0.10.0; the affected file is identical in both
# save the code below as cryptoutil/digestset_security_test.go, then:
go test ./cryptoutil/ -run TestDigestSetEqualHashDowngrade -v
```

It **fails** (the secure assertion does not hold), demonstrating the downgrade:

```go
package cryptoutil

import (
	"crypto"
	"testing"

	"github.com/stretchr/testify/require"
)

func TestDigestSetEqualHashDowngrade(t *testing.T) {
	sha256 := DigestValue{Hash: crypto.SHA256}
	sha1 := DigestValue{Hash: crypto.SHA1}

	// Trusted artifact, fully described: strong (SHA-256) + weak (SHA-1).
	trusted := DigestSet{
		sha256: "3b1f2e8c9d4a5b6c7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f9012345abcd",
		sha1:   "da39a3ee5e6b4b0d3255bfef95601890afd80709",
	}
	// Attacker artifact OMITS the strong hash and matches only on the weak one. Different file.
	attacker := DigestSet{
		sha1: "da39a3ee5e6b4b0d3255bfef95601890afd80709",
	}

	// SECURE EXPECTATION: equality must not downgrade to the weakest shared hash. A set lacking
	// the strong digest must not compare equal to one that has it.
	require.False(t, trusted.Equal(attacker),
		"DigestSet.Equal downgrades to the weakest shared hash; a SHA-1-only digest is accepted "+
			"as equal to a SHA-256 artifact (cryptoutil/digestset.go:128)")
}
```

End to end, an attacker who controls one step's collection (a functionary for that step) supplies a
material or product described only by `sha1:<X>`, where `<X>` is a SHA-1 collision of the trusted
artifact. `compareArtifacts` then treats the tampered file as identical across the `artifactsFrom`
boundary, and the downstream step accepts it.

## Suggested fix

Do not let equality reduce to the weakest shared algorithm. Require agreement on the strongest hash
present on either side, or refuse to compare (treat as not-equal / error) when the strongest
available algorithm is absent on one side. At minimum, never accept a SHA-1-only match for an
artifact that also carries SHA-256.

## References

- https://github.com/in-toto/go-witness/security/advisories/GHSA-pgpm-j729-qcvh

Page: https://cve.now/GHSA-PGPM-J729-QCVH

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
