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

Potential CVE? #2715

Closed
ibodrov opened this issue Jan 12, 2021 · 2 comments
Closed

Potential CVE? #2715

ibodrov opened this issue Jan 12, 2021 · 2 comments
Assignees
Labels
bug security Pull requests that address a security vulnerability
Milestone

Comments

@ibodrov
Copy link

ibodrov commented Jan 12, 2021

A recently found vulnerability was fixed in another project similar to this one. It might potentially affect a similar implementation in PodOperationsImpl.

Ironically, it prints out the normalized path into stdout, but uses the original (potentially dangerous) path.

@manusa
Copy link
Member

manusa commented Jan 29, 2021

I finally managed to create a reproducer for this CVE.

I first created a Container Image which contains a poisoned tar binary.
Whenever this binary is executed with arguments -cf - [fileName] it will produce a tar with a single file containing a forged tar entry ../youve-been-hacked.

The following gist contains a JBang script that will exploit the vulnerability.
You should be able to invoke the script by running the following in your command line:

$ jbang https://gist.github.com/manusa/94b91311ee9af7267a8a7f659f594a82

This is an excerpt of the script:

final Path targetDirectory = Paths.get("", "target-directory");
targetDirectory.toFile().mkdirs();
kc.pods().withName(podName).dir("/var/lib").copy(targetDirectory);

According to this script, the contents of the container's /var/lib directory should be copied to the local ./target-directory.

However, when the script is executed, a file youve-been-hacked is created in the parent directory (since the tar entry is defined as ../youve-been-hacked, thus exploiting the exposed vulnerability).

If you were to extract this intermediate tar using the standard tar command, you would be greeted with the following error:

tar: Removing leading `../' from member names
tar: ../youve-been-hacked: Member name contains '..'
tar: Exiting with failure status due to previous errors

You would need to force the extraction using the -P/--absolute-names (don't strip leading '/'s from file names)
flag

@manusa manusa added bug security Pull requests that address a security vulnerability labels Jan 29, 2021
@manusa manusa added this to the 5.1.0 milestone Feb 1, 2021
@manusa manusa self-assigned this Feb 3, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Feb 8, 2021
@manusa
Copy link
Member

manusa commented Feb 9, 2021

Releases with fix:

@manusa manusa closed this as completed Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug security Pull requests that address a security vulnerability
Projects
None yet
Development

No branches or pull requests

2 participants