Skip to content

Commit

Permalink
[JENKINS-51777] Don't let tar entries escape target dir
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-beck committed Jun 8, 2018
1 parent e992e11 commit 7438abb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/java/hudson/FilePath.java
Expand Up @@ -2452,6 +2452,10 @@ private void readFromTar(String name, File baseDir, InputStream in) throws IOExc
TarArchiveEntry te;
while ((te = t.getNextTarEntry()) != null) {
File f = new File(baseDir, te.getName());
if (!f.toPath().normalize().startsWith(baseDir.toPath())) {
throw new IOException(
"Tar " + name + " contains illegal file name that breaks out of the target directory: " + te.getName());
}
if (te.isDirectory()) {
mkdirs(f);
} else {
Expand Down

0 comments on commit 7438abb

Please sign in to comment.