Skip to content

Commit bb521e5

Browse files
committed
Remove --shell option where unsafe to use
This provides a more comprehensive and safe fix for CVE-2025-64756, by making the `--shell` option fully nonfunctional on systems where it is not known to be safe. Re: GHSA-5j98-mcp5-4vw2 Re: CVE-2025-64756
1 parent 2551fb5 commit bb521e5

File tree

4 files changed

+25
-27
lines changed

4 files changed

+25
-27
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ share the previously loaded cache.
435435
is used as the starting point for absolute patterns that start
436436
with `/`, (but not drive letters or UNC paths on Windows).
437437

438-
To start absolute and non-absolute patterns in the same path,
439-
you can use `{root:''}`. However, be aware that on Windows
440-
systems, a pattern like `x:/*` or `//host/share/*` will
441-
_always_ start in the `x:/` or `//host/share` directory,
442-
regardless of the `root` setting.
438+
To start absolute and non-absolute patterns in the same path,
439+
you can use `{root:''}`. However, be aware that on Windows
440+
systems, a pattern like `x:/*` or `//host/share/*` will
441+
_always_ start in the `x:/` or `//host/share` directory,
442+
regardless of the `root` setting.
443443

444444
> [!NOTE] This _doesn't_ necessarily limit the walk to the
445445
> `root` directory, and doesn't affect the cwd starting point
@@ -664,7 +664,6 @@ share the previously loaded cache.
664664
> already be added before its ancestor, if multiple or braced
665665
> patterns are used.
666666
667-
668667
## Glob Primer
669668

670669
Much more information about glob pattern expansion can be found

changelog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
# changeglob
22

3+
## 12
4+
5+
- Remove the unsafe `--shell` option. The `--shell` option is now
6+
ONLY supported on known shells where the behavior can be
7+
implemented safely.
8+
39
## 11.1
410

511
[GHSA-5j98-mcp5-4vw2](https://github.com/isaacs/node-glob/security/advisories/GHSA-5j98-mcp5-4vw2)
612

713
- Add the `--shell` option for the command line, with a warning
814
that this is unsafe. (It will be removed in v12.)
9-
- Add the `--cmd-arg`/`-g` as a way to *safely* add positional
15+
- Add the `--cmd-arg`/`-g` as a way to _safely_ add positional
1016
arguments to the command provided to the CLI tool.
1117
- Detect commands with space or quote characters on known shells,
1218
and pass positional arguments to them safely, avoiding

src/bin.mts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,7 @@ try {
357357
const { SHELL = 'unknown' } = process.env
358358
const shellBase = basename(SHELL)
359359
const knownShells = ['sh', 'ksh', 'zsh', 'bash', 'fish']
360-
if (
361-
(shell || /[ "']/.test(cmd)) &&
362-
knownShells.includes(shellBase)
363-
) {
360+
if ((shell || /[ "']/.test(cmd)) && knownShells.includes(shellBase)) {
364361
const cmdWithArgs = `${cmd} "\$${shellBase === 'fish' ? 'argv' : '@'}"`
365362
if (shellBase !== 'fish') {
366363
cmdArg.unshift(SHELL)
@@ -370,13 +367,13 @@ try {
370367
} else {
371368
if (shell) {
372369
process.emitWarning(
373-
'The --shell option is unsafe, and will be removed. To pass ' +
370+
'The --shell option is not supported on this system. To pass ' +
374371
'positional arguments to the subprocess, use -g/--cmd-arg instead.',
375-
'DeprecationWarning',
372+
'UnsupportedWarning',
376373
'GLOB_SHELL',
377374
)
378375
}
379-
stream.on('end', () => foregroundChild(cmd, cmdArg, { shell }))
376+
stream.on('end', () => foregroundChild(cmd, cmdArg))
380377
}
381378
}
382379
} catch (e) {

test/bin.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ const { version } = JSON.parse(
1111
)
1212
const bin = fileURLToPath(new URL('../dist/esm/bin.mjs', import.meta.url))
1313

14-
const foregroundChildCalls: [
15-
string,
16-
string[],
17-
undefined | SpawnOptions,
18-
][] = []
14+
const foregroundChildCalls: [string, string[]][] = []
1915
let mockForegroundChildAwaiting: undefined | Promise<void> = undefined
2016
let resolveMockForegroundChildAwaiting: undefined | (() => void) =
2117
undefined
@@ -30,7 +26,10 @@ const mockForegroundChild = {
3026
resolveMockForegroundChildAwaiting?.()
3127
resolveMockForegroundChildAwaiting = undefined
3228
mockForegroundChildAwaiting = undefined
33-
foregroundChildCalls.push([cmd, args, options])
29+
if (options !== undefined) {
30+
throw new Error('should not pass in spawn opts')
31+
}
32+
foregroundChildCalls.push([cmd, args])
3433
},
3534
}
3635
t.beforeEach(() => (foregroundChildCalls.length = 0))
@@ -148,7 +147,6 @@ t.test('append positional args safely to shell in fish', async t => {
148147
'a/x.y',
149148
'a/b/z.y',
150149
],
151-
undefined,
152150
],
153151
])
154152
})
@@ -183,13 +181,12 @@ t.test('UNSAFE positional args with --shell', async t => {
183181
'foreground-child': mockForegroundChild,
184182
})
185183
await p
186-
t.strictSame(foregroundChildCalls, [
187-
[c, ['a/x.y', 'a/b/z.y'], { shell: true }],
188-
])
184+
t.strictSame(foregroundChildCalls, [[c, ['a/x.y', 'a/b/z.y']]])
189185
t.strictSame(warnings, [
190186
[
191-
'The --shell option is unsafe, and will be removed. To pass positional arguments to the subprocess, use -g/--cmd-arg instead.',
192-
'DeprecationWarning',
187+
'The --shell option is not supported on this system. To pass ' +
188+
'positional arguments to the subprocess, use -g/--cmd-arg instead.',
189+
'UnsupportedWarning',
193190
'GLOB_SHELL',
194191
],
195192
])
@@ -238,7 +235,6 @@ t.test('safe positional args with --cmd-arg/-g', async t => {
238235
[
239236
c,
240237
['-p', 'process.argv.map(s=>s.toUpperCase())', 'a/x.y', 'a/b/z.y'],
241-
{ shell: false },
242238
],
243239
])
244240
t.strictSame(warnings, [])

0 commit comments

Comments
 (0)