Skip to content

fix(server): allow : in file paths on non-Windows platforms - #23773

Open
comp615 wants to merge 1 commit into
vitejs:mainfrom
comp615:fix/colon-paths-posix
Open

comp615 wants to merge 1 commit into
vitejs:mainfrom
comp615:fix/colon-paths-posix

Conversation

@comp615

@comp615 comp615 commented Oct 14, 2026

Copy link
Copy Markdown

fixes #23620

Since the previous CVE fix (#22572), Vite refuses to serve any path containing a :. That makes sense on Windows, where : can't be in a file name, so it always means a stream. On macOS and Linux though, : is a normal file name character.

At Square, we name route files after their route params, like items/library/:id.tsx. Currently, the dev server returns 403 for them and Vitest failed with "Cannot find module". We've been patching Vite locally to skip the check outside Windows. But patches are annoying to carry forward, so I'd rather fix it here.

What this changes:

  • On Windows, any : after the drive letter is still rejected, same as today.
  • On other platforms, : is allowed. The path is also checked against server.fs.deny so it should keep the CVE fix (I think). Just with the :... part removed from each segment. So .env::$DATA or .git::$INDEX_ALLOCATION/config is still denied, the same way .env or .git/config would be.

Someone had previously done #23645, which was closed. The difference is that #23645 only strips the stream suffix from the last segment. That misses streams on directories, like .git::$INDEX_ALLOCATION/config.

One AI identified trade-off: if an NTFS volume is mounted on macOS or Linux, streams of files that aren't denied become readable again. That's how it worked before #22572.

But otherwise, I think the fix is better scoped after this (let's all ignore that obviously we wouldn't be naming with colons if we used windows dev machines which makes our repo unportable.)

Used AI to identify, verify and help author the code

@comp615 comp615 closed this Oct 15, 2026
@comp615 comp615 reopened this Oct 15, 2026
@comp615
comp615 force-pushed the fix/colon-paths-posix branch from 71a4a04 to 30a6d0e Compare November 23, 2026 15:22

This branch has not been deployed

No deployments
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.

Dev server returns 403 for files with colon (:) in their path on Linux and macOS

1 participant