MediumGHSA-6jpm-p5cq-9q44CVE-2026-140012

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
Update to the fixed version for your release line, for example:npm install terser@4.8.2
Affected
>=5.0.0 <5.51.3
Fixed in
5.51.3
Update to the fixed version for your release line, for example:npm install terser@5.51.3

We confirm your address first. See our privacy policy.

Which terser does your project really install?

Drop your package-lock.json hereWe find the exact terser version you install, even when another package pulls it in, and tell you if it’s affected and what to run. Free, no sign-up.

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 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).

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
terser security overview

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.