You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,14 @@ layout: default
4
4
section: main
5
5
---
6
6
7
+
### v3.8.0 2022-03-30
8
+
9
+
- Santize filenames when files are loaded with `loadAsync`, to avoid ["zip slip" attacks](https://snyk.io/research/zip-slip-vulnerability). The original filename is available on each zip entry as `unsafeOriginalName`. See the [documentation](https://stuk.github.io/jszip/documentation/api_jszip/load_async.html). Many thanks to McCaulay Hudson for reporting.
10
+
7
11
### v3.7.1 2021-08-05
8
12
9
13
- Fix build of `dist` files.
10
-
+ Note: this version ensures the changes from 3.7.0 are actually included in the `dist` files. Thanks to Evan W for reporting.
14
+
+ Note: this version ensures the changes from 3.7.0 are actually included in the `dist` files. Thanks to Evan W for reporting.
Copy file name to clipboardExpand all lines: documentation/api_jszip/load_async.md
+23Lines changed: 23 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,8 @@ object at the current folder level. This technique has some limitations, see
10
10
If the JSZip object already contains entries, new entries will be merged. If
11
11
two have the same name, the loaded one will replace the other.
12
12
13
+
Since v3.8.0 this method will santize relative path components (i.e. `..`) in loaded filenames to avoid ["zip slip" attacks](https://snyk.io/research/zip-slip-vulnerability). For example: `../../../example.txt` → `example.txt`, `src/images/../example.txt` → `src/example.txt`. The original filename is available on each zip entry as `unsafeOriginalName`.
14
+
13
15
__Returns__ : A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) with the updated zip object.
14
16
The promise can fail if the loaded data is not valid zip data or if it
15
17
uses unsupported features (multi volume, password protected, etc).
@@ -194,3 +196,24 @@ zip.loadAsync(bin1)
194
196
// file3.txt, from bin2
195
197
});
196
198
```
199
+
200
+
Reading a zip file with relative filenames:
201
+
202
+
```js
203
+
// here, "unsafe.zip" is zip file containing:
204
+
// src/images/../file.txt
205
+
// ../../example.txt
206
+
207
+
require("fs").readFile("unsafe.zip", function (err, data) {
0 commit comments