Skip to content

Commit

Permalink
refactor: fix security issue on extracting sneaky tar files
Browse files Browse the repository at this point in the history
  • Loading branch information
npepinpe committed May 10, 2022
1 parent e541df6 commit 9d07eea
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/io/zeebe/containers/archive/TarExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ private void extractEntry(
}

final Path entryPath = destination.resolve(entry.getName());
if (!entryPath.normalize().startsWith(destination)) {
throw new IllegalStateException(
String.format(
"Expected to extract %s from TAR archive to the destination folder %s, but it would "
+ "be extracted outside to %s; make sure no entry contains `..` or the likes in "
+ "their name",
entry.getName(), destination, entryPath));
}

if (entry.isDirectory()) {
Files.createDirectories(entryPath);
Expand Down

0 comments on commit 9d07eea

Please sign in to comment.