CVE-2026-140012: Terser: Input sourcemap sourcesContent leaks, revealing input source code
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:
js 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).
Other sources
Terser is a JavaScript parser, mangler, and compressor toolkit for ES6+. Prior to 4.8.2, and from 5.0.0 to before 5.51.3, when minify() is given an input source map through the sourceMap.content option, Terser copies that map's sourcesContent into the generated source map even when includeSources is false. Anyone who receives the generated source map can read the original source code, which may include comments, constants, or embedded secret tokens. This issue is fixed in versions 4.8.2 and 5.51.3.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
npm/terserto a version that resolves this vulnerability.Fixed in 5.51.3 - Upgrade
Upgrade
npm/terserto a version that resolves this vulnerability.Fixed in 4.8.2 - Configuration
Do not provide an input source map through the sourceMap.content option.
Terser sourceMap.content = disabled
Event History
Frequently Asked Questions
When is an application exposed to this issue?
Exposure requires a build process that passes an input source map to Terser through sourceMap.content and distributes the generated source map to someone who should not be able to view the original source. Builds that do not use sourceMap.content are not described as affected.
Does setting includeSources to false prevent the leak in affected versions?
No. In affected versions, Terser copies sourcesContent from the input source map into the generated source map even when includeSources is false.
What could be disclosed through an affected generated source map?
Anyone with access to the generated source map may be able to read the original input source code contained in sourcesContent. This can expose comments, constants, or embedded secret tokens.
Which Terser versions contain the fix?
The issue is fixed in Terser 4.8.2 and 5.51.3. Affected releases are versions before 4.8.2, plus versions from 5.0.0 up to but not including 5.51.3.
What can be done if upgrading is not immediately possible?
Avoid providing input source maps through sourceMap.content, or prevent generated source maps from being distributed to untrusted recipients. Review already published generated source maps for copied sourcesContent and remove or restrict access to maps containing sensitive source material.