Skip to content
Path traversal Write-up Beginner

Finding a Path Traversal via Base64

An API endpoint accepted a base64-encoded file path parameter and used it directly to read files, allowing path traversal. An attacker could read the production .env file containing credentials and configuration data.

medium.com

Published on medium.com

It happened a few weeks ago, after finishing my main sprint tasks, I had some spare time. Instead of taking a break (gabut), I decided to explore bug hunting method, refining recon techniques, and challenging my hunting instinct further.

Tino, 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

The application decoded the base64 parameter and used it directly as a file path without validating or restricting it to the intended directory.

Impact

An attacker could read the production .env file, exposing sensitive credentials and configuration data such as SMTP, database, and API keys; the WAF blocked one payload but not the other.

What the attacker needed

Access to the API endpoint; ability to send base64-encoded parameter

The fix

The vendor rotated the environment keys and patched the issue, though the text does not describe the code fix.

How it was found

  1. Find an API endpoint with an encoded parameter.
  2. Decode the parameter and see it is base64 for an image file path.
  3. Encode a traversal path to /etc/passwd in base64 and send it; the WAF blocks it.
  4. Encode a traversal path to .env in base64 and send it; the WAF does not block it.
  5. Receive the production .env file contents 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.

A web app sometimes takes a file name or path from the user to show a file. If it does not check that path carefully, someone can use '..' to climb out of the intended folder and read other files on the server. Here the path was hidden inside base64 encoding, which is just a way to represent text, not a security control.

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.