Skip to content

Backport #4335: [core] Fix vulnerable nanoid pin by dropping the dependency - #4881

Closed
github-actions[bot] wants to merge 1 commit into
stablefrom
backport/pr-4335-to-stable
Closed

github-actions[bot] wants to merge 1 commit into
stablefrom
backport/pr-4335-to-stable

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Automated backport of #4335 to stable (backport job run).

AI recommendation: This is a security fix: it removes the exact nanoid@5.1.6 pin affected by GHSA-28wg-ghj8-5hjv, which stable still carries (packages/core/package.json on origin/stable pins nanoid: 5.1.6), while preserving the existing seeded-token/PRNG draw pattern so recorded runs do not diverge on replay. The rest of the diff is mechanical call-site updates plus a test pinning the 5.1.6 golden output; note the QuickJS engine file does not exist on stable, so that hunk will need dropping, and PR #4336 may already carry an equivalent change for 4.x.

Merge conflicts were resolved by AI (opencode with anthropic/claude-opus-5). Please review the conflict resolution carefully before merging.

Closes #3842.

`@workflow/core` pins `nanoid` exactly at `5.1.6`, which is in the
vulnerable range of
[GHSA-28wg-ghj8-5hjv](GHSA-28wg-ghj8-5hjv)
(high, `>=4.0.0 <5.1.16`). Because the pin is exact, apps can only move
off it with an `overrides`/`resolutions` entry.

This PR removes the dependency instead of bumping it.

Core uses nanoid only to build the seeded generator for default hook
tokens: `customRandom(urlAlphabet, 21, bytes from the run-seeded PRNG)`.
In 5.1.16, `customRandom` requests 21 bytes per id instead of 34. For
the same seed, that changes both the hook token and every seeded value
drawn after it (`Math.random()` inside the workflow, later tokens):

| seed `wrun_test:seed` | 1st token | 2nd token | next `Math.random()` |
|---|---|---|---|
| nanoid 5.1.6 | `pVjvQyygUGbIid9mUBIhp` | `mgNKWnMBr9yywfW_syBGT` |
`0.3399…` |
| nanoid 5.1.16 | `d9mUBIhphoZLwZ1T1ma-k` | `jdT3d6rupVjvQyygUGbIi` |
`0.1769…` |

A run recorded before the upgrade and replayed after it would diverge.
On `stable`, a plain bump failed the `hook-sleep-interaction` replay
tests with `ReplayDivergenceError` (see #4336's history). The same
applies to users who add a `nanoid` override today.

- `packages/core/src/seeded-nanoid.ts` reproduces nanoid 5.1.6's
`customRandom(urlAlphabet, 21, ...)` exactly: 34 draws per id, read from
the end of the batch.
- `seeded-nanoid.test.ts` pins the recorded 5.1.6 output and PRNG
position, so any change to the draw pattern fails a test.
- The node:vm engine (`workflow.ts`), the QuickJS engine
(`runtime/quickjs-runtime.ts`) and the test helpers all use it.
- `nanoid` is removed from `@workflow/core`'s dependencies.
- The two private Next.js workbenches, which use nanoid directly, are
bumped to 5.1.16.
- Changeset: patch for `@workflow/core`, worded as a security fix so the
backport check picks it up.

- `pnpm --filter @workflow/core test` passes (3070 tests on current
`main`), and `typecheck` passes.
- Installing this PR's workflow-tarballs build and running `npm audit
--omit=dev` reports 0 vulnerabilities, with no `nanoid` in the tree.

- #4336 carries the same change for `stable` (4.x), plus the undici
7.29.0 backport from #3315.
- #3545 is the community PR for the plain bump. It has the replay issue
described above.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
Co-authored-by: Pranay Prakash <1797812+pranaygp@users.noreply.github.com>
Co-authored-by: Peter Wielander <peter.wielander@vercel.com>
Signed-off-by: Pranay Prakash <pranay.gp@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a88f327

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
example-nextjs-workflow-turbopack Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
example-nextjs-workflow-webpack Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
example-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-astro-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-express-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-fastify-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-hono-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-nestjs-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-nitro-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-nuxt-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-python-workflow Error Error v0 Oct 14, 2026 6:26pm UTC
workbench-sveltekit-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-tanstack-start-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workbench-vite-workflow Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workflow-swc-playground Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workflow-tarballs Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
workflow-web Ready Ready Preview, v0 Oct 14, 2026 6:26pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
workflow-docs Skipped Skipped v0 Oct 14, 2026 6:26pm UTC

@vercel
vercel Bot temporarily deployed to Preview – workflow-docs October 14, 2026 18:21 Inactive

This branch was previously deployed

1 inactive deployment
Preview – workflow-docs — a88f3277 Deployed Oct 14, 2026 by vercel[bot]
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.

1 participant