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

Dependency Ttrack makes Trivy-generated SBOM unusable to Trivy server #3721

Closed
2 tasks done
sec-p24 opened this issue May 16, 2024 · 13 comments · Fixed by #3727
Closed
2 tasks done

Dependency Ttrack makes Trivy-generated SBOM unusable to Trivy server #3721

sec-p24 opened this issue May 16, 2024 · 13 comments · Fixed by #3727
Labels
defect Something isn't working integration/trivy Related to the Trivy integration
Milestone

Comments

@sec-p24
Copy link

sec-p24 commented May 16, 2024

Current Behavior

I am trying to use recently added Trivy analyzer but in some cases Dependency Track transforms uploaded SBOM in a way that unables Trivy server to detect OS vulnerabilities correctly (see logs below).

trivy_1             | 2024-05-16T11:51:45.145Z  INFO    Detected OS: none
trivy_1             | 2024-05-16T11:51:45.145Z  WARN    unsupported os : none
trivy_1             | 2024-05-16T11:51:45.145Z  INFO    Number of language-specific files: 0

When I generate SBOM using Trivy and then specify the same Trivy server that is used by Dependency Track while analyzing then it works correctly:

2024-05-16T14:02:41.844+0200    INFO    Detected OS: alpine
2024-05-16T14:02:41.844+0200    INFO    Detecting Alpine vulnerabilities...
2024-05-16T14:02:41.845+0200    INFO    Number of language-specific files: 0

When I upload SBOM to Dependency Track either through UI or API then the same SBOM file does not show any vulnerabilities.

Steps to Reproduce

1.Create SBOM with Trivy. In my case the command is trivy image --format cyclonedx --output test.json php:7.4.10-fpm-alpine
2. Upload it to Dependency Track (either using UI or API)
3. In Dependency Track dependencies are correctly listed but no vulnerabilities are shown

Expected Behavior

Trivy server correctly parses SBOM uploaded to Dependency Track.

Dependency-Track Version

4.11.0

Dependency-Track Distribution

Container Image

Database Server

PostgreSQL

Database Server Version

15.0

Browser

N/A

Checklist

@sec-p24 sec-p24 added defect Something isn't working in triage labels May 16, 2024
@nscuro nscuro added the integration/trivy Related to the Trivy integration label May 16, 2024
@nscuro
Copy link
Member

nscuro commented May 16, 2024

cc @fnxpt

@sec-p24 Can you please share the version of Trivy you're using? Also sharing the exact SBOM you're uploading could help in reproducing this.

@sec-p24
Copy link
Author

sec-p24 commented May 16, 2024

My current production setup uses Trivy v0.49.1 to generate SBOM and Trivy v0.51.1 in server mode.
However I tested the same locally with both Trivy's v0.51.1 and the issue remains the same. I am attaching 2 SBOMs - one straight after it was generated with Trivy and the other one downloaded from Dependency Track UI (Download BOM -> Inventory).

After performing few additional tests I have noticed that when I access the Trivy server directly (through Trivy SBOM command, ommiting dtrack) then sometimes it parses the dtrack-proccessed SBOM file correctly, while other times it does not (like 50/50). When I upload the same file through Dependency Track, then it always fails it's assessment.

dt-processed-sbom.json
raw-trivy-sbom.json

@fnxpt
Copy link

fnxpt commented May 16, 2024

When I try to run the sbom locally on trivy I get this.

Screenshot 2024-05-16 at 16 22 50

@sec-p24
Copy link
Author

sec-p24 commented May 16, 2024

Trivy client logs:

$ trivy sbom --server http://localhost:7070 raw-trivy-sbom.json
2024-05-16T16:25:12.145+0200    INFO    Vulnerability scanning is enabled
2024-05-16T16:25:12.147+0200    INFO    Detected SBOM format: cyclonedx-json
2024-05-16T16:25:12.203+0200    WARN    This OS version is no longer supported by the distribution: alpine 3.12.0
2024-05-16T16:25:12.203+0200    WARN    The vulnerability detection may be insufficient because security updates are not provided

Trivy server logs:

$ docker run -p 7070:7070 aquasec/trivy:0.51.1 server --listen 0.0.0.0:7070
2024-05-16T14:25:01Z    INFO    Need to update DB
2024-05-16T14:25:01Z    INFO    Downloading DB...       repository="ghcr.io/aquasecurity/trivy-db:2"
2024-05-16T14:25:08Z    INFO    Listening 0.0.0.0:7070...
2024-05-16T14:25:12Z    INFO    Detected OS     family="alpine" version="3.12.0"
2024-05-16T14:25:12Z    INFO    [alpine] Detecting vulnerabilities...   os_version="3.12" repository="" pkg_num=31
2024-05-16T14:25:12Z    INFO    Number of language-specific files       num=0

@fnxpt
Copy link

fnxpt commented May 16, 2024

Generated a new sbom for that image using trivy and it worked

Screenshot 2024-05-16 at 16 41 55

@sec-p24
Copy link
Author

sec-p24 commented May 17, 2024

When I generated the SBOM for the same image as you did, uploading the file directly to Trivy server yielded different results than when it was uploaded to Dependency Track.
dtrack
trivy
trivy_server_logs

@fnxpt
Copy link

fnxpt commented May 17, 2024

Do you see the requests from DT arriving to trivy?
With the image you mentioned yesterday I was able to get some result... not all of them (i will check why)... but Im getting results

Screenshot 2024-05-17 at 12 07 34

@sec-p24
Copy link
Author

sec-p24 commented May 17, 2024

Few things to clarify.

  1. In my initial comment I generated SBOM for php:7.4.10-fpm-alpine docker image, not the trivy image itself.
  2. The from Trivy (see last screenshot from my previous message) suggest SBOM arrive correctly there. The same goes for Dependency Track API logs which suggest successful analysis:
2024-05-17 10:08:15,600 INFO [TrivyAnalysisTask] Starting Trivy vulnerability analysis task
2024-05-17 10:08:15,813 INFO [TrivyAnalysisTask] Trivy vulnerability analysis complete

If there is a better way to confirm the arrival, please let me know.
3. Anyway, notice that you are getting results from language-based component only, but not OS-related packages. Looks like the issue might with OS detection on Trivy side when the SBOM is passed from DT.

@fnxpt
Copy link

fnxpt commented May 17, 2024

Ok I confirm its not working as expected, I will try to debug it later today

@fnxpt
Copy link

fnxpt commented May 17, 2024

I think I found the issue, just need to do some testing...

@fnxpt
Copy link

fnxpt commented May 17, 2024

@sec-p24 Issue fixed, PR is failing due to issues with dependencies
@nscuro any ideia what could be the issue, i saw in the logs that there were a few changes on the dependencies 2 days ago

for the php:7.4.10-fpm-alpine
Screenshot 2024-05-17 at 17 39 47

for the aquasec/trivy:0.51.1
Screenshot 2024-05-17 at 17 36 30

@nscuro
Copy link
Member

nscuro commented May 17, 2024

@fnxpt The build failures are related to #3726 and the corresponding changes in Alpine. I'll get that PR merged, then your build should pass.

Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
defect Something isn't working integration/trivy Related to the Trivy integration
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants