LearnNewsExamplesServices
Frontmatter
id18812
titleTwo lodash-es advisories ship inside the mermaid bundle, unreachable today by accident
stateClosed
labels
bugaibuild
assigneesneo-opus-vega
createdAtSep 16, 2026, 9:21 PM
updatedAtSep 17, 2026, 10:49 AM
githubUrlhttps://github.com/neomjs/neo/issues/18812
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 17, 2026, 10:49 AM

Two lodash-es advisories ship inside the mermaid bundle, unreachable today by accident

neo-opus-vega
neo-opus-vega commented on Sep 16, 2026, 9:21 PM

Context

Two open Dependabot alerts on lodash-es, both reaching us transitively:

# severity range patched summary
97 high >= 4.0.0, <= 4.17.23 4.18.0 code injection via _.template imports key names
98 medium <= 4.17.23 4.18.0 prototype pollution via array path bypass in _.unset and _.omit

Nothing in neomjs/neo imports lodash. The path is entirely upstream:

mermaid@12.0.0 (devDependency)
├─┬ chevrotain@11.1.2
│ ├── lodash-es@4.17.23          ← vulnerable
│ ├─┬ @chevrotain/cst-dts-gen@11.1.2
│ │ └── lodash-es@4.17.23        ← vulnerable
│ └─┬ @chevrotain/gast@11.1.2
│   └── lodash-es@4.17.23        ← vulnerable
└─┬ dagre-d3-es@7.0.14
  └── lodash-es@4.18.1           ← already patched

Live latest-open sweep 2026-09-16T19:2xZ: no open ticket on either alert. A2A sweep of the latest 30 messages: no claim on dependency security.

The Problem — "devDependency" understates it

mermaid is a devDependency, which normally ends the conversation. It does not here: the bundle it produces is a published artifact.

  • npm run bundle-mermaid → buildScripts/build/mermaid.mjs → dist/mermaid.mjs
  • .npmignore:81 carries !/dist/mermaid.mjs — an explicit negation, so that file is published
  • src/component/wrapper/Mermaid.mjs and src/main/addon/Mermaid.mjs load it at runtime

So the chevrotain code that imports lodash-es is compiled into an artifact every consumer of neo.mjs receives. The honest framing is not "we do not use lodash" but "we ship a bundle that contains lodash code".

The Architectural Reality — and why this is not urgent

Measured rather than assumed, in both the tree and the shipped artifact:

1. Chevrotain does not import either vulnerable function. Its 27 lodash-es import sites pull 40 names:

assign clone compact defaults difference drop dropRight every filter find first flatMap flatten forEach groupBy has identity includes indexOf isArray isEmpty isFunction isObject isRegExp isString isUndefined keys last map noop pickBy reduce reject some uniq values …

template, unset and omit are absent. It uses pickBy, not omit. The single template hit in chevrotain's source is the word inside a comment about template strings.

2. The shipped bundle contains neither. Against the built dist/mermaid.mjs (3.4 MB):

function template   0
function unset      0
function omit       0
baseUnset           0

esbuild tree-shakes what nothing imports, so the vulnerable sinks are not in the artifact at all.

So neither advisory is exploitable through this path today — not in node_modules, not in what consumers receive.

That is a reason to patch calmly, not a reason to dismiss. The tree-shake is an accident of chevrotain's current import list. A single patch-level chevrotain release that starts using omit would put a prototype-pollution sink into a published bundle, and by then the alert would already be closed as "not applicable" if we dismissed it.

Upstream has moved, but we cannot follow. chevrotain@13.2.0 dropped lodash-es entirely — its dependency set is @chevrotain/* only. But mermaid@latest is still 12.0.0 and pins chevrotain: ~11.1.2, so the fix is unreachable by upgrading anything we declare.

The Fix

An overrides entry, which is already this repository's idiom for exactly this shape:

"overrides": {
  "gray-matter":    {"js-yaml":    "^3.15.2"},
  "monaco-editor":  {"dompurify":  "^3.4.13"}
}

Add "lodash-es": "^4.18.0" at top level rather than scoped under chevrotain. Scoped would need three entries — chevrotain, @chevrotain/cst-dts-gen, @chevrotain/gast — because a nested override only governs that package's own dependency. Top level covers all three and is a no-op for dagre-d3-es, which already resolves 4.18.1.

4.17.23 → 4.18.x is same-major, and one consumer in this very tree already runs 4.18.1.

Acceptance Criteria

  • AC-1: npm ls lodash-es --all reports no version <= 4.17.23; the three chevrotain copies resolve ^4.18.0.
  • AC-2: both alerts close on the next Dependabot scan. Until then, the AC-1 output is the evidence.
  • AC-3: npm run bundle-mermaid still produces a working dist/mermaid.mjs, verified by the specs that render it — e2e/portal/LearnMermaidRender.spec.mjs and unit/component/MermaidTheme.spec.mjs.
  • AC-4: the package-lock.json diff touches only lodash-es resolutions. An override that quietly re-resolves unrelated packages is a different change.
  • AC-5 — revalidationTrigger: the override is retired when mermaid moves to chevrotain@13, which needs no lodash at all. Recorded as a comment beside the entry, so removing it is a decision rather than an archaeology exercise.

Out of Scope

  • Upgrading mermaid — 12.0.0 is latest and pins the vulnerable range itself.
  • Vendoring or patching chevrotain.
  • The other overrides entries.
  • Rebuilding and committing dist/mermaid.mjs — it is gitignored (.gitignore:68) and built at publish time.

Avoided Traps

  • ⛔ Do not dismiss the alerts as "devDependency, not shipped". .npmignore:81 publishes the bundle; the code does reach consumers.
  • ⛔ Do not dismiss them as "not exploitable" either. True today, and true only because chevrotain happens not to import those two functions. The measurement belongs in the PR body as the reason it is not urgent, never as the reason to close it unpatched.
  • ⛔ Do not scope the override under chevrotain alone. Two of the three vulnerable copies sit under @chevrotain/cst-dts-gen and @chevrotain/gast, which a chevrotain-scoped entry does not reach.
  • ⛔ Do not let the lock diff sprawl. npm install under a new override can re-resolve more than intended; AC-4 is the check, and a wide diff means stop and narrow rather than ship it.

Related

Dependabot alerts #97, #98 · .npmignore:81 (publishes the bundle) · buildScripts/build/mermaid.mjs

Origin Session ID: 5bf0b816-b919-40fc-9c18-fee751fd1635

Retrieval Hint: "lodash-es transitive chevrotain mermaid bundle shipped npmignore negation override tree-shaken template unset omit"

tobiu referenced in commit 09f2f22 - "fix(deps): pin lodash-es past the two advisories that reach us through mermaid (#18812) (#18813) on Sep 17, 2026, 10:49 AM
tobiu closed this issue on Sep 17, 2026, 10:49 AM