Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong image digest set as version in cyclonedx output #435

Open
cjnosal opened this issue Sep 29, 2021 · 3 comments
Open

Wrong image digest set as version in cyclonedx output #435

cjnosal opened this issue Sep 29, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@cjnosal
Copy link
Contributor

cjnosal commented Sep 29, 2021

What happened:
When generating a cyclonedx report of an image the manifest digest is set in bom.metadata.component.version (though the name is set to image@${image digest})

What you expected to happen:
bom.metadata.component.version should match the image digest

How to reproduce it (as minimally and precisely as possible):

DIGEST=$(crane digest nginx:1.16)
grype nginx@$DIGEST -o cyclonedx

Anything else we need to know?:

Environment:

  • Output of grype version: 0.21.0
  • OS (e.g: cat /etc/os-release or similar): ubuntu bionic
@cjnosal cjnosal added the bug Something isn't working label Sep 29, 2021
@luhring
Copy link
Contributor

luhring commented Oct 6, 2021

Adding a link to the related (and currently ongoing) thread in our community Slack: https://anchorecommunity.slack.com/archives/C027JE5M345/p1629141976015600

We can update this issue when we get more clarity on an acceptable path forward.

@luhring
Copy link
Contributor

luhring commented Oct 29, 2021

Follow up on this — there's a few action items to note:

Re: wrong digest in CycloneDX (this issue)

Confirmed. In CycloneDX output, Grype sets the bom.metadata.component.version field to what stereoscope has determined is the "manifest digest" (link to code).

Example output:

<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.2" xmlns:v="http://cyclonedx.org/schema/ext/vulnerability/1.0" version="1" serialNumber="urn:uuid:6bc35dd2-bc2d-4fb7-b7a0-6babeab88eec">
  <metadata>
    ...
    <component type="container">
      <name>ubuntu@sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322</name>
-->   <version>sha256:5c163b73006137467cde89dafc24d7a071f0a312757c2cd90933c052e399cc51</version>
    </component>
  </metadata>
...

The problem is that, currently, this ManifestDigest value from stereoscope cannot be relied on as the image's real manifest digest. This is because there's a case where stereoscope doesn't actually have access to the OCI manifest from the registry — when we're retrieving a container image from the Docker daemon — and so stereoscope creates a new OCI manifest on the fly.

Stereoscope shouldn't do this. I've opened an issue in stereoscope for more context and discussion: anchore/stereoscope#83. Once that issue is completed, we should update Syft and Grype to use the latest of stereoscope. We'll keep this issue (grype#435) open until that's done and the solution is verified in Grype.

Re: lack of transparency about image digest selection

In the Slack discussion, a separate concern was identified:

Our tools are not being transparent in their output about how they selected the exact image to scan, in the case where the user requested a scan of an image without referring to exactly one manifest digest — i.e. they specified a manifest list digest, or an image tag.

For this, I've opened a dedicated issue: #485

@spiffcs spiffcs added this to OSS Jun 1, 2022
@spiffcs spiffcs moved this to Triage (Comments or Progress Made) in OSS Jun 1, 2022
@spiffcs spiffcs removed the status in OSS Jul 19, 2022
@spiffcs spiffcs moved this to Backlog (Pulled Forward for Priority) in OSS Jul 19, 2022
@spiffcs spiffcs moved this from Backlog (Pulled Forward for Priority) to In Progress (Actively Resolving) in OSS Jul 19, 2022
@spiffcs spiffcs self-assigned this Jul 19, 2022
@spiffcs spiffcs moved this from In Progress (Actively Resolving) to Parking Lot (Comments or Progress Made) in OSS Jul 29, 2022
@tgerla tgerla moved this from Awaiting Response to False Positives in OSS Jan 26, 2023
@tgerla tgerla removed the status in OSS Jan 26, 2023
@kzantow
Copy link
Contributor

kzantow commented Jan 26, 2023

We should definitely make sure that these values match, that both represent the image at the version that was pulled.

@kzantow kzantow moved this to Backlog in OSS Jan 26, 2023
@spiffcs spiffcs moved this from Backlog to In Progress in OSS Jun 15, 2023
@spiffcs spiffcs moved this from In Progress to Backlog in OSS Jul 27, 2023
@spiffcs spiffcs moved this from Backlog to In Progress in OSS Jul 27, 2023
@spiffcs spiffcs moved this from In Progress to Backlog in OSS Sep 14, 2023
@spiffcs spiffcs moved this from Backlog to In Progress in OSS Sep 21, 2023
@spiffcs spiffcs removed their assignment Apr 23, 2024
@spiffcs spiffcs moved this from In Progress to Backlog in OSS Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

4 participants