[JENKINS-32778] - Prevent extracting archived plugins outside of target path (#3402)

This commit is contained in:
aviadatsnyk authored and Oleg Nenashev committed 2018-05-05 14:32:34 +02:00
1 parent 4278461c90
commit 8ede53387e
1 file changed
+4
+4
View File
@@ -598,6 +598,10 @@ public final class FilePath implements Serializable {
while (entries.hasMoreElements()) {
ZipEntry e = entries.nextElement();
File f = new File(dir, e.getName());
if (!f.toPath().normalize().startsWith(dir.toPath())) {
throw new IOException(
"Zip " + zipFile.getPath() + " contains illegal file name that breaks out of the target directory: " + e.getName());
}
if (e.isDirectory()) {
mkdirs(f);
} else {