Should docker build . fail when Dockerfile is a symlink pointing to ../file?
#6840
|
Building with buildkit does not fail when The context directory contains this: I tried it out on Fedora CoreOS 44.20260523.1.1. About the system Side note: Building with the legacy builder (environment |
Replies: 1 comment 1 reply
|
This is expected from BuildKit's current context-filesystem implementation, although it is different from the legacy builder's host-filesystem dereference behavior. First, the symlink in the reproducer is broken from the host's point of view: resolves to BuildKit does not dereference that path directly against the host filesystem. When loading the Dockerfile, the frontend requests it with That root-clamping is deliberate and covered by an upstream test: the So the practical behavior is:
It may be worth documenting the legacy difference, but BuildKit succeeding here is consistent with its security model and its tested symlink-resolution semantics; it is not reading |
This is expected from BuildKit's current context-filesystem implementation, although it is different from the legacy builder's host-filesystem dereference behavior.
First, the symlink in the reproducer is broken from the host's point of view:
resolves to
$tmp/file, not$tmp/context/file. The existing file would be targeted byDockerfile -> file.BuildKit does not dereference that path directly against the host filesystem. When loading the Dockerfile, the frontend requests it with
llb.FollowPaths. Thefsutilresolver treats the build context as a rooted virtual filesystem, so absolute paths and..components cannot escape the context. In this case,../file…