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 (
2424 "encoding/pem"
2525 "errors"
2626 "fmt"
27+ "io"
2728 "net/http"
2829 "strings"
2930
4950 // ErrProvenanceNotFoundOrIncomplete is returned when there's no provenance info (missing .sig or attestation) or
5051 // has incomplete data
5152 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
5257)
5358
5459const (
@@ -291,8 +296,9 @@ func getAttestationReply(
291296 }
292297 defer resp .Body .Close ()
293298
299+ lr := io .LimitReader (resp .Body , MaxAttestationsBytesLimit )
294300 var attestationReply AttestationReply
295- if err := json .NewDecoder (resp . Body ).Decode (& attestationReply ); err != nil {
301+ if err := json .NewDecoder (lr ).Decode (& attestationReply ); err != nil {
296302 return nil , fmt .Errorf ("error decoding response: %w" , err )
297303 }
298304
@@ -446,7 +452,8 @@ func getSimpleSigningLayersFromSignatureManifest(manifestRef string, auth authn.
446452 }
447453
448454 // 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 )
450457 if err != nil {
451458 return nil , fmt .Errorf ("error parsing signature manifest: %w" , err )
452459 }
You can’t perform that action at this time.
0 commit comments