Skip to content

ssr-manifest.json and ssrContext disclose folder structure present in the source code #3303

Closed
@ferdinando-ferreira

Description

@ferdinando-ferreira

Describe the bug

In a ssr build, ssr-manifest.json and ssrContext (in the dist/server/entry-server.js file), will contain the complete filenames (including the folder structure) present in the source code. This causes two problems:

  • It may "leak" personal or confidential information about the source code being built
    • It could be the internal and private structure of the source code
    • it could be the name of the developers building their applications (if it is present, for instance, in the home folder where the application source code resides)
  • More importantly, it makes a build "non deterministic"
    • Two programmers in the same organization, using the exact same codebase, will generate distinct builds differing only on these specific files, based on the layout of their file systems and where they stored the source code

Submitted #3315 as a comprehensive fix

Reproduction

git clone https://github.com/vitejs/vite.git vite
cd vite
yarn
yarn build
cd packages/playground/ssr-vue
yarn build

Two files will contain complete paths from the source code:

  • packages/playground/ssr-vue/dist/client/ssr-manifest.json
  • packages/playground/ssr-vue/dist/server/entry-server.js

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 3.22 GB / 7.91 GB
  Binaries:
    Node: 15.11.0
    Yarn: 1.22.10
    npm: 7.6.0
  Browsers:
    Chrome: 90.0.4430.93
    Edge: Spartan (44.19041.906.0), Chromium (90.0.818.51)
    Internet Explorer: 11.0.19041.1

Used package manager:
yarn

Logs

N/A


Other comments

Here is a "naive" solution for the root cause
EDIT: Sent a #3315 as a more robust implementation that solves both the "leak" and the determinism issues.

Before submitting the issue, please make sure you do the following

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions