Skip to content

Commit e92ef71

Browse files
Introduced protections against "zip slip" attacks
1 parent fbe7b75 commit e92ef71

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

flow-server/pom.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@
170170
<version>${hibernate.validator.version}</version>
171171
<scope>test</scope>
172172
</dependency>
173-
173+
<dependency>
174+
<groupId>io.github.pixee</groupId>
175+
<artifactId>java-security-toolkit</artifactId>
176+
</dependency>
174177
</dependencies>
175178
<build>
176179
<resources>

flow-server/src/main/java/com/vaadin/flow/server/frontend/CompressUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.vaadin.flow.server.frontend;
1818

19+
import io.github.pixee.security.ZipSecurity;
1920
import java.io.File;
2021
import java.io.FileInputStream;
2122
import java.io.FileOutputStream;
@@ -109,8 +110,7 @@ public static void uncompressFile(File zip, File targetDirectory) {
109110
return;
110111
}
111112
byte[] buffer = new byte[1024];
112-
try (ZipInputStream zis = new ZipInputStream(
113-
new FileInputStream(zip))) {
113+
try (ZipInputStream zis = ZipSecurity.createHardenedInputStream(new FileInputStream(zip))) {
114114
ZipEntry zipEntry = zis.getNextEntry();
115115
while (zipEntry != null) {
116116
File newFile = newFile(targetDirectory, zipEntry);

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@
146146
<failsafe.parallel>all</failsafe.parallel>
147147
<failsafe.threadCount>2</failsafe.threadCount>
148148
<failsafe.perCoreThreadCount>true</failsafe.perCoreThreadCount>
149+
<versions.java-security-toolkit>1.2.1</versions.java-security-toolkit>
149150
</properties>
150151

151152
<repositories>
@@ -280,6 +281,11 @@
280281
<artifactId>hamcrest-all</artifactId>
281282
<version>1.3</version>
282283
</dependency>
284+
<dependency>
285+
<groupId>io.github.pixee</groupId>
286+
<artifactId>java-security-toolkit</artifactId>
287+
<version>${versions.java-security-toolkit}</version>
288+
</dependency>
283289
</dependencies>
284290
</dependencyManagement>
285291

0 commit comments

Comments
 (0)