Skip to content

vendor: github.com/moby/go-archive v0.3.0 - #6964

Open
thaJeztah wants to merge 1 commit into
moby:masterfrom
thaJeztah:bump_go_archive
Open

vendor: github.com/moby/go-archive v0.3.0#6964
thaJeztah wants to merge 1 commit into
moby:masterfrom
thaJeztah:bump_go_archive

Conversation

@thaJeztah

@thaJeztah thaJeztah commented Jul 17, 2026

Copy link
Copy Markdown
Member

vendor: github.com/moby/go-archive v0.3.0

full diff: moby/go-archive@v0.2.1...v0.3.0

v0.3.0

This release fixes CVE-2026-17106 / GHSA-hfg8-hc9c-6c3h, where a crafted
tar archive could use links to cause extraction operations to create or
overwrite files outside the intended destination directory.

The issue affected Unpack, UnpackLayer, Untar, UntarUncompressed, and the
ApplyLayer helpers. Users should upgrade and avoid extracting untrusted
archives with earlier versions.

What's Changed

  • archive: harden tar extraction against path traversal
  • archive: do not follow reparse points in chtimes
  • archive: fix creation time updates on Windows
  • archive: minor cleanups and godoc touch-up
  • archive: RebaseArchiveEntries: fix archive path rebasing
Update  github.com/moby/go-archive to v0.3.0 to fix CVE-2026-17106 / GHSA-hfg8-hc9c-6c3h

@github-actions github-actions Bot added the area/dependencies Pull requests that update a dependency file label Jul 17, 2026
@thaJeztah
thaJeztah force-pushed the bump_go_archive branch 5 times, most recently from e623b60 to f3005c5 Compare July 24, 2026 17:26
full diff: moby/go-archive@v0.2.1...v0.3.0

v0.3.0

This release fixes CVE-2026-17106 / GHSA-hfg8-hc9c-6c3h, where a crafted
tar archive could use links to cause extraction operations to create or
overwrite files outside the intended destination directory.

The issue affected Unpack, UnpackLayer, Untar, UntarUncompressed, and the
ApplyLayer helpers. Users should upgrade and avoid extracting untrusted
archives with earlier versions.

What's Changed

* archive: harden tar extraction against path traversal
* archive: do not follow reparse points in chtimes
* archive: fix creation time updates on Windows
* archive: minor cleanups and godoc touch-up
* archive: RebaseArchiveEntries: fix archive path rebasing

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah changed the title vendor: github.com/moby/go-archive main / v0.3.0-dev vendor: github.com/moby/go-archive v0.3.0 Jul 30, 2026
@thaJeztah
thaJeztah marked this pull request as ready for review July 30, 2026 17:27
@crazy-max

Copy link
Copy Markdown
Member

Looking at the BuildKit call path, go-archive is used for Dockerfile/LLB archive unpack in

func unpack(srcRoot string, src string, destRoot string, dest string, ch copy.Chowner, u *copy.User, tm *time.Time, idmap *user.IdentityMapping) (bool, error) {
src, err := fs.RootPath(srcRoot, src)
if err != nil {
return false, err
}
if !isArchivePath(src) {
return false, nil
}
dest, err = fs.RootPath(destRoot, dest)
if err != nil {
return false, err
}
if _, err := copy.MkdirAll(dest, 0755, ch, tm); err != nil {
return false, err
}
file, err := os.Open(src)
if err != nil {
return false, err
}
defer file.Close()
opts := &archive.TarOptions{
BestEffortXattrs: true,
}
if idmap != nil {
opts.IDMap = *idmap
}
if u != nil {
opts.ChownOpts = &archive.ChownOpts{
UID: u.UID,
GID: u.GID,
}
}
return true, chrootarchive.Untar(file, dest, opts)
}

BuildKit first uses fs.RootPath to map the source and destination into the mounted snapshot, then calls chrootarchive.Untar.

The duplicate containment concern is later on Linux: chrootarchive.Untar switches root before calling archive.Unpack, and go-archive v0.3.0 then wraps extraction in os.Root too. So Linux BuildKit ADD unpack pays the repeated os.Root path-walk cost even though extraction is already running inside the chrooted root. 🙈

I would not remove fs.RootPath here though, that is still needed to resolve the Dockerfile/LLB path into the snapshot mount iiuc. I also would not add a broad BuildKit opt-out, because Windows and non-chroot callers still need the hardening. I think the fix should be in go-archive, either the dirCache mitigation from moby/go-archive#49 or a chroot-aware fast path. 🤔

@crazy-max

Copy link
Copy Markdown
Member

The duplicate containment concern is later on Linux: chrootarchive.Untar switches root before calling archive.Unpack

Hum maybe we could call archive.Untar directly. It would remove the double containment but not the expensive repeated os.Root path-walk per extracted entry. The chroot was already there before v0.3.0, so this is mostly os.Root, not the one-time chroot setup.

@crazy-max

crazy-max commented Jul 30, 2026

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants