COPY and RUN commands have full access to the filesystem #2153
Labels
area/behavior
all bugs related to kaniko behavior like running in as root
area/security
categorized
differs-from-docker
issue/sensitive-data
kind/enhancement
New feature or request
priority/p2
High impact feature/bug. Will get a lot of users happy
Actual behavior
If you build an image with Kaniko each
COPY
andRUN
command has full acccess to the filesystem (even to files outside of the workspace). A (malicious) Dockerfile can be used to read, write or modify arbitrary files on the filesystem. E.g. you can read the credentials from/kaniko/.docker/config.json
or modify other files to change the behaviour of subsequent builds (in case you build multiple images like we do).Expected behavior
Builds should only have access to files inside
/workspace
and the extracted filesystem and not/kaniko
or other directories part of Kaniko. Would be possible to extract the filesystem and execute each command in a temporary directory instead of using the root directory? If it's not possible can we then introduce a new flag like--chroot
to build the image inside of a temporary directory? Of course this would require thesys_chroot
capability.To Reproduce
Dockerfile.1
:Dockerfile.2
:Dockerfile.1
:Dockerfile.2
.Output of the second build log:
As you can see Kaniko prints the credentials and the
ls
command was replaced with our own implementation which should not happen.--cache
flagThe text was updated successfully, but these errors were encountered: