Skip to content

Conversation

@Mrhs121
Copy link

@Mrhs121 Mrhs121 commented Jul 3, 2023

…Utils.unpack

What changes were proposed in this pull request?

This PR proposes to use FileUtil.unTarUsingJava that is a Java implementation for un-tar .tar files. unTarUsingJava is not public but it exists in all Hadoop versions from 2.1+, see HADOOP-9264.

The security issue reproduction requires a non-Windows platform, and a non-gzipped TAR archive file name (contents don't matter).

Why are the changes needed?

There is a risk for arbitrary shell command injection via Utils.unpack when the filename is controlled by a malicious user. This is due to an issue in Hadoop's unTar, that is not properly escaping the filename before passing to a shell command:https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java#L904

Does this PR introduce any user-facing change?

Yes, it prevents a security issue that, previously, allowed users to execute arbitrary shall command.

How was this patch tested?

Manually tested in local, and existing test cases should cover.

Closes apache#35946 from HyukjinKwon/SPARK-38631.

Authored-by: Hyukjin Kwon [email protected]

(cherry picked from commit 057c051)

What changes were proposed in this pull request?

Why are the changes needed?

Does this PR introduce any user-facing change?

How was this patch tested?

…Utils.unpack

### What changes were proposed in this pull request?

This PR proposes to use `FileUtil.unTarUsingJava` that is a Java implementation for un-tar `.tar` files. `unTarUsingJava` is not public but it exists in all Hadoop versions from 2.1+, see HADOOP-9264.

The security issue reproduction requires a non-Windows platform, and a non-gzipped TAR archive file name (contents don't matter).

### Why are the changes needed?

There is a risk for arbitrary shell command injection via `Utils.unpack` when the filename is controlled by a malicious user. This is due to an issue in Hadoop's `unTar`, that is not properly escaping the filename before passing to a shell command:https://github.com/apache/hadoop/blob/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java#L904

### Does this PR introduce _any_ user-facing change?

Yes, it prevents a security issue that, previously, allowed users to execute arbitrary shall command.

### How was this patch tested?

Manually tested in local, and existing test cases should cover.

Closes apache#35946 from HyukjinKwon/SPARK-38631.

Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
(cherry picked from commit 057c051)
Signed-off-by: Hyukjin Kwon <[email protected]>
@github-actions github-actions bot added the CORE label Jul 3, 2023
@Mrhs121 Mrhs121 closed this Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants