Skip to content

Commit 13a24b7

Browse files
committed
attestation: forbid provenance attestations from frontend
Signed-off-by: Justin Chadwell <[email protected]>
1 parent 24807f5 commit 13a24b7

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

exporter/attestation/unbundle.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"os"
77
"path"
8+
"strings"
89

910
"github.com/containerd/continuity/fs"
1011
intoto "github.com/in-toto/in-toto-golang/in_toto"
@@ -32,6 +33,12 @@ func Unbundle(ctx context.Context, s session.Group, bundled []exporter.Attestati
3233
eg.Go(func() error {
3334
switch att.Kind {
3435
case gatewaypb.AttestationKindInToto:
36+
if strings.HasPrefix(att.InToto.PredicateType, "https://slsa.dev/provenance/") {
37+
if att.ContentFunc == nil {
38+
// provenance may only be set buildkit-side using ContentFunc
39+
return errors.New("frontend may not set provenance attestations")
40+
}
41+
}
3542
unbundled[i] = append(unbundled[i], att)
3643
case gatewaypb.AttestationKindBundle:
3744
if att.ContentFunc != nil {
@@ -56,6 +63,11 @@ func Unbundle(ctx context.Context, s session.Group, bundled []exporter.Attestati
5663
if err != nil {
5764
return err
5865
}
66+
for _, att := range atts {
67+
if strings.HasPrefix(att.InToto.PredicateType, "https://slsa.dev/provenance/") {
68+
return errors.New("frontend may not bundle provenance attestations")
69+
}
70+
}
5971
unbundled[i] = append(unbundled[i], atts...)
6072
}
6173
return nil
@@ -71,8 +83,8 @@ func Unbundle(ctx context.Context, s session.Group, bundled []exporter.Attestati
7183
}
7284

7385
if err := Validate(joined); err != nil {
74-
return nil, err
75-
}
86+
return nil, err
87+
}
7688
return joined, nil
7789
}
7890

0 commit comments

Comments
 (0)