Repository navigation
OCI Tarballs not working #5135
DescriptionBuildkit (and Docker when using the buildx plugin) exports an OCI image as a tar file when building with Desired BehaviorFor it to successfully scan the image. Actual BehaviorError message Reproduction Steps1. Use buildkit to build a sample dockerfile with `buildctl build --frontend=dockerfile.v0 --local context=. --local dockerfile=. --output type=oci,dest=path/to/output.tar`
2. `trivy image --input output.tarTargetContainer Image ScannerVulnerability Output FormatNone ModeNone Debug Output2023-09-06T21:06:36.996-0500 DEBUG Severities: ["UNKNOWN" "LOW" "MEDIUM" "HIGH" "CRITICAL"]
2023-09-06T21:06:36.997-0500 DEBUG Ignore statuses {"statuses": null}
2023-09-06T21:06:37.007-0500 DEBUG cache dir: /home/reilly/.cache/trivy
2023-09-06T21:06:37.007-0500 DEBUG DB update was skipped because the local DB is the latest
2023-09-06T21:06:37.007-0500 DEBUG DB Schema: 2, UpdatedAt: 2023-09-07 00:26:18.880588019 +0000 UTC, NextUpdate: 2023-09-07 06:26:18.880587319 +0000 UTC, DownloadedAt: 2023-09-07 01:26:59.398513802 +0000 UTC
2023-09-06T21:06:37.007-0500 INFO Vulnerability scanning is enabled
2023-09-06T21:06:37.007-0500 DEBUG Vulnerability type: [os library]
2023-09-06T21:06:37.007-0500 INFO Secret scanning is enabled
2023-09-06T21:06:37.007-0500 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2023-09-06T21:06:37.007-0500 INFO Please see also https://aquasecurity.github.io/trivy/v0.45/docs/scanner/secret/#recommendation for faster secret detection
2023-09-06T21:06:37.014-0500 FATAL image scan error:
github.com/aquasecurity/trivy/pkg/commands/artifact.Run
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:424
- scan error:
github.com/aquasecurity/trivy/pkg/commands/artifact.(*runner).scanArtifact
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:268
- unable to initialize a scanner:
github.com/aquasecurity/trivy/pkg/commands/artifact.scan
/home/runner/work/trivy/trivy/pkg/commands/artifact/run.go:679
- unable to initialize the archive scanner:
github.com/aquasecurity/trivy/pkg/commands/artifact.archiveStandaloneScanner
/home/runner/work/trivy/trivy/pkg/commands/artifact/scanner.go:27
- 2 errors occurred:
* unable to open output.tar as a Docker image: file manifest.json not found in tar
* unable to open output.tar as an OCI Image: stat output.tar/index.json: not a directoryOperating SystemLinux VersionVersion: 0.45.0
Vulnerability DB:
Version: 2
UpdatedAt: 2023-09-07 00:26:18.880588019 +0000 UTC
NextUpdate: 2023-09-07 06:26:18.880587319 +0000 UTC
DownloadedAt: 2023-09-07 01:26:59.398513802 +0000 UTCChecklist
|
Replies: 5 comments 1 reply
|
I can reproduce. In the long run, trivy should definitely support OCI tarballs |
|
As a last note, you need v0.12.x+ to reproduce this, since there was a bug before which would include the manifest.json, this has since been fixed, see: moby/buildkit#4131 |
|
Hello! |
|
Hello everyone! We do not currently support OCI tar images - https://aquasecurity.github.io/trivy/v0.48/docs/target/container_image/#tar-files. To avoid compressing images in ➜ buildkit git:(master) ✗ docker buildx build -o type=oci,tar=false,dest=myimage .
...
➜ buildkit git:(master) ✗ trivy image --input myimage
2023-12-12T14:00:38.631+0600 INFO Vulnerability scanning is enabled
2023-12-12T14:00:38.632+0600 INFO Secret scanning is enabled
2023-12-12T14:00:38.632+0600 INFO If your scanning is slow, please try '--scanners vuln' to disable secret scanning
2023-12-12T14:00:38.632+0600 INFO Please see also https://aquasecurity.github.io/trivy/v0.48/docs/scanner/secret/#recommendation for faster secret detection
2023-12-12T14:00:38.641+0600 INFO Detected OS: alpine
2023-12-12T14:00:38.641+0600 INFO Detecting Alpine vulnerabilities...
2023-12-12T14:00:38.645+0600 INFO Number of language-specific files: 3
2023-12-12T14:00:38.645+0600 INFO Detecting gobinary vulnerabilities...
myimage (alpine 3.18.5)
Total: 0 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 0, CRITICAL: 0)
usr/bin/buildctl (gobinary)
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
┌──────────────────────────────────────────────────────────────┬────────────────┬──────────┬────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
├──────────────────────────────────────────────────────────────┼────────────────┼──────────┼────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ go.opentelemetry.io/contrib/instrumentation/google.golang.o- │ CVE-2023-47108 │ HIGH │ fixed │ v0.45.0 │ 0.46.0 │ opentelemetry-go-contrib: DoS vulnerability in otelgrpc due │
│ rg/grpc/otelgrpc │ │ │ │ │ │ to unbound cardinality metrics │
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2023-47108 │
└──────────────────────────────────────────────────────────────┴────────────────┴──────────┴────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘
usr/bin/buildkit-runc (gobinary)
Total: 4 (UNKNOWN: 0, LOW: 0, MEDIUM: 3, HIGH: 1, CRITICAL: 0)
┌───────────────────────────────────────┬─────────────────────┬──────────┬────────┬───────────────────┬───────────────┬──────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
├───────────────────────────────────────┼─────────────────────┼──────────┼────────┼───────────────────┼───────────────┼──────────────────────────────────────────────────────────────┤
│ github.com/cyphar/filepath-securejoin │ GHSA-6xv5-86q9-7xr8 │ MEDIUM │ fixed │ v0.2.3 │ 0.2.4 │ SecureJoin: on windows, paths outside of the rootfs could be │
│ │ │ │ │ │ │ inadvertently produced... │
│ │ │ │ │ │ │ https://github.com/advisories/GHSA-6xv5-86q9-7xr8 │
├───────────────────────────────────────┼─────────────────────┼──────────┤ ├───────────────────┼───────────────┼──────────────────────────────────────────────────────────────┤
│ golang.org/x/net │ CVE-2023-39325 │ HIGH │ │ v0.8.0 │ 0.17.0 │ golang: net/http, x/net/http2: rapid stream resets can cause │
│ │ │ │ │ │ │ excessive work (CVE-2023-44487) │
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2023-39325 │
│ ├─────────────────────┼──────────┤ │ ├───────────────┼──────────────────────────────────────────────────────────────┤
│ │ CVE-2023-3978 │ MEDIUM │ │ │ 0.13.0 │ golang.org/x/net/html: Cross site scripting │
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2023-3978 │
│ ├─────────────────────┤ │ │ ├───────────────┼──────────────────────────────────────────────────────────────┤
│ │ CVE-2023-44487 │ │ │ │ 0.17.0 │ HTTP/2: Multiple HTTP/2 enabled web servers are vulnerable │
│ │ │ │ │ │ │ to a DDoS attack... │
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2023-44487 │
└───────────────────────────────────────┴─────────────────────┴──────────┴────────┴───────────────────┴───────────────┴──────────────────────────────────────────────────────────────┘
usr/bin/buildkitd (gobinary)
Total: 1 (UNKNOWN: 0, LOW: 0, MEDIUM: 0, HIGH: 1, CRITICAL: 0)
┌──────────────────────────────────────────────────────────────┬────────────────┬──────────┬────────┬───────────────────┬───────────────┬─────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
├──────────────────────────────────────────────────────────────┼────────────────┼──────────┼────────┼───────────────────┼───────────────┼─────────────────────────────────────────────────────────────┤
│ go.opentelemetry.io/contrib/instrumentation/google.golang.o- │ CVE-2023-47108 │ HIGH │ fixed │ v0.45.0 │ 0.46.0 │ opentelemetry-go-contrib: DoS vulnerability in otelgrpc due │
│ rg/grpc/otelgrpc │ │ │ │ │ │ to unbound cardinality metrics │
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2023-47108 │
└──────────────────────────────────────────────────────────────┴────────────────┴──────────┴────────┴───────────────────┴───────────────┴─────────────────────────────────────────────────────────────┘But Regards, Dmitriy |

Hello everyone!
We do not currently support OCI tar images - https://aquasecurity.github.io/trivy/v0.48/docs/target/container_image/#tar-files.
But we support image directories for OCI images - https://aquasecurity.github.io/trivy/v0.48/docs/target/container_image/#oci-layout.
To avoid compressing images in
tarusingbuildx, usetarparameter - https://docs.docker.com/build/exporters/oci-docker/e.g.:
➜ buildkit git:(master) ✗ docker buildx build -o type=oci,tar=false,dest=myimage . ... ➜ buildkit git:(master) ✗ trivy image --input myimage 2023-12-12T14:00:38.631+0600 INFO Vulnerability scanning is enabled 2023-12-12T14:00:38.632+0600 INFO Secret scanning is enabled 2023-12-12T14:00:3…