Download tasks/codeql_java_benchmark_top30_v2/morefixes-623c5f3c0558ba463c5a/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 2 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_java_benchmark_top30_v2/morefixes-623c5f3c0558ba463c5a/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_java_benchmark_top30_v2/morefixes-623c5f3c0558ba463c5a/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_java_benchmark_top30_v2/morefixes-623c5f3c0558ba463c5a/patch.diff
2 kB
| diff --git a/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ZipUtils.java b/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ZipUtils.java | |
| index c27eae6..62e625f 100644 | |
| --- a/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ZipUtils.java | |
| +++ b/frontend/archive/src/main/java/org/pytorch/serve/archive/utils/ZipUtils.java | |
| public final class ZipUtils { | |
| try (ZipInputStream zis = new ZipInputStream(is)) { | |
| ZipEntry entry; | |
| while ((entry = zis.getNextEntry()) != null) { | |
| - String name = entry.getName(); | |
| - File file = new File(dest, name); | |
| + File file = new File(dest, entry.getName()); | |
| + File canonicalDestDir = dest.getCanonicalFile(); | |
| + File canonicalFile = file.getCanonicalFile(); | |
| + | |
| + // Check for Zip Slip vulnerability | |
| + if (!canonicalFile.getPath().startsWith(canonicalDestDir.getPath())) { | |
| + throw new IOException("Detected Zip Slip vulnerability: " + entry.getName()); | |
| + } | |
| + | |
| if (entry.isDirectory()) { | |
| FileUtils.forceMkdir(file); | |
| } else { | |
| public final class ZipUtils { | |
| while ((entry = tis.getNextEntry()) != null) { | |
| String name = entry.getName().substring(entry.getName().indexOf('/') + 1); | |
| File file = new File(dest, name); | |
| + File canonicalDestDir = dest.getCanonicalFile(); | |
| + File canonicalFile = file.getCanonicalFile(); | |
| + | |
| + // Check for Zip Slip vulnerability | |
| + if (!canonicalFile.getPath().startsWith(canonicalDestDir.getPath())) { | |
| + throw new IOException("Detected Zip Slip vulnerability: " + entry.getName()); | |
| + } | |
| + | |
| if (entry.isDirectory()) { | |
| FileUtils.forceMkdir(file); | |
| } else { | |