Skip to content

fix: update node, regenerate the lockfile and run the audit pass - #13

Merged
javierarams merged 11 commits into
mainfrom
fix/security-audit-and-node-update
Oct 29, 2026
Merged

javierarams merged 11 commits into
mainfrom
fix/security-audit-and-node-update

Conversation

@javierarams

@javierarams javierarams commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

xhr still uses Node 10 and a v1 lockfile, so a new release needs a toolchain update first. The steps are the same as in videojs/video.js#9231 and videojs/video.js#9232:

  1. Update Node.
  2. Regenerate the lockfile.
  3. Run the audit pass.

Before, using

  • node: v10.24.1
  • npm: 6.14.12

npm audit showed:

found 245 vulnerabilities (15 low, 45 moderate, 144 high, 41 critical) in 649 scanned packages

npm 11 counts vulnerabilities per package, not per path. With npm 11, the same lockfile shows 51 vulnerabilities (2 low, 9 moderate, 27 high, 13 critical).

Now, using

  • node: v24.21.0
  • npm: 11.19.0

npm audit shows 5 low severity vulnerabilities. One elliptic advisory causes all of them, and the advisory has no patched release. It affects only dev dependencies.

The tests did not run on main. The lockfile pinned a run-browser commit from 2016 that needs phantomjs, and the lockfile did not include phantomjs. Newer run-browser versions read the browser console only after the page loads. Short test files then print no TAP output and still pass. This PR replaces run-browser with a small runner. All 151 assertions pass.

The runtime dependency ranges do not change. The runtime advisories in @babel/runtime and min-document have fixes inside the current ranges.

Replaces #11 for its security goal. min-document 2.19.1 fixes the advisory, and global ~4.4.0 already allows that version.

Specific Changes proposed

From the third commit, each commit passes the install, the build and npm test by itself. xhr has no lint setup.

  • Updated Node to 24 in .nvmrc and added engines. The engines value is the same as in video.js.
    • npm 11 regenerated the lockfile as v3.
    • npm 11 moved @babel/runtime from 7.5.5 to 7.29.10, because @videojs/babel-config has a peer dependency on ^7.11.2.
  • Replaced run-browser with test/runner.js.
    • The runner bundles each test file with browserify 17 and runs it in the installed Chrome through playwright-core. CHROME_BIN sets a different browser binary.
    • The runner uses a free port, writes TAP and sets the exit code. The runner does not need tap-spec.
    • npm run browser still serves the tests for a manual run.
  • Changed the cross-domain error test to use the mock server on a second origin. The mocky.io URL in the test does not exist anymore, so the test always failed.
  • Updated the workflow actions to versions with Node 24 runtimes. GitHub deprecated the node12, node16 and node20 action runtimes.
    • The workflow writes to $GITHUB_OUTPUT, because GitHub deprecated the set-output command.
    • Removed xvfb, the Firefox audio packages and the BrowserStack secrets. The tests use only headless Chrome.
  • Ran npm audit fix. Result: 11 vulnerabilities (5 low, 6 high)
    • Added an override for crypto-browserify. npm audit fix moves it to 3.3.0, which uses a sha.js version with a critical advisory.
  • Replaced pre-commit with husky 9. pre-commit depends on a cross-spawn version with a high advisory.
    • pre-commit installs the hook from a dependency install script. npm 12 blocks these scripts by default.
    • The prepare script installs the hook from .husky/pre-commit. The hook continues to run npm test.
  • Added an override for chokidar. @babel/cli 7 uses chokidar 3, which depends on braces. All braces versions have a high advisory.
    • chokidar 4 keeps the API that babel --watch uses. npm start works.
  • Updated the @babel/core range to ^7.29.7. Older versions have a low advisory. video.js uses the same range.
  • Changed repository in package.json to the object form. npm publish shows a warning for the string form.
  • Updated @babel/preset-env to ^7.29.7. Version 7.14 installs deprecated proposal plugins, and npm shows a warning for each plugin.
  • Changed typings in package.json to ./index.d.ts. The old value ./lib/index.d.ts points to a file that the build does not make, so TypeScript did not find the types.
    • npm pack --dry-run shows that the package contains index.d.ts.

Built files / package checks:

  • lib/ from main is byte identical to the lib/ in the published 2.7.0 package.
  • The new lib/ has the same AST for all code from src/. The differences are format changes from newer Babel versions.
  • lib/interceptors.js also has newer versions of the inline for-of helpers from Babel. The helpers do the same checks.
  • The lib/ from the published 2.7.0 package passes the new test suite.
  • npm pack --dry-run gives the same 15 files as npm 6 on main.

Follow-up items:

  • elliptic GHSA-848j-6mx2-7j84 (low) has no fixed version. It comes from the crypto-browserify shim in browserify.
  • The published 2.7.0 package contains .idea/ files that git does not track. A publish from a clean clone prevents this.
  • The old CI logs are no longer available, and no CI run on main exists. The first CI run is on this PR.
  • If CI does not find Chrome on ubuntu-latest, set CHROME_BIN in the workflow.

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chrome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
    • Example created (starter template on JSBin)
  • Reviewed by Two Core Contributors

The `engines` value is the same as in video.js. The v1 lockfile did not list `phantomjs`, which the pinned `run-browser` commit needs. npm 11 adds it to the v3 lockfile.

npm 11 also moves `@babel/runtime` from 7.5.5 to 7.29.10, because `@videojs/babel-config` has a peer dependency on `^7.11.2`.
`run-browser` is not maintained. The lockfile pins a `run-browser` commit from 2016 that runs the tests in phantomjs 1.9. The tests did not start, because the lockfile did not include `phantomjs`.

Newer `run-browser` versions read the browser console only after the page loads. Short test files then print no TAP output and still pass.

The new runner bundles each test file with `browserify` and runs it in the installed Chrome, or in the browser at `CHROME_BIN`. It writes TAP to stdout and sets the exit code. The new runner does not need `tap-spec`.
The mocky.io URL in the test does not exist anymore, so the test always failed. The mock server now sends a CORS 404 response on a second origin. The request stays cross-origin and does not use the network.
GitHub deprecated the node12, node16 and node20 action runtimes. The workflow writes to `$GITHUB_OUTPUT`, because GitHub deprecated the `set-output` command.

The tests use only headless Chrome. The workflow does not need xvfb, the Firefox audio packages or the BrowserStack secrets.
All versions stay inside the declared ranges. The lockfile now resolves a fixed runtime version of `min-document`.

`npm audit fix` moves `crypto-browserify` from 3.12.1 to 3.3.0 to remove a low `elliptic` finding. `crypto-browserify` 3.3.0 uses `sha.js` 2.2.6, which has a critical advisory. The override keeps `crypto-browserify` on 3.12.
`pre-commit` 1.2.2 depends on a `cross-spawn` version with a high advisory. `pre-commit` installs the hook from a dependency install script. npm 11 shows a warning for these scripts, and npm 12 blocks them by default.

husky installs the hook from the `prepare` script of the package. The hook continues to run `npm test`.
`@babel/cli` 7 uses `chokidar` 3, which depends on `braces`. All `braces` versions have a high advisory. `chokidar` 4 has no `braces` dependency and keeps the `FSWatcher` API that `babel --watch` uses.
`@babel/core` 7.29.0 and older have a low advisory. These versions also allow `@babel/traverse` and `@babel/helpers` versions with known advisories. video.js uses the same range.
`npm publish` shows a warning for the string form and changes it. GitHub does not serve the `git://` protocol anymore.
`@babel/preset-env` 7.14 installs deprecated proposal plugins, and npm shows a warning for each plugin. The only change in `lib/` is one pair of braces in an inline Babel helper.

@spuppo-mux spuppo-mux left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typings points to ./lib/index.d.ts, but the package does not contain that file. The types file is ./index.d.ts.

Lets add this on this PR. Otherwise, lgtm

@spuppo-mux

Copy link
Copy Markdown

Also opened #14 with the follow up items

The typings field pointed to ./lib/index.d.ts. The build does not make that file, so TypeScript users did not get the types.
@javierarams
javierarams merged commit 229852d into main Oct 29, 2026
4 checks passed
@javierarams
javierarams deleted the fix/security-audit-and-node-update branch October 29, 2026 14:27
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.

3 participants