File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
internal/verifier/sigstore/container Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import (
24
24
"encoding/pem"
25
25
"errors"
26
26
"fmt"
27
+ "io"
27
28
"net/http"
28
29
"strings"
29
30
49
50
// ErrProvenanceNotFoundOrIncomplete is returned when there's no provenance info (missing .sig or attestation) or
50
51
// has incomplete data
51
52
ErrProvenanceNotFoundOrIncomplete = errors .New ("provenance not found or incomplete" )
53
+
54
+ // MaxAttestationsBytesLimit is the maximum number of bytes we're willing to read from the attestation endpoint
55
+ // We'll limit this to 10mb for now
56
+ MaxAttestationsBytesLimit int64 = 10 * 1024 * 1024
52
57
)
53
58
54
59
const (
@@ -291,8 +296,9 @@ func getAttestationReply(
291
296
}
292
297
defer resp .Body .Close ()
293
298
299
+ lr := io .LimitReader (resp .Body , MaxAttestationsBytesLimit )
294
300
var attestationReply AttestationReply
295
- if err := json .NewDecoder (resp . Body ).Decode (& attestationReply ); err != nil {
301
+ if err := json .NewDecoder (lr ).Decode (& attestationReply ); err != nil {
296
302
return nil , fmt .Errorf ("error decoding response: %w" , err )
297
303
}
298
304
@@ -446,7 +452,8 @@ func getSimpleSigningLayersFromSignatureManifest(manifestRef string, auth authn.
446
452
}
447
453
448
454
// Parse the manifest
449
- manifest , err := v1 .ParseManifest (bytes .NewReader (mf ))
455
+ r := io .LimitReader (bytes .NewReader (mf ), MaxAttestationsBytesLimit )
456
+ manifest , err := v1 .ParseManifest (r )
450
457
if err != nil {
451
458
return nil , fmt .Errorf ("error parsing signature manifest: %w" , err )
452
459
}
You can’t perform that action at this time.
0 commit comments