Repository navigation
Replies: 1 comment
|
Hi @junjae79! Thanks for the detailed report and the reproduction script — it helped a lot. Your analysis is correct. I opened a fix in Until then, you can use one of these workarounds:
As for #10338 — the error signature is the same, so it is most likely the same case. Regards, Dmitriy |
Uh oh!
There was an error while loading. Please reload this page.
Description
trivy image --input <file>fails witharchive/tar: invalid tar header(orunexpected EOFfor small layers) when a docker-save archive contains layers with mixed compression: layer 0 is an uncompressed tar blob while a later layer blob is gzip — even though every layer's mediaType is declared correctly and every blob is individually valid.Reversing the order (gzip layer first, uncompressed layer later) scans fine. This asymmetry suggests the tarball reading path decides compression once (from the first layer) and applies it to all layers, instead of detecting per layer. When the first layer is uncompressed, subsequent gzip blobs are parsed as raw tar and fail at the first header block (large blob →
invalid tar header; blob smaller than ~1.5 tar blocks →unexpected EOF).This is not a synthetic-only situation. Docker Engine with the containerd image store (default for fresh installs since v28/v29) exports each layer blob in whatever form it is stored:
docker load(common in air-gapped environments) keep uncompressed layer representations;docker saveof such an image produces exactly the failing mix (first layers uncompressed, later layers gzip). Both--input file.tarand the daemon path (--image-src docker, which streams the same export) fail. GNU tar,docker load, andgzip -tall handle the same archive without complaint.Probably related: #10338 (identical error signature on a pulled base image; closed without root-cause resolution).
Desired Behavior
Layer compression is detected per layer (e.g. magic-byte peek per blob, or honoring each layer's declared mediaType), so mixed-compression docker-save archives scan successfully.
Actual Behavior
For a gzip layer blob smaller than ~1.5 tar blocks the error is
unexpected EOFinstead.Reproduction Steps
No docker needed — the following python3 script synthesizes two docker-save-style archives that differ only in layer order:
Notes from further bisecting (all of these pass, so they are ruled out): a gzip blob whose mediaType declares uncompressed
v1.tar, trailing garbage after the gzip stream, concatenated gzip members, missing tar end-of-archive blocks, manifestsizefield mismatches,application/vnd.docker.image.rootfs.diff.tar.gzipinside an OCI manifest. Only the "uncompressed first layer + gzip later layer" combination fails.Real-world chain (verified on Docker Engine 29.3.1 and 29.9.3, containerd image store,
driver: overlayfs): base image brought in withdocker load(uncompressed blobs) + image built FROM it (classic builder or BuildKit commit gzip blobs) →docker saveemits uncompressed-first mixed archive →trivy imagefails on both--inputand--image-src docker, whiledocker load, GNU tar andgzip -tall accept the archive.Target
Container Image
Scanner
Vulnerability (also reproducible with Secret scanner alone, so no DB is needed)
Output Format
Table
Mode
Standalone
Operating System
Linux (reproduced in container; also on Windows host)
Version
All reactions