Terser: Input sourcemap sourcesContent leaks, revealing input source code
Published 1 Dec 2026 · Updated 1 Dec 2026
Affected packages
- Affected
- <4.8.2
- Fixed in
- 4.8.2
npm install terser@4.8.2- Affected
- >=5.0.0 <5.51.3
- Fixed in
- 5.51.3
npm install terser@5.51.3Which terser does your project really install?
Works for private projects: the file is read in memory to run the scan and then dropped. Also reads yarn.lock, pnpm-lock.yaml or package.json.
Public repo?
Look after several JavaScript apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Details
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 mapSource 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).
Is GHSA-6jpm-p5cq-9q44 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected terser, and gives you the command that fixes it.
More advisories for terser
- HighCVE-2022-25858Terser insecure use of regular expressions leads to ReDoS · 16 Jul 2022
References
- Linkgithub.com/terser/terser/security/advisories/GHSA-6jpm-p5cq-9q44
- Advisorynvd.nist.gov/vuln/detail/CVE-2026-140012
- Linkgithub.com/terser/terser/commit/a63e814e816405e1d9cad106b1aeaa29c5c12bdc
- Linkgithub.com/terser/terser/commit/bab93bde6e2156cdd2fdd27eadc4dffd7362dee3
- Packagegithub.com/terser/terser
- Linkgithub.com/terser/terser/releases/tag/v4.8.2
- Linkgithub.com/terser/terser/releases/tag/v5.51.3
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.