Skip to content

Harden serve-client-library Vite plugin: path traversal fix, proper content types, and build error output#3303

Closed
Copilot wants to merge 1 commit intodevex_improvement_using_dynamic_clientfrom
copilot/sub-pr-3302
Closed

Harden serve-client-library Vite plugin: path traversal fix, proper content types, and build error output#3303
Copilot wants to merge 1 commit intodevex_improvement_using_dynamic_clientfrom
copilot/sub-pr-3302

Conversation

Copy link
Contributor

Copilot AI commented Feb 24, 2026

Addresses security and correctness issues in the serve-client-library Vite dev plugin introduced for serving @wp-playground/client at /client/.

Changes

  • Path traversal prevention: Parse req.url via new URL() to strip query strings before building the filesystem path, then use path.relative() + isAbsolute() to assert the resolved path stays within clientDistDir — returns 403 otherwise.
  • Content-type by extension: Replaced the hard-coded application/javascript with an extension map covering .js, .cjs, .json, and .map; falls back to application/octet-stream.
  • Static child_process import: Replaced the inline require('child_process') call with a top-level import { exec } from 'node:child_process', improving type safety and ESM compatibility.
  • Build error visibility: The exec callback now captures stderr and forwards it to the Vite logger so build failures surface actionable output instead of a generic message.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Serve client on 127.0.0.1:5400/client/index.js for dev Harden serve-client-library Vite plugin: path traversal fix, proper content types, and build error output Feb 24, 2026
@ashfame ashfame closed this Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants