Skip to content
Path traversal Write-up Beginner

The Backslash Bug: How a Tiny Path Glitch in Vite Could Leak You

A path normalisation flaw in the Vite development server on Windows allowed a trailing backslash to bypass the file deny list, so sensitive files such as .env could be served. An attacker on the same network could read those files if the dev server was exposed with --host.

Mohammad Abir Abbas Follow

Published on medium.com

A subtle bug in the Vite development server allowed attackers on the same network to bypass file access restrictions by appending a backslash (\) to certain URLs.

Mohammad Abir Abbas, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the deny list matched only forward slashes, while Windows treats backslashes as equivalent path separators, so the check and the file read disagreed.

Impact

An attacker on the same network could read sensitive files such as .env, but only if the Vite dev server was running on Windows and exposed with --host; local-only servers were not affected.

What the attacker needed

Vite dev server on Windows; Server exposed with --host; Attacker on the same network

The fix

Upgrade Vite to a patched release and avoid exposing the dev server publicly unless necessary.

How it was found

  1. Create a new Vite project and add a .env file containing a secret.
  2. Install dependencies and start the dev server.
  3. From another machine on the same network, request the .env path with a trailing backslash.
  4. Observe the secret value in the response.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Vite is a tool developers use to preview websites while building them. It has a blocklist to stop certain private files, like .env (which holds passwords and keys), from being served. On Windows, adding a backslash to the end of a web address made the blocklist miss the file, so the server handed it over to anyone who asked.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.