CVE-2026-140012 is a medium-severity (CVSS 5.3) CWE-540 vulnerability in terser. A fix is available for terser — see the affected versions and patch details below.
Terser: Input sourcemap sourcesContent leaks, revealing input source code
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
terser📦terserReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects npm packages — download data is not available via public APIs for these ecosystems.
Description
Impact
Leakage of user source code, which may include comments, constants with secret tokens, etc.
When using Terser with an input sourcemap (sourceMap.content), and this input sourcemap has original source information (sourcesContent), Terser leaks this sourcesContent into the output, even when the user specified includeSources: false to opt-out.
Details
To help developers debug their JS applications, Terser's minify function reads and produces source maps.
To minify a JS file that has a corresponding source map, and generate a source map in turn, we call Terser's minify function like so:
const out = await minify(INPUTFILE, {
sourceMap: {
content: INPUTMAP,
},
});
out.map // output source map
Source maps may contain the content of files, in their sourcesContent property. Files which may include secrets.
Terser shouldn't include sourcesContent by default, unless we pass includeSources: true under sourceMap options.
But it does include the sourcesContent of the INPUTMAP even if includeSources: false, which is the leak we're discussing.
Patches
The problem will be patched in version 5.51.3, and 4.8.2.
Workarounds
Do not use an input sourcemap (sourceMap.content option).
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦npm | terser | all versions | 4.8.2npm install terser@4.8.2 |
| 📦npm | terser | ≥ 5.0.0&&< 5.51.3 | 5.51.3npm install terser@5.51.3 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for terser, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update terser to 4.8.2 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-140012 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
Frequently Asked Questions
Is CVE-2026-140012 in your dependencies?
Find it across npm, including transitive dependencies.