Skip to content

include v0.28.1 patches and extra os.Root hardening - #6613

Merged
tonistiigi merged 9 commits into
moby:masterfrom
tonistiigi:os-root-patches
Mar 25, 2026
Merged

tonistiigi merged 9 commits into
moby:masterfrom
tonistiigi:os-root-patches

Conversation

@tonistiigi

Copy link
Copy Markdown
Member

This includes security patches from https://github.com/moby/buildkit/releases/tag/v0.28.1 plus extra patches

source/http: use os.Root for read-path file operations
source/git: scope path access to roots
executor/oci: scope state files to roots

The extra patches do not fix actual security issues but add extra hardening to avoid similar issues in the future.

Add executor.ValidContainerID and enforce it in runc/containerd Run paths.

Only runc executor used the ID in filesystem operations.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 789df2422341960b7549d14ea475add43e73cd74)
Add safeFileName and route all getFileName sources through it.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 9d117af5ab1e1032f75658884384328fea440843)
Open the snapshot mount as an os.Root and perform file write/chown/chtimes
through root-relative APIs to keep operations constrained to the mount root.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit d568881c97278d87e4f6f01a1f8a67ad807152bb)
Move safeFileName from source/http to source/util/pathutil
and apply it to the containerblob source as well. Harden
containerblob/pull.go to use os.OpenRoot for file writes,
preventing path traversal via crafted filenames.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 3d6e587655d72c343f6fdc7268480a900ba45b0c)
Normalize Git subdir fragments and validate checkout subdir components
so each segment must be a real directory, preventing traversal and symlink escapes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 8c994eb561a2646b35352e5663afecd225306214)
Validate user-provided refs once during identifier construction and reject
option-like refs with leading '-'. There is no known attack related to
previous core, patch is to make ref handling more robust and improve
errors.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit e7f8093e1b386ffe711c8468ca8cdde8cfea0c72)
Open the snapshot mount as an os.Root and perform file reads
through root-relative APIs in verifySignature and
computeChecksumResponse, consistent with the write path.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Use os.OpenRoot for git dir and checkout subdir access, and share root-
relative path normalization between validation and open paths.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Use os.OpenRoot for resolv.conf and hosts state file creation, and
adapt executor callers and tests to the root-relative helper API.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@tonistiigi
tonistiigi merged commit 30cd25b into moby:master Mar 25, 2026
190 checks passed
smerkviladze added a commit to smerkviladze/buildkit that referenced this pull request Apr 3, 2026
…2.x branch with Go 1.20-compatible replacements.

Fixes CVE-2026-33748 (git source path traversal and option injection):
- Normalize and validate git subdir paths and reject non-directory/symlink components.
- Reject refs starting with - and add -- separators to git subprocess calls.

Fixes CVE-2026-33747 (frontend file write and container ID path traversal):
- Sanitize HTTP source filenames and use securejoin for root-confined writes.
- Validate container IDs before filesystem use.

Includes tests for path validation, git ref validation, filename sanitization, and container ID checks.

Signed-off-by: Sopho Merkviladze <smerkviladze@mirantis.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants