Skip to content

Fix serialize-javascript RCE vulnerability (replace mocha with vitest, upgrade deps)#39

Merged
alexdima merged 1 commit intomainfrom
fix/serialize-javascript-vulnerability
Feb 28, 2026
Merged

Fix serialize-javascript RCE vulnerability (replace mocha with vitest, upgrade deps)#39
alexdima merged 1 commit intomainfrom
fix/serialize-javascript-vulnerability

Conversation

@alexdima
Copy link
Copy Markdown
Member

Problem

Dependabot alert #25: serialize-javascript 6.0.2 is vulnerable to RCE via RegExp.prototype.flags and Date.prototype.toISOString(). The earliest fixed version is 7.0.3.

The vulnerable dependency was introduced via two paths:

  • mocha 10.8.2 → serialize-javascript 6.0.2
  • webpack 5.x → terser-webpack-plugin → serialize-javascript 6.0.2

Solution

  • Replace mocha with vitest — eliminates the mocha dependency path entirely. Vitest runs TypeScript directly, so test files no longer need to be compiled by tsc.
  • Upgrade webpack 5.75 → 5.105 and webpack-cli 5.0 → 6.0
  • Add npm overrides for serialize-javascript: ^7.0.3 — needed because terser-webpack-plugin still pins ^6.0.2
  • Upgrade @types/node ^18 → ^22 (required by vitest 4.x)
  • Add skipLibCheck to tsconfig (standard practice; vitest/vite types reference newer TS features)
  • Exclude test files from tsc compilation (vitest handles them directly)
  • Add vitest.config.ts with globals mode and an alias to resolve the emscripten-generated onig.js

Verification

$ npm audit
found 0 vulnerabilities

Resolves #25.

…grade deps

- Replace mocha with vitest for test runner (fixes serialize-javascript
  transitive dep from mocha)
- Upgrade webpack 5.75→5.105, webpack-cli 5.0→6.0
- Add npm override for serialize-javascript ^7.0.3 (fixes transitive
  dep from webpack→terser-webpack-plugin)
- Upgrade @types/node ^18→^22 (required by vitest 4.x)
- Add skipLibCheck to tsconfig (vitest/vite types need newer TS features)
- Exclude test files from tsc (vitest runs TypeScript directly)
- Add vitest.config.ts with globals and onig.js alias
- Remove compiled test output from git (no longer needed)

Resolves serialize-javascript RCE vulnerability (GHSA issue #25).
npm audit now reports 0 vulnerabilities.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alexdima alexdima marked this pull request as ready for review February 28, 2026 13:27
@alexdima alexdima enabled auto-merge (squash) February 28, 2026 13:27
@alexdima alexdima merged commit 4554315 into main Feb 28, 2026
8 checks passed
@alexdima alexdima deleted the fix/serialize-javascript-vulnerability branch February 28, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntax highlighting works differently in web vs desktop

2 participants