fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

fix(world-local): prevent path traversal via request-supplied IDs - #1829

Merged
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal
Apr 30, 2026
Merged

fix(world-local): prevent path traversal via request-supplied IDs#1829
TooTallNate merged 5 commits into
mainfrom
fix/world-local-path-traversal

Conversation

@TooTallNate

Copy link
Copy Markdown
Member

Summary

  • Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId, stream names, and tags) flowed straight into path.join() inside @workflow/world-local, so a client could send a payload like {"runId":"../../../package"} to /.well-known/workflow/v1/flow and read or write files outside the workflow data directory.
  • Added a centralized assertSafeEntityId helper in packages/world-local/src/fs.ts that rejects IDs which are empty, start with ., or contain /, \, or NUL bytes. This is permissive enough to accept every existing valid ID shape (ULIDs, composite keys like wrun_X-step_Y, base64url stream namespaces, tags like vitest-0) while blocking real traversal vectors.
  • Applied the check at each storage-layer entry point that composes IDs into filesystem paths: fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs / steps / events / hooks storage methods, and the streamer.

Test plan

  • pnpm --filter @workflow/world-local test — 266 → 328 passing (62 new unit + integration tests covering the exact payloads from the report: ../../../package, ../runs/wrun_…, backslash variants, NUL bytes, .locks, etc.)
  • pnpm --filter @workflow/core test — 591 passing

Request-supplied identifiers (runId, eventId, stepId, hookId, correlationId,
stream names, and tags) flowed directly into path.join() calls, allowing a
client to send values like '../../../package' and cause the backend to read
or write files outside the workflow data directory.
Add a centralized validator (assertSafeEntityId) that rejects IDs which are
empty, start with '.', or contain path separators or NUL bytes. Apply it at
each storage-layer entry point that composes IDs into filesystem paths:
fs.taggedPath / readJSONWithFallback / paginatedFileSystemQuery, the runs /
steps / events / hooks storage methods, and the streamer.
CopilotAI review requested due to automatic review settings April 22, 2026 21:21
@changeset-bot

changeset-botBot commented Apr 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 8d3898a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
NameType
@workflow/world-localPatch
@workflow/cliPatch
@workflow/corePatch
@workflow/vitestPatch
@workflow/world-postgresPatch
workflowPatch
@workflow/world-testingPatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/web-sharedPatch
@workflow/webPatch
@workflow/aiPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercelBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

📊 Benchmark Results

📈 Comparing against baseline from main branch. Green 🟢 = faster, Red 🔺 = slower.

workflow with no steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
💻 Local🥇 Nitro0.044s (+2.1%)1.005s (~)0.961s101.00x
💻 LocalExpress0.044s (~)1.005s (~)0.961s101.00x
🐘 PostgresExpress0.049s (-15.0% 🟢)1.009s (~)0.960s101.12x
🐘 PostgresNitro0.057s (-40.5% 🟢)1.010s (-3.2%)0.953s101.29x
workflow with 1 step

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.120s (-2.3%)2.009s (~)0.889s101.00x
💻 LocalExpress1.126s (~)2.005s (~)0.880s101.01x
💻 LocalNitro1.129s (~)2.006s (~)0.876s101.01x
🐘 PostgresNitro1.135s (~)2.009s (~)0.874s101.01x
workflow with 10 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express10.691s (-2.5%)11.018s (~)0.327s31.00x
🐘 PostgresNitro10.886s (~)11.018s (~)0.132s31.02x
💻 LocalExpress10.937s (~)11.023s (~)0.086s31.02x
💻 LocalNitro10.947s (~)11.023s (~)0.076s31.02x
workflow with 25 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express13.971s (-4.2%)14.021s (-6.7% 🟢)0.050s51.00x
🐘 PostgresNitro14.494s (-0.7%)15.019s (~)0.525s41.04x
💻 LocalNitro14.982s (-0.5%)15.280s (-4.7%)0.298s41.07x
💻 LocalExpress14.995s (~)15.029s (~)0.034s41.07x
workflow with 50 sequential steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express12.932s (-7.7% 🟢)13.021s (-10.8% 🟢)0.089s71.00x
🐘 PostgresNitro13.814s (-1.1%)14.020s (-2.0%)0.206s71.07x
💻 LocalNitro16.416s (-2.2%)17.031s (~)0.614s61.27x
💻 LocalExpress16.689s (+0.5%)17.030s (~)0.341s61.29x
Promise.all with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.196s (-5.1% 🟢)2.009s (~)0.812s151.00x
🐘 PostgresNitro1.253s (-1.7%)2.009s (~)0.756s151.05x
💻 LocalNitro1.504s (-7.8% 🟢)2.006s (-3.3%)0.502s151.26x
💻 LocalExpress1.512s (+1.6%)2.006s (~)0.494s151.26x
Promise.all with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.278s (-3.5%)3.009s (~)0.731s101.00x
🐘 PostgresNitro2.338s (-0.6%)3.010s (~)0.673s101.03x
💻 LocalNitro2.828s (-10.0% 🟢)3.008s (-22.6% 🟢)0.180s101.24x
💻 LocalExpress2.958s (~)3.208s (-7.1% 🟢)0.250s101.30x
Promise.all with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.371s (-3.3%)4.009s (~)0.638s81.00x
🐘 PostgresNitro3.455s (-0.7%)4.010s (~)0.554s81.03x
💻 LocalNitro7.405s (-11.3% 🟢)8.020s (-11.1% 🟢)0.614s42.20x
💻 LocalExpress8.209s (-1.6%)9.022s (~)0.814s42.44x
Promise.race with 10 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.199s (-4.6%)2.007s (~)0.808s151.00x
🐘 PostgresNitro1.260s (~)2.008s (~)0.749s151.05x
💻 LocalExpress1.516s (-19.9% 🟢)2.006s (-15.2% 🟢)0.489s151.26x
💻 LocalNitro1.585s (-15.1% 🟢)2.006s (-14.3% 🟢)0.421s151.32x
Promise.race with 25 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.269s (-3.1%)3.009s (~)0.740s101.00x
🐘 PostgresNitro2.315s (-1.0%)3.009s (~)0.694s101.02x
💻 LocalNitro2.903s (-5.3% 🟢)3.454s (-11.1% 🟢)0.550s91.28x
💻 LocalExpress3.170s (+1.2%)4.010s (+6.6% 🔺)0.840s81.40x
Promise.race with 50 concurrent steps

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express3.388s (-3.2%)4.008s (~)0.620s81.00x
🐘 PostgresNitro3.476s (~)4.009s (~)0.533s81.03x
💻 LocalNitro8.071s (-11.7% 🟢)9.021s (-10.0% 🟢)0.950s42.38x
💻 LocalExpress8.942s (+1.6%)9.276s (~)0.335s42.64x
workflow with 10 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.587s (-30.0% 🟢)1.006s (-1.7%)0.419s601.00x
🐘 PostgresNitro0.789s (-3.8%)1.006s (~)0.216s601.34x
💻 LocalExpress0.987s (~)1.158s (+7.7% 🔺)0.171s521.68x
💻 LocalNitro1.011s (+3.1%)1.627s (+48.7% 🔺)0.616s371.72x
workflow with 25 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.406s (-28.9% 🟢)2.007s (-11.1% 🟢)0.601s451.00x
🐘 PostgresNitro1.886s (-2.2%)2.030s (-3.4%)0.144s451.34x
💻 LocalExpress3.040s (+0.8%)3.609s (+0.7%)0.569s252.16x
💻 LocalNitro3.048s (~)3.729s (-0.8%)0.681s252.17x
workflow with 50 sequential data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express2.926s (-26.7% 🟢)3.137s (-28.2% 🟢)0.210s391.00x
🐘 PostgresNitro3.860s (-5.9% 🟢)4.077s (-11.4% 🟢)0.218s301.32x
💻 LocalNitro8.969s (-3.5%)9.479s (-5.4% 🟢)0.510s133.06x
💻 LocalExpress9.232s (~)9.942s (-0.8%)0.710s133.15x
workflow with 10 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.226s (-20.0% 🟢)1.007s (~)0.781s601.00x
🐘 PostgresNitro0.272s (-4.1%)1.007s (~)0.735s601.20x
💻 LocalNitro0.551s (-8.9% 🟢)1.004s (-1.7%)0.454s602.44x
💻 LocalExpress0.578s (+3.2%)1.004s (~)0.426s602.56x
workflow with 25 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.354s (-30.5% 🟢)1.006s (~)0.651s901.00x
🐘 PostgresNitro0.484s (-2.5%)1.007s (~)0.523s901.37x
💻 LocalNitro2.402s (-5.4% 🟢)3.009s (~)0.607s306.78x
💻 LocalExpress2.564s (+2.0%)3.009s (~)0.445s307.24x
workflow with 50 concurrent data payload steps (10KB)

💻 Local Development

WorldFrameworkWorkflow TimeWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.564s (-31.2% 🟢)1.006s (-1.1%)0.443s1201.00x
🐘 PostgresNitro0.769s (-2.6%)1.007s (~)0.238s1201.37x
💻 LocalNitro10.339s (-7.6% 🟢)11.028s (-5.5% 🟢)0.689s1118.34x
💻 LocalExpress11.094s (-0.9%)11.756s (-1.5%)0.662s1119.68x
Stream Benchmarks(includes TTFB metrics)
workflow with stream

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.153s (-25.5% 🟢)1.000s (~)0.001s (-31.3% 🟢)1.009s (~)0.856s101.00x
💻 LocalExpress0.201s (+0.7%)1.004s (~)0.012s (+2.5%)1.019s (~)0.818s101.31x
💻 LocalNitro0.205s (-3.9%)1.004s (~)0.010s (-20.0% 🟢)1.016s (~)0.810s101.34x
🐘 PostgresNitro0.208s (+1.6%)0.995s (~)0.001s (-6.7% 🟢)1.009s (~)0.801s101.36x
stream pipeline with 5 transform steps (1MB)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.496s (-21.2% 🟢)1.006s (~)0.003s (-9.7% 🟢)1.020s (~)0.524s591.00x
🐘 PostgresNitro0.597s (-4.4%)1.007s (~)0.004s (-5.7% 🟢)1.021s (~)0.424s591.20x
💻 LocalExpress0.752s (-0.6%)1.012s (-1.6%)0.010s (+1.5%)1.024s (-1.6%)0.271s591.52x
💻 LocalNitro0.857s (+2.2%)1.011s (~)0.009s (-1.4%)1.115s (~)0.258s541.73x
10 parallel streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express0.903s (-6.0% 🟢)1.109s (-13.2% 🟢)0.000s (+25.5% 🔺)1.118s (-14.4% 🟢)0.215s551.00x
🐘 PostgresNitro0.946s (-2.3%)1.148s (-7.9% 🟢)0.000s (-53.8% 🟢)1.161s (-7.7% 🟢)0.215s521.05x
💻 LocalNitro1.208s (-1.2%)2.020s (~)0.000s (+233.3% 🔺)2.022s (~)0.814s301.34x
💻 LocalExpress1.245s (+1.6%)2.023s (~)0.000s (-10.0% 🟢)2.024s (~)0.780s301.38x
fan-out fan-in 10 streams (1MB each)

💻 Local Development

WorldFrameworkWorkflow TimeTTFBSlurpWall TimeOverheadSamplesvs Fastest
🐘 Postgres🥇 Express1.629s (-8.1% 🟢)2.103s (-3.4%)0.000s (+Infinity% 🔺)2.112s (-3.9%)0.483s291.00x
🐘 PostgresNitro1.778s (-0.7%)2.102s (-1.8%)0.000s (-100.0% 🟢)2.113s (-2.8%)0.335s291.09x
💻 LocalNitro3.472s (+2.5%)4.102s (+1.7%)0.000s (-25.0% 🟢)4.104s (+1.7%)0.632s152.13x
💻 LocalExpress3.573s (+3.1%)4.099s (+1.6%)0.001s (-16.7% 🟢)4.101s (+1.6%)0.528s152.19x

Summary

Fastest Framework by World

Winner determined by most benchmark wins

World🥇 Fastest FrameworkWins
💻 LocalNitro14/21
🐘 PostgresExpress21/21
Fastest World by Framework

Winner determined by most benchmark wins

Framework🥇 Fastest WorldWins
Express🐘 Postgres20/21
Nitro🐘 Postgres18/21
Column Definitions
  • Workflow Time: Runtime reported by workflow (completedAt - createdAt) - primary metric
  • TTFB: Time to First Byte - time from workflow start until first stream byte received (stream benchmarks only)
  • Slurp: Time from first byte to complete stream consumption (stream benchmarks only)
  • Wall Time: Total testbench time (trigger workflow + poll for result)
  • Overhead: Testbench overhead (Wall Time - Workflow Time)
  • Samples: Number of benchmark iterations run
  • vs Fastest: How much slower compared to the fastest configuration for this benchmark

Worlds:

  • 💻 Local: In-memory filesystem world (local development)
  • 🐘 Postgres: PostgreSQL database world (local development)
  • ▲ Vercel: Vercel production/preview deployment
  • 🌐 Turso: Community world (local development)
  • 🌐 MongoDB: Community world (local development)
  • 🌐 Redis: Community world (local development)
  • 🌐 Jazz: Community world (local development)

📋 View full workflow run

@github-actions

github-actionsBot commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

Summary

PassedFailedSkippedTotal
✅ ▲ Vercel Production9890671056
✅ 💻 Local Development10660861152
✅ 📦 Local Production10660861152
✅ 🐘 Local Postgres10660861152
✅ 🪟 Windows960096
✅ 📋 Other270018288
Total455303434896

Details by Category

✅ ▲ Vercel Production
AppPassedFailedSkipped
✅ astro8907
✅ example8907
✅ express8907
✅ fastify8907
✅ hono8907
✅ nextjs-turbopack9402
✅ nextjs-webpack9402
✅ nitro8907
✅ nuxt8907
✅ sveltekit8907
✅ vite8907
✅ 💻 Local Development
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 📦 Local Production
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🐘 Local Postgres
AppPassedFailedSkipped
✅ astro-stable9006
✅ express-stable9006
✅ fastify-stable9006
✅ hono-stable9006
✅ nextjs-turbopack-canary77019
✅ nextjs-turbopack-stable9600
✅ nextjs-webpack-canary77019
✅ nextjs-webpack-stable9600
✅ nitro-stable9006
✅ nuxt-stable9006
✅ sveltekit-stable9006
✅ vite-stable9006
✅ 🪟 Windows
AppPassedFailedSkipped
✅ nextjs-turbopack9600
✅ 📋 Other
AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable9006
✅ e2e-local-postgres-nest-stable9006
✅ e2e-local-prod-nest-stable9006

📋 View full workflow run

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens @workflow/world-local’s filesystem-backed storage against path traversal by validating request-supplied identifiers before they’re used in file paths, and adds regression tests to cover common traversal payloads.

Changes:

  • Introduces assertSafeEntityId (and UnsafeEntityIdError) and applies it across filesystem path composition helpers.
  • Adds ID validation at storage entry points (runs/steps/events/hooks) and streamer operations that use IDs in filenames.
  • Expands unit + integration coverage to ensure traversal payloads are rejected; adds a changeset for the patch release.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
FileDescription
packages/world-local/src/fs.tsAdds centralized ID validation + applies it in taggedPath, readJSONWithFallback, and paginatedFileSystemQuery.
packages/world-local/src/streamer.tsValidates runId and streamName before using them as filename prefixes / keys.
packages/world-local/src/storage/runs-storage.tsValidates runId before reading run JSON from disk.
packages/world-local/src/storage/steps-storage.tsValidates runId/stepId before reading steps and before listing by run prefix.
packages/world-local/src/storage/events-storage.tsValidates runId/eventId and request correlationId before composing composite keys and paths.
packages/world-local/src/storage/hooks-storage.tsValidates hookId before reading hook JSON from disk.
packages/world-local/src/fs.test.tsAdds focused tests for assertSafeEntityId and for validation in taggedPath/readJSONWithFallback.
packages/world-local/src/storage.test.tsAdds regression tests ensuring traversal payloads are rejected across storage APIs.
.changeset/world-local-path-traversal.mdDeclares a patch release for the security fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Solid, well-scoped fix. Validation is applied at every entry point I could trace, tests cover the exact payloads from the Latacora report, and all 328 @workflow/world-local tests pass locally. A few non-blocking suggestions inline — mostly around defense-in-depth and error-type consistency. Copilot already flagged the docstring inaccuracies so I won't duplicate those.

One additional note not worth a line comment: legacy.ts's handleLegacyEvent uses runId in path.join directly (lines 47 and 73 — unchanged by this PR). It's safe today because the function is only called from events.create after assertSafeEntityId('runId', runId) has already run, but the function is exported and nothing in its signature documents that invariant. A one-line assertSafeEntityId('runId', runId) at the top of handleLegacyEvent would make the guarantee local to the file.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts
Comment threadpackages/world-local/src/storage/events-storage.ts

@pranaygppranaygp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two follow-ups not already covered in prior review rounds.

Comment threadpackages/world-local/src/fs.ts Outdated
Comment threadpackages/world-local/src/fs.ts Outdated
- UnsafeEntityIdError now extends WorkflowWorldError for consistency with
other storage-layer errors and the platform error-to-HTTP mapping.
- Add resolveWithinBase(basedir, ...segments) containment helper and
apply it at every taggedPath / readJSONWithFallback / .locks path
construction site in events-storage and legacy, so a forgotten
assertSafeEntityId at a future call site can't silently regress.
- Truncate attacker-controlled values in the error message.
- Drop unused assertSafeEntityIds helper and the unreachable typeof
check under the TS signature.
- Fix docstrings on assertSafeEntityId / taggedPath JSDoc example /
filePrefix validation comment to match what the code actually does.
- handleLegacyEvent now re-asserts runId locally so the invariant is
documented at the call site instead of implicitly inherited from
events.create.
@TooTallNate

Copy link
Copy Markdown
MemberAuthor

Thanks for the review. Pushed b33b922 addressing every comment:

  • UnsafeEntityIdError now extends WorkflowWorldError (with name + static is()) so it flows through the platform's normal error mapping instead of surfacing as a generic 500.
  • Added resolveWithinBase(basedir, ...segments) as the belt-and-suspenders containment check, and routed every path.join-with-user-input through it (taggedPath, readJSONWithFallback, all four .locks/** sites in events-storage.ts, and the two sites in legacy.ts).
  • handleLegacyEvent now re-asserts runId locally so the invariant is documented at the call site (per your top-level note) and both its path.join sites use resolveWithinBase.
  • Error message values are truncated (48 chars + ellipsis) via truncateForError to limit attacker feedback.
  • Removed the unused assertSafeEntityIds helper and the unreachable typeof branch.
  • Fixed the docstring / example / filePrefix comment inaccuracies Copilot flagged.

Tests: 335 passing in @workflow/world-local (328 → 335, +7 for resolveWithinBase and the WorkflowWorldError hierarchy), 591 passing in @workflow/core.

@TooTallNate
TooTallNate enabled auto-merge (squash) April 30, 2026 07:30
Sign up for freeto 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.

5 participants

@TooTallNate@pranaygp@ijjk@VaguelySerious