spire-server-fips
1.9.4-r2
4.2
CVSS V3
Cosign malicious attachments can cause system-wide denial of service
A remote image with a malicious attachment can cause denial of service of the host machine running Cosign. This can impact other services on the machine that rely on having memory available such as a Redis database which can result in data loss. It can also impact the availability of other services on the machine that will not be available for the duration of the machine denial.
The root cause of this issue is that Cosign reads the attachment from a remote image entirely into memory without checking the size of the attachment first. As such, a large attachment can make Cosign read a large attachment into memory; If the attachments size is larger than the machine has memory available, the machine will be denied of service. The Go runtime will make a SIGKILL
after a few seconds of system-wide denial.
The root cause is that Cosign reads the contents of the attachments entirely into memory on line 238 below:
...and prior to that, neither Cosign nor go-containerregistry checks the size of the attachment and enforces a max cap. In the case of a remote layer of f *attached
, go-containerregistry will invoke this API:
Notice that the second argument to rl.fetcher.fetchBlob
is verify.SizeUnknown
which results in not using the io.LimitReader
in verify.ReadCloser
:
https://github.com/google/go-containerregistry/blob/a0658aa1d0cc7a7f1bcc4a3af9155335b6943f40/internal/verify/verify.go#L82-L100
This issue can allow a supply-chain escalation from a compromised registry to the Cosign user: If an attacher has compromised a registry or the account of an image vendor, they can include a malicious attachment and hurt the image consumer.
Update to the latest version of Cosign, which limits the number of attachments. An environment variable can override this value.