-
Notifications
You must be signed in to change notification settings - Fork 787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multi-stage build fails with unmarshalling error when using file descriptor as authfile #3070
Comments
A friendly reminder that this issue had no activity for 30 days. |
Would there be any information I could provide that would be helpful? |
This works for me, and I missing something? |
/tmp/login is an actual file in the filesystem, i.e. it can be accessed multiple times. Whereas --authfile=<(echo "{ "auths": { "myrepository.example": { "auth": "$(echo 'foo:bar' | base64 --wrap=0)" } } }") is a file descriptor which can be accessed only once. In the second time it yields nothing leading to the unmarshalling error. Using process substitution prevents the exposure of secrets via filesystem, which is why I'm interested in this. I suppose one solution would be for buildah to cache the secrets once read and use the cached secrets in multistage builds. |
Would buildah secrets help with this? |
I suppose you mean "buildah bud --secret=...". I think it is not possible to pass the authentication information for external repository in Dockerfile FROM via buildah secret. |
A friendly reminder that this issue had no activity for 30 days. |
One solution could be that the authfile content would be read into memory and used from there during the build. There would be less file operations as well. |
Interested in opening a PR to make this happen? |
A friendly reminder that this issue had no activity for 30 days. |
@flouthoc PTAL |
@kkujala thanks for sharing reproducer. We can defiantly write this to memory or a temp file on first pass if input is a file descriptor. Picking this up |
Following PR makes sure that buildah mirrors --authfile to a temporary file in filesystem if arg is pointing to an FD instead of actual file as FD can be only consumed once. Fixes: containers#3070 Signed-off-by: Aditya Rajan <[email protected]>
Following commit makes sure that podman mirrors --authfile to a temporary file in filesystem if arg is pointing to an FD instead of actual file as FD can be only consumed once. Reference: * containers/buildah#3498 * containers/buildah#3070 [NO TESTS NEEDED] Signed-off-by: Aditya Rajan <[email protected]>
Following commit makes sure that podman mirrors --authfile to a temporary file in filesystem if arg is pointing to an FD instead of actual file as FD can be only consumed once. Reference: * containers/buildah#3498 * containers/buildah#3070 [NO TESTS NEEDED] Signed-off-by: Aditya Rajan <[email protected]>
Following commit makes sure that podman mirrors --authfile to a temporary file in filesystem if arg is pointing to an FD instead of actual file as FD can be only consumed once. Reference: * containers/buildah#3498 * containers/buildah#3070 [NO TESTS NEEDED] Signed-off-by: Aditya Rajan <[email protected]>
Description
When I try to build a multi-stage Dockerfile with a file descriptor from bash process substitution, then it fails with unmarshalling error on the second image fetching. The first image is fetched successfully and the second image fetching encounters the error.
In order to hide the authentication credentials from process listings or from filesystem, then creating a temporary file descriptor with bash process substitution is one way of achieving it securely. I.e. using
--creds
option would reveal the secrets to the host system when runningps
. And using an actual file with--authfile
would reveal the secrets likewise in the filesystem.Steps to reproduce the issue:
The following command should be used for building
Observe the first image centos8 being fetched correctly
Observe the second image
myrepository.example/image:tag
fetching leading to unmarshalling error.Describe the results you received:
It should be noted that the
myrepository.example
is intentionally invalid as per RFC 2606, as it is enough to demonstrate this issue. Also the authfile content is not valid but enough for demonstration. One can replace the both of the images with valid images from a repository that requires authentication, and use the correct secrets in the bash substitution. In such case the first image fetching works and the second one still fails with unmarshalling error.Describe the results you expected:
I'm expecting that the multistage build proceed to fetching the second image with the credentials as given via
--authfile
using file descriptor from bash process substitution.Output of
rpm -q buildah
orapt list buildah
:Output of
buildah version
:Output of
podman version
if reporting apodman build
issue:Output of
cat /etc/*release
:Output of
uname -a
:Output of
cat /etc/containers/storage.conf
:The text was updated successfully, but these errors were encountered: