Skip to content
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

Tern fails to perform analysis for Buildpack images #684

Closed
rnjudge opened this issue May 13, 2020 · 1 comment · Fixed by #685
Closed

Tern fails to perform analysis for Buildpack images #684

rnjudge opened this issue May 13, 2020 · 1 comment · Fixed by #685
Assignees
Milestone

Comments

@rnjudge
Copy link
Contributor

rnjudge commented May 13, 2020

Describe the bug
If you create or pull an image from dockerhub that was created with kpack, Tern fails to perform any analysis. Note: this has been seen on a variety of buildpack images.

To Reproduce

1. $ docker pull carlocolombo/pet-clinic-007
2. $ tern report -o pet-clinic-007.tern.12.05.2020 -i carlocolombo/pet-clinic-007:latest

Error in terminal

2020-05-13 13:38:09,929 - ERROR - rootfs - Malformed tar: tar: Removing leading `/' from member names
2020-05-13 13:38:09,930 - WARNING - report - Error in loading image: Malformed tarball: /home/toor/.tern/temp/d534ff8ec2cb1b96a73da5fa02d959d80f35250115eebd86cd0a01bfb02ed1f3/layer.tar
2020-05-13 13:38:09,930 - WARNING - run - Cannot retrieve full image metadata

Expected behavior
Tern would ideally be able to unpack the buildpack image and perform analysis on it.

Environment you are running Tern on
Enter all that apply

  • Tern @ tip of master
  • Ubuntu VM

Possibly related super issue: #678

@nishakm
Copy link
Contributor

nishakm commented May 13, 2020

Not related to super issue: #678

It looks like CNB does not use GNU tar to tar their buildpack tarballs, thus creating leading / in tarball members. This is a security concern when extracting (see #226). However, it looks like GNU tar will remove the leading / by default (see https://www.gnu.org/software/tar/manual/html_node/absolute.html).

Tern reports any messages to stderr as a "Malformed tarball" even though tar takes care of the security issue by default. So I think we just need to check for this message and ignore it if present.

nishakm pushed a commit to nishakm/tern that referenced this issue May 13, 2020
Currently, we use tar -t to test if tar can untar a given tarball
before we extract the tarball. This allows us to take advantage of
tar's testing of malformed or malicious tarballs. GNU tar will
remove leading forwardslashes in members if it finds any. This gets
piped to stderr with a message. We check if any error exists and
exit, despite the fact that in this case, GNU tar successfully
extracted the tarball while dealing with a possible security issue.

Hence in this change, we check to see if the error message is what
we would expect if GNU tar encounters the leading forwardslash. If
that is the error, we continue on.

Resolves tern-tools#684

Signed-off-by: Nisha K <[email protected]>
rnjudge pushed a commit that referenced this issue May 13, 2020
Currently, we use tar -t to test if tar can untar a given tarball
before we extract the tarball. This allows us to take advantage of
tar's testing of malformed or malicious tarballs. GNU tar will
remove leading forwardslashes in members if it finds any. This gets
piped to stderr with a message. We check if any error exists and
exit, despite the fact that in this case, GNU tar successfully
extracted the tarball while dealing with a possible security issue.

Hence in this change, we check to see if the error message is what
we would expect if GNU tar encounters the leading forwardslash. If
that is the error, we continue on.

Resolves #684

Signed-off-by: Nisha K <[email protected]>
nishakm pushed a commit to nishakm/tern that referenced this issue May 20, 2020
Currently, we use tar -t to test if tar can untar a given tarball
before we extract the tarball. This allows us to take advantage of
tar's testing of malformed or malicious tarballs. GNU tar will
remove leading forwardslashes in members if it finds any. This gets
piped to stderr with a message. We check if any error exists and
exit, despite the fact that in this case, GNU tar successfully
extracted the tarball while dealing with a possible security issue.

Hence in this change, we check to see if the error message is what
we would expect if GNU tar encounters the leading forwardslash. If
that is the error, we continue on.

Resolves tern-tools#684

Signed-off-by: Nisha K <[email protected]>
@rnjudge rnjudge added this to the Release 2.1.0 milestone May 28, 2020
rnjudge pushed a commit to rnjudge/tern that referenced this issue Jun 5, 2020
Currently, we use tar -t to test if tar can untar a given tarball
before we extract the tarball. This allows us to take advantage of
tar's testing of malformed or malicious tarballs. GNU tar will
remove leading forwardslashes in members if it finds any. This gets
piped to stderr with a message. We check if any error exists and
exit, despite the fact that in this case, GNU tar successfully
extracted the tarball while dealing with a possible security issue.

Hence in this change, we check to see if the error message is what
we would expect if GNU tar encounters the leading forwardslash. If
that is the error, we continue on.

Resolves tern-tools#684

Signed-off-by: Nisha K <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants