CVE-2026-138148 — Micromatch Picomatch — CWE-185
picomatch through 4.0.7 contains a glob filter bypass vulnerability because globstar (**) patterns are compiled without the dotAll flag and fail to match line terminators. Attackers who control file, object key or archive entry names containing newline characters can evade ** deny patterns, causing excluded resources to be included and exposed.
picomatch through 4.0.7 contains a glob filter bypass vulnerability because globstar (**) patterns are compiled without the dotAll flag and fail to match line terminators. Attackers who control file, object key or archive entry names containing newline characters can evade ** deny patterns, causing excluded resources to be included and exposed.
🎯 What is this vulnerability?
CVE‑2026‑138148 is a glob filter bypass in the JavaScript library picomatch (v4.0.7 and earlier).
Picomatch is a fast, POSIX‑compliant glob matcher used by many Node.js tools (e.g., npm, Yarn, ESLint, Jest, etc.). The vulnerability arises from the way the library compiles glob patterns that contain the globstar ()** operator.
Technical flaw
- CWE‑185 – Incorrectly Handling of Input The library compiles glob patterns into regular expressions. For patterns that contain
- Resulting behavior When an application uses picomatch to filter out files (e.g., “do not process files that match
- CVSS vector
, the generated regex omits the dotAll (s) flag**.
Without dotAll, the . meta‑character does not match line‑terminator characters (\n, \r). Consequently, a pattern such as */.js will not match file names that contain newline characters, because the newline breaks the match.*/.tmp”), an attacker can craft a file name that includes a newline. The glob filter will treat the part after the newline as a separate string, bypassing the deny pattern and allowing the file to be processed or exposed.CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N
* No authentication or privilege is required.
* The impact is low confidentiality (exposed data) but no integrity or availability impact.⚡ Attack Chain
NOTE: The following chain is a generic illustration of how the vulnerability can be abused in a Node.js application that uses picomatch for file filtering. The exact endpoint or parameter names are not specified in the CVE; the example below assumes a typical file‑upload API.
1. Discovery & Reconnaissance
| Step | Technique | Tools / Commands |
|---|---|---|
| Identify the library | Search package.json or node_modules for picomatch | grep -R "picomatch" -n package.json node_modules/ |
| Verify version | Inspect package.json or npm ls picomatch | npm ls picomatch |
| Confirm vulnerability | Check if version ≤ 4.0.7 | npm view picomatch version |
If the target is a public API, a simple curl to the upload endpoint can reveal that the server accepts file uploads and that the response contains the file name (common in many file‑upload services).
2. Exploitation
Goal: Upload a file whose name contains a newline character that bypasses a */.tmp deny pattern.
a. Crafting the payload
# Create a file with a newline in its name
printf "evil.txt\n.tmp" > /tmp/evil.txtThe file name is evil.txt\n.tmp. The part after the newline (.tmp) would normally be matched by a deny pattern, but because picomatch’s regex does not use dotAll, the newline splits the match.
b. Uploading the file
Assume the API endpoint is /api/upload and accepts multipart/form-data:
curl -X POST http://target.example.com/api/upload \
-F "file=@/tmp/evil.txt" \
-H "Authorization: Bearer <token>"Illustrative – the actual endpoint and authentication method may differ.
c. Server processing
1. The server receives the multipart request and extracts the file name evil.txt\n.tmp.
2. It passes the file name through picomatch with a deny pattern such as */.tmp.
3. Because the regex lacks dotAll, the pattern matches only up to the newline, not the .tmp suffix.
4. The file is accepted and stored (or processed) as evil.txt\n.tmp.
3. Post‑exploitation
🌍 Real World Impact
| Impact | Assessment |
|---|---|
| Confidentiality | Low – only the data in the uploaded file is exposed. |
| Integrity | None – the vulnerability does not alter existing data. |
| Availability | None – no denial‑of‑service effect. |
Practical consequences
.tmp, .log) can be subverted. 🛡️ Remediation & Mitigation
1. Patch
| Affected | Fixed |
|---|---|
| picomatch 4.0.7 and earlier | 4.0.8 (released 2026‑11‑25) – regexes for ** patterns now use the dotAll flag. |
Action:
npm install picomatch@^4.0.8or update the dependency in package.json and run npm update.
2. Workarounds (if patching is not immediately possible)
| Mitigation | Implementation |
|---|---|
| Disable globstar | In the application’s configuration, avoid using in deny patterns. Replace /*.tmp with *.tmp or use a custom filter that explicitly checks for newline characters. |
| Pre‑sanitize file names | Strip or encode newline characters before passing the name to picomatch. Example in Node.js: const sanitized = filename.replace(/[\r\n]/g, '_'); |
| WAF / ModSecurity rule | Block uploads containing newline characters in the file name. Example ModSecurity rule: <br>SecRule REQUEST_FILENAME "@rx \n" "id:1001,phase:2,deny,msg:'Newline in filename'" |
3. Detection
| Indicator | Log pattern / IoC | |
|---|---|---|
| Upload request with newline in filename | POST /api/upload with filename=".*\n.*" | |
| File stored with newline in name | File system audit: ls -l | grep $'\n' |
| Application logs mentioning “globstar” or “dotAll” | grep -i "globstar" /var/log/app.log |
Example WAF log entry (ModSecurity):
[modsecurity] [client 192.0.2.10] [id 1001] [msg "Newline in filename"] [uri /api/upload] [status 403]4. Monitoring
⚠️ Urgency
[🤖 CVE Professor AI Security Engine]
FOFA Query