mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Java: Add a flow step for Path::toFile in ZipSlip
This commit is contained in:
@@ -51,4 +51,13 @@ public class ZipTest {
|
||||
throw new Exception();
|
||||
FileOutputStream os = new FileOutputStream(file); // OK
|
||||
}
|
||||
|
||||
public void m6(ZipEntry entry, Path dir) {
|
||||
String canonicalDest = dir.toFile().getCanonicalPath();
|
||||
Path target = dir.resolve(entry.getName());
|
||||
String canonicalTarget = target.toFile().getCanonicalPath();
|
||||
if (!canonicalTarget.startsWith(canonicalDest + File.separator))
|
||||
throw new Exception();
|
||||
OutputStream os = Files.newOutputStream(target); // OK
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user