@keep-lts/extract-zip 0.0.0-stage → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/LICENSE +23 -0
- package/SECURITY.md +43 -0
- package/cli.js +19 -0
- package/index.d.ts +21 -0
- package/index.js +245 -0
- package/package.json +98 -4
- package/readme.md +75 -0
- package/README.md +0 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Security-maintained fork of [`extract-zip`](https://www.npmjs.com/package/extract-zip).
|
|
4
|
+
Only security and compatibility fixes are applied; the public API is unchanged.
|
|
5
|
+
|
|
6
|
+
## [2.0.2] — 2026-11-07
|
|
7
|
+
|
|
8
|
+
### Security
|
|
9
|
+
- **Fix CVE-2026-56876 / CVE-2026-19693 / GHSA-jmr9-qjv8-65gv / GHSA-7pqw-9j4j-h8q3 (High, CWE-59 Link Following / CWE-22 Path Traversal).** Symlink entries are resolved the way the operating system will resolve them — from the real directory containing the link, following symlinks that already exist — and rejected unless they land inside the extraction directory. Absolute link targets, and targets with a `..` after a normal segment (which can escape through a symlinked segment), are rejected outright. Before writing a file or creating a link, any symlink already sitting at that path is removed rather than followed.
|
|
10
|
+
See [SECURITY.md](./SECURITY.md) for the advisory, proof-of-concept, and remediation.
|
|
11
|
+
|
|
12
|
+
### Notes
|
|
13
|
+
- No public API change; behavior is identical for all legitimate input.
|
|
14
|
+
- Regression tests added in `test/security.test.js`.
|
|
15
|
+
- Drop-in replacement for `extract-zip@2.0.1`.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
Based on `extract-zip` by max ogden (BSD-2-Clause).
|
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright (c) 2014 Max Ogden and other contributors
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Security Advisory — extract-zip
|
|
2
|
+
|
|
3
|
+
## CVE-2026-56876 / CVE-2026-19693 / GHSA-jmr9-qjv8-65gv / GHSA-7pqw-9j4j-h8q3 — Arbitrary file write outside the extraction directory via symlink entries in extract-zip
|
|
4
|
+
|
|
5
|
+
| | |
|
|
6
|
+
|---|---|
|
|
7
|
+
| **Severity** | High (CWE-59 Link Following / CWE-22 Path Traversal) |
|
|
8
|
+
| **Affected** | `extract-zip` <= 2.0.1 (all published versions) (original package; no upstream fix) |
|
|
9
|
+
| **Fixed in** | `@keep-lts/extract-zip@2.0.2` |
|
|
10
|
+
|
|
11
|
+
### Summary
|
|
12
|
+
|
|
13
|
+
extract-zip validated only the parent directory of each archive entry. A malicious zip could (1) create a symlink pointing anywhere on disk (CVE-2026-56876), and (2) follow it with a regular file of the same name, which extract-zip then wrote through the symlink — an arbitrary file write outside the extraction directory (CVE-2026-19693). Any service that extracts user-supplied zips (uploads, plugin/theme installers, CI artefacts, Electron updaters) is exposed.
|
|
14
|
+
|
|
15
|
+
### Proof of concept
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
// zip entries: 'evil' (symlink -> ../../../../home/user/.bashrc), then 'evil' (file: attacker content)
|
|
19
|
+
await require('extract-zip')('evil.zip', { dir: '/srv/uploads/x' })
|
|
20
|
+
// extract-zip 2.0.1 overwrites /home/user/.bashrc
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### The fix
|
|
24
|
+
|
|
25
|
+
Three checks, each covered by a regression test that fails on 2.0.1: (1) every symlink target is resolved against the real filesystem and must land inside the target directory; absolute targets and `x/../y`-style targets are refused, closing bypasses of a purely textual check (e.g. a link through an earlier `d -> .` symlink); (2) an existing symlink at a destination path is removed before writing, never written through; (3) the existing parent-directory check is kept and also guards against cross-drive paths on Windows. Normal archives — files, nested folders, file modes, `__MACOSX` skipping, and relative symlinks that stay inside (as in macOS .app/framework bundles) — extract exactly as before.
|
|
26
|
+
|
|
27
|
+
### Remediation
|
|
28
|
+
|
|
29
|
+
Replace the vulnerable dependency with this drop-in fork — no code changes required:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"overrides": {
|
|
34
|
+
"extract-zip": "npm:@keep-lts/extract-zip@^2.0.2"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then reinstall and confirm `npm ls extract-zip` resolves to the fork.
|
|
40
|
+
|
|
41
|
+
### Reporting
|
|
42
|
+
|
|
43
|
+
Report vulnerabilities in this fork via a private security advisory on the fork repository.
|
package/cli.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-process-exit */
|
|
4
|
+
|
|
5
|
+
var extract = require('./')
|
|
6
|
+
|
|
7
|
+
var args = process.argv.slice(2)
|
|
8
|
+
var source = args[0]
|
|
9
|
+
var dest = args[1] || process.cwd()
|
|
10
|
+
if (!source) {
|
|
11
|
+
console.error('Usage: extract-zip foo.zip <targetDirectory>')
|
|
12
|
+
process.exit(1)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
extract(source, { dir: dest })
|
|
16
|
+
.catch(function (err) {
|
|
17
|
+
console.error('error!', err)
|
|
18
|
+
process.exit(1)
|
|
19
|
+
})
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Based on the type definitions for extract-zip 1.6
|
|
2
|
+
// Definitions by: Mizunashi Mana <https://github.com/mizunashi-mana>
|
|
3
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e69b58e/types/extract-zip/index.d.ts
|
|
4
|
+
|
|
5
|
+
import { Entry, ZipFile } from 'yauzl';
|
|
6
|
+
|
|
7
|
+
declare namespace extract {
|
|
8
|
+
interface Options {
|
|
9
|
+
dir: string;
|
|
10
|
+
defaultDirMode?: number;
|
|
11
|
+
defaultFileMode?: number;
|
|
12
|
+
onEntry?: (entry: Entry, zipfile: ZipFile) => void;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare function extract(
|
|
17
|
+
zipPath: string,
|
|
18
|
+
opts: extract.Options,
|
|
19
|
+
): Promise<void>;
|
|
20
|
+
|
|
21
|
+
export = extract;
|
package/index.js
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
const debug = require('debug')('extract-zip')
|
|
2
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
3
|
+
const { createWriteStream, promises: fs } = require('fs')
|
|
4
|
+
const getStream = require('get-stream')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const { promisify } = require('util')
|
|
7
|
+
const stream = require('stream')
|
|
8
|
+
const yauzl = require('yauzl')
|
|
9
|
+
|
|
10
|
+
const openZip = promisify(yauzl.open)
|
|
11
|
+
const pipeline = promisify(stream.pipeline)
|
|
12
|
+
|
|
13
|
+
// Keep LTS security patch (CVE-2026-19693, CVE-2026-56876):
|
|
14
|
+
// extraction must never read or write outside the target directory.
|
|
15
|
+
|
|
16
|
+
// True if `target` is `dir` itself or somewhere underneath it (absolute paths).
|
|
17
|
+
function isInside (dir, target) {
|
|
18
|
+
const relative = path.relative(dir, target)
|
|
19
|
+
if (relative === '') return true
|
|
20
|
+
return !relative.split(path.sep).includes('..') && !path.isAbsolute(relative)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Resolve a symlink's target the way the OS will, starting from the real
|
|
24
|
+
// directory that contains the link, following any symlinks that already exist.
|
|
25
|
+
// Returns null for targets we refuse outright:
|
|
26
|
+
// - absolute targets (could point anywhere), and
|
|
27
|
+
// - targets with a `..` after a normal segment (e.g. `x/../y`). The OS applies
|
|
28
|
+
// `..` after following `x`, so if `x` is (or later becomes) a symlink the
|
|
29
|
+
// target can escape even though it looks contained on paper.
|
|
30
|
+
async function resolveLinkTarget (realParentDir, link) {
|
|
31
|
+
if (path.isAbsolute(link) || path.win32.isAbsolute(link) || path.posix.isAbsolute(link)) return null
|
|
32
|
+
const segments = link.split(/[\\/]+/).filter(s => s !== '' && s !== '.')
|
|
33
|
+
let seenName = false
|
|
34
|
+
let current = realParentDir
|
|
35
|
+
for (const segment of segments) {
|
|
36
|
+
if (segment === '..') {
|
|
37
|
+
if (seenName) return null
|
|
38
|
+
current = path.dirname(current)
|
|
39
|
+
continue
|
|
40
|
+
}
|
|
41
|
+
seenName = true
|
|
42
|
+
const next = path.join(current, segment)
|
|
43
|
+
try {
|
|
44
|
+
current = await fs.realpath(next)
|
|
45
|
+
} catch (err) {
|
|
46
|
+
/* istanbul ignore if */
|
|
47
|
+
if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') throw err
|
|
48
|
+
current = next
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return current
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Remove a symlink sitting at `dest` so we replace it instead of writing
|
|
55
|
+
// through it (CVE-2026-19693). Real files and directories are left alone.
|
|
56
|
+
async function removeSymlinkAt (dest) {
|
|
57
|
+
let stats
|
|
58
|
+
try {
|
|
59
|
+
stats = await fs.lstat(dest)
|
|
60
|
+
} catch (err) {
|
|
61
|
+
/* istanbul ignore if */
|
|
62
|
+
if (err.code !== 'ENOENT') throw err
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
if (stats.isSymbolicLink()) {
|
|
66
|
+
debug('removing existing symlink', dest)
|
|
67
|
+
await fs.unlink(dest)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
class Extractor {
|
|
72
|
+
constructor (zipPath, opts) {
|
|
73
|
+
this.zipPath = zipPath
|
|
74
|
+
this.opts = opts
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async extract () {
|
|
78
|
+
debug('opening', this.zipPath, 'with opts', this.opts)
|
|
79
|
+
|
|
80
|
+
this.zipfile = await openZip(this.zipPath, { lazyEntries: true })
|
|
81
|
+
this.canceled = false
|
|
82
|
+
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
this.zipfile.on('error', err => {
|
|
85
|
+
this.canceled = true
|
|
86
|
+
reject(err)
|
|
87
|
+
})
|
|
88
|
+
this.zipfile.readEntry()
|
|
89
|
+
|
|
90
|
+
this.zipfile.on('close', () => {
|
|
91
|
+
if (!this.canceled) {
|
|
92
|
+
debug('zip extraction complete')
|
|
93
|
+
resolve()
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
this.zipfile.on('entry', async entry => {
|
|
98
|
+
/* istanbul ignore if */
|
|
99
|
+
if (this.canceled) {
|
|
100
|
+
debug('skipping entry', entry.fileName, { cancelled: this.canceled })
|
|
101
|
+
return
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
debug('zipfile entry', entry.fileName)
|
|
105
|
+
|
|
106
|
+
if (entry.fileName.startsWith('__MACOSX/')) {
|
|
107
|
+
this.zipfile.readEntry()
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const destDir = path.dirname(path.join(this.opts.dir, entry.fileName))
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
await fs.mkdir(destDir, { recursive: true })
|
|
115
|
+
|
|
116
|
+
const canonicalDestDir = await fs.realpath(destDir)
|
|
117
|
+
|
|
118
|
+
if (!isInside(this.opts.dir, canonicalDestDir)) {
|
|
119
|
+
throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
await this.extractEntry(entry)
|
|
123
|
+
debug('finished processing', entry.fileName)
|
|
124
|
+
this.zipfile.readEntry()
|
|
125
|
+
} catch (err) {
|
|
126
|
+
this.canceled = true
|
|
127
|
+
this.zipfile.close()
|
|
128
|
+
reject(err)
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async extractEntry (entry) {
|
|
135
|
+
/* istanbul ignore if */
|
|
136
|
+
if (this.canceled) {
|
|
137
|
+
debug('skipping entry extraction', entry.fileName, { cancelled: this.canceled })
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (this.opts.onEntry) {
|
|
142
|
+
this.opts.onEntry(entry, this.zipfile)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const dest = path.join(this.opts.dir, entry.fileName)
|
|
146
|
+
|
|
147
|
+
// Backstop: yauzl already rejects absolute and `..` entry names.
|
|
148
|
+
/* istanbul ignore if */
|
|
149
|
+
if (!isInside(this.opts.dir, dest)) {
|
|
150
|
+
throw new Error(`Out of bound path "${dest}" found while processing file ${entry.fileName}`)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// convert external file attr int into a fs stat mode int
|
|
154
|
+
const mode = (entry.externalFileAttributes >> 16) & 0xFFFF
|
|
155
|
+
// check if it's a symlink or dir (using stat mode constants)
|
|
156
|
+
const IFMT = 61440
|
|
157
|
+
const IFDIR = 16384
|
|
158
|
+
const IFLNK = 40960
|
|
159
|
+
const symlink = (mode & IFMT) === IFLNK
|
|
160
|
+
let isDir = (mode & IFMT) === IFDIR
|
|
161
|
+
|
|
162
|
+
// Failsafe, borrowed from jsZip
|
|
163
|
+
if (!isDir && entry.fileName.endsWith('/')) {
|
|
164
|
+
isDir = true
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// check for windows weird way of specifying a directory
|
|
168
|
+
// https://github.com/maxogden/extract-zip/issues/13#issuecomment-154494566
|
|
169
|
+
const madeBy = entry.versionMadeBy >> 8
|
|
170
|
+
if (!isDir) isDir = (madeBy === 0 && entry.externalFileAttributes === 16)
|
|
171
|
+
|
|
172
|
+
debug('extracting entry', { filename: entry.fileName, isDir: isDir, isSymlink: symlink })
|
|
173
|
+
|
|
174
|
+
const procMode = this.getExtractedMode(mode, isDir) & 0o777
|
|
175
|
+
|
|
176
|
+
// always ensure folders are created
|
|
177
|
+
const destDir = isDir ? dest : path.dirname(dest)
|
|
178
|
+
|
|
179
|
+
const mkdirOptions = { recursive: true }
|
|
180
|
+
if (isDir) {
|
|
181
|
+
mkdirOptions.mode = procMode
|
|
182
|
+
}
|
|
183
|
+
debug('mkdir', { dir: destDir, ...mkdirOptions })
|
|
184
|
+
await fs.mkdir(destDir, mkdirOptions)
|
|
185
|
+
if (isDir) return
|
|
186
|
+
|
|
187
|
+
debug('opening read stream', dest)
|
|
188
|
+
const readStream = await promisify(this.zipfile.openReadStream.bind(this.zipfile))(entry)
|
|
189
|
+
|
|
190
|
+
if (symlink) {
|
|
191
|
+
const link = await getStream(readStream)
|
|
192
|
+
// CVE-2026-56876: a symlink may not point outside the target directory.
|
|
193
|
+
const realParent = await fs.realpath(path.dirname(dest))
|
|
194
|
+
const resolved = await resolveLinkTarget(realParent, link)
|
|
195
|
+
if (resolved === null || !isInside(this.opts.dir, resolved)) {
|
|
196
|
+
throw new Error(`Out of bound symlink target "${link}" found while processing file ${entry.fileName}`)
|
|
197
|
+
}
|
|
198
|
+
debug('creating symlink', link, dest)
|
|
199
|
+
await removeSymlinkAt(dest)
|
|
200
|
+
await fs.symlink(link, dest)
|
|
201
|
+
} else {
|
|
202
|
+
// CVE-2026-19693: never write through a symlink planted at this path.
|
|
203
|
+
await removeSymlinkAt(dest)
|
|
204
|
+
await pipeline(readStream, createWriteStream(dest, { mode: procMode }))
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
getExtractedMode (entryMode, isDir) {
|
|
209
|
+
let mode = entryMode
|
|
210
|
+
// Set defaults, if necessary
|
|
211
|
+
if (mode === 0) {
|
|
212
|
+
if (isDir) {
|
|
213
|
+
if (this.opts.defaultDirMode) {
|
|
214
|
+
mode = parseInt(this.opts.defaultDirMode, 10)
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (!mode) {
|
|
218
|
+
mode = 0o755
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
if (this.opts.defaultFileMode) {
|
|
222
|
+
mode = parseInt(this.opts.defaultFileMode, 10)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (!mode) {
|
|
226
|
+
mode = 0o644
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return mode
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
module.exports = async function (zipPath, opts) {
|
|
236
|
+
debug('creating target directory', opts.dir)
|
|
237
|
+
|
|
238
|
+
if (!path.isAbsolute(opts.dir)) {
|
|
239
|
+
throw new Error('Target directory is expected to be absolute')
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
await fs.mkdir(opts.dir, { recursive: true })
|
|
243
|
+
opts.dir = await fs.realpath(opts.dir)
|
|
244
|
+
return new Extractor(zipPath, opts).extract()
|
|
245
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,100 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keep-lts/extract-zip",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.2",
|
|
4
|
+
"description": "Security-maintained drop-in fork of extract-zip. Patches CVE-2026-56876 and CVE-2026-19693 (symlink path traversal / arbitrary file write): symlinks may only point inside the target directory, and files are never written through a symlink. Original API unchanged.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"extract-zip": "cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"ava": "ava",
|
|
12
|
+
"coverage": "nyc ava",
|
|
13
|
+
"lint": "yarn lint:js && yarn lint:ts && yarn tsd",
|
|
14
|
+
"lint:js": "eslint .",
|
|
15
|
+
"lint:ts": "eslint --config .eslintrc.typescript.js --ext .ts .",
|
|
16
|
+
"test": "node --test test/security.test.js",
|
|
17
|
+
"tsd": "tsd"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"cli.js",
|
|
21
|
+
"index.d.ts",
|
|
22
|
+
"CHANGELOG.md",
|
|
23
|
+
"SECURITY.md"
|
|
24
|
+
],
|
|
25
|
+
"author": "max ogden",
|
|
26
|
+
"license": "BSD-2-Clause",
|
|
27
|
+
"repository": "keep-lts/extract-zip",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"unzip",
|
|
30
|
+
"zip",
|
|
31
|
+
"extract",
|
|
32
|
+
"cve-2026-56876",
|
|
33
|
+
"cve-2026-19693",
|
|
34
|
+
"security",
|
|
35
|
+
"patch",
|
|
36
|
+
"lts",
|
|
37
|
+
"fork",
|
|
38
|
+
"cwe-59-link-following-/-cwe-22-path-traversal"
|
|
39
|
+
],
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">= 10.17.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"debug": "^4.1.1",
|
|
45
|
+
"get-stream": "^5.1.0",
|
|
46
|
+
"yauzl": "^2.10.0"
|
|
47
|
+
},
|
|
48
|
+
"optionalDependencies": {
|
|
49
|
+
"@types/yauzl": "^2.9.1"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^3.2.0",
|
|
53
|
+
"@typescript-eslint/parser": "^3.2.0",
|
|
54
|
+
"ava": "^3.5.1",
|
|
55
|
+
"eslint": "^7.2.0",
|
|
56
|
+
"eslint-config-standard": "^14.1.1",
|
|
57
|
+
"eslint-plugin-ava": "^10.2.0",
|
|
58
|
+
"eslint-plugin-import": "^2.20.1",
|
|
59
|
+
"eslint-plugin-node": "^11.0.0",
|
|
60
|
+
"eslint-plugin-promise": "^4.2.1",
|
|
61
|
+
"eslint-plugin-standard": "^4.0.1",
|
|
62
|
+
"fs-extra": "^9.0.0",
|
|
63
|
+
"husky": "^4.2.3",
|
|
64
|
+
"lint-staged": "^10.0.9",
|
|
65
|
+
"nyc": "^15.0.0",
|
|
66
|
+
"tsd": "^0.11.0",
|
|
67
|
+
"typescript": "^3.8.3"
|
|
68
|
+
},
|
|
69
|
+
"eslintConfig": {
|
|
70
|
+
"extends": [
|
|
71
|
+
"eslint:recommended",
|
|
72
|
+
"plugin:ava/recommended",
|
|
73
|
+
"plugin:import/errors",
|
|
74
|
+
"plugin:import/warnings",
|
|
75
|
+
"plugin:node/recommended",
|
|
76
|
+
"plugin:promise/recommended",
|
|
77
|
+
"standard"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"husky": {
|
|
81
|
+
"hooks": {
|
|
82
|
+
"pre-commit": "lint-staged"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"lint-staged": {
|
|
86
|
+
"*.js": "yarn lint:js --fix",
|
|
87
|
+
"*.ts": "yarn lint:ts --fix"
|
|
88
|
+
},
|
|
89
|
+
"contributors": [
|
|
90
|
+
"Keep LTS (security maintenance fork)"
|
|
91
|
+
],
|
|
92
|
+
"bugs": {
|
|
93
|
+
"url": "https://github.com/keep-lts/extract-zip/issues"
|
|
94
|
+
},
|
|
95
|
+
"homepage": "https://github.com/keep-lts/extract-zip",
|
|
96
|
+
"publishConfig": {
|
|
97
|
+
"access": "public",
|
|
98
|
+
"provenance": true
|
|
99
|
+
}
|
|
100
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @keep-lts/extract-zip
|
|
2
|
+
|
|
3
|
+
> Security-maintained, drop-in fork of [`extract-zip`](https://www.npmjs.com/package/extract-zip).
|
|
4
|
+
|
|
5
|
+
> [!IMPORTANT]
|
|
6
|
+
> **Unofficial security-maintenance fork.** The original `extract-zip` has no fix for
|
|
7
|
+
> **CVE-2026-56876 / CVE-2026-19693 / GHSA-jmr9-qjv8-65gv / GHSA-7pqw-9j4j-h8q3** (High). This fork applies a minimal, tested patch and keeps the
|
|
8
|
+
> public API byte-for-byte compatible. Adopt with zero code changes via npm `overrides`:
|
|
9
|
+
>
|
|
10
|
+
> ```json
|
|
11
|
+
> { "overrides": { "extract-zip": "npm:@keep-lts/extract-zip@^2.0.2" } }
|
|
12
|
+
> ```
|
|
13
|
+
>
|
|
14
|
+
> See [SECURITY.md](./SECURITY.md) and [CHANGELOG.md](./CHANGELOG.md). Original functionality
|
|
15
|
+
> and attribution preserved under the BSD-2-Clause license.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# extract-zip
|
|
20
|
+
|
|
21
|
+
Unzip written in pure JavaScript. Extracts a zip into a directory. Available as a library or a command line program.
|
|
22
|
+
|
|
23
|
+
Uses the [`yauzl`](http://npmjs.org/yauzl) ZIP parser.
|
|
24
|
+
|
|
25
|
+
[](https://npm.im/extract-zip)
|
|
26
|
+
[](https://github.com/standard/standard)
|
|
27
|
+
[](https://github.com/maxogden/extract-zip/actions?query=workflow%3ACI)
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
Make sure you have Node 10 or greater installed.
|
|
32
|
+
|
|
33
|
+
Get the library:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
npm install extract-zip --save
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Install the command line program:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
npm install extract-zip -g
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## JS API
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
const extract = require('extract-zip')
|
|
49
|
+
|
|
50
|
+
async function main () {
|
|
51
|
+
try {
|
|
52
|
+
await extract(source, { dir: target })
|
|
53
|
+
console.log('Extraction complete')
|
|
54
|
+
} catch (err) {
|
|
55
|
+
// handle any errors
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Options
|
|
61
|
+
|
|
62
|
+
- `dir` (required) - the path to the directory where the extracted files are written
|
|
63
|
+
- `defaultDirMode` - integer - Directory Mode (permissions), defaults to `0o755`
|
|
64
|
+
- `defaultFileMode` - integer - File Mode (permissions), defaults to `0o644`
|
|
65
|
+
- `onEntry` - function - if present, will be called with `(entry, zipfile)`, entry is every entry from the zip file forwarded from the `entry` event from yauzl. `zipfile` is the `yauzl` instance
|
|
66
|
+
|
|
67
|
+
Default modes are only used if no permissions are set in the zip file.
|
|
68
|
+
|
|
69
|
+
## CLI Usage
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
extract-zip foo.zip <targetDirectory>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
If not specified, `targetDirectory` will default to `process.cwd()`.
|
package/README.md
DELETED