Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm run dev serves entire project directory #919

Closed
thricedotted opened this issue Apr 7, 2021 · 6 comments
Closed

npm run dev serves entire project directory #919

thricedotted opened this issue Apr 7, 2021 · 6 comments
Labels

Comments

@thricedotted
Copy link

Describe the bug
When I run npm run dev, the entire project directory is included and served as static assets. For instance, I can go to http://localhost:3000/README.md and get a prompt to download this file. (The regular static assets are routed and served correctly -- this is something extra on top of that.)

To Reproduce

  • Initialize a project with npm init svelte@next
  • Run npm run dev
  • Attempt to access any file relative to the project root through the server, e.g. http://localhost:3000/README.md

Expected behavior
The project root is not served as static assets.

Information about your SvelteKit Installation:

Diagnostics
  • The output of npx envinfo --system --npmPackages svelte,@sveltejs/kit,vite --binaries --browsers
    System:
    OS: Linux 4.19 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
    Memory: 4.17 GB / 6.12 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
    Binaries:
    Node: 14.7.0 - ~/.nvm/versions/node/v14.7.0/bin/node
    npm: 7.6.3 - ~/.nvm/versions/node/v14.7.0/bin/npm
    npmPackages:
    @sveltejs/kit: next => 1.0.0-next.71
    svelte: ^3.29.0 => 3.37.0
    vite: ^2.1.0 => 2.1.5

  • Your adapter (e.g. Node, static, Vercel, Begin, etc...)
    Node

Severity
Fairly severe -- it makes it impossible to write routes that overlap with the project directory structure (e.g., a /data/[filename].json route that corresponds to a data/ directory of JSON files in the project root that I add additional information to before serving). I discovered it because I was trying to set up a route with parameters that corresponded to a folder structure in my project directory, and spent a while thinking it had to be stale service workers or cache issues before realizing that the files from the project folder itself, rather than just static/, were being served as static assets.

@mohe2015
Copy link
Contributor

mohe2015 commented Apr 7, 2021

This could also be a security issue

@benmccann
Copy link
Member

I believe this is caused by vitejs/vite#2820 and will need to be fixed there

@mohe2015
Copy link
Contributor

mohe2015 commented Apr 8, 2021

What about leaving this open as I think you would also need to change some configuration here then? And also this should probably be fixed before a 1.0 release so nobody forgets about it?

@benmccann
Copy link
Member

Nothing would be changed here. User projects would need to be upgraded

@AlbertMarashi
Copy link

Getting this issue as well. This seems like a severe vunerability @benmccann @Rich-Harris

@benmccann
Copy link
Member

@AlbertMarashi are you on the latest? This should not be happening unless you're on a very old version:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants