Skip to content
Path traversal Write-up Beginner

I Hired A Penetration Tester To Attack My Own Side Project It Took Him Under An Hour

A debug endpoint that read files by name without authentication or path sanitisation allowed an attacker to read arbitrary files as the application user. The attacker used this to read a .env file containing production database credentials and live API keys.

Sarath S Follow

Published on systemweakness.com

Here’s the part I want to be honest about up front, because it’s the whole point: this box was already hardened. Not “I moved SSH off port 22 once” hardened.

Sarath S, on systemweakness.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 debug endpoint lacked authentication and failed to sanitise the user-supplied filename, allowing path traversal.

Impact

The attacker obtained production database credentials and live third-party API keys, and could potentially have used a forwarded SSH agent to reach other systems if the timing had been right.

What the attacker needed

Network access to the server; no authentication required

The fix

The application should be sandboxed with systemd, secrets moved to a root-only file loaded via EnvironmentFile, egress default-denied, agent forwarding disabled, and production error handling forced.

How it was found

  1. Scan the target with nmap to find open ports.
  2. Fuzz routes and notice a JSON parse error instead of a 404, indicating a file-reading endpoint.
  3. Use path traversal to read arbitrary files as the application user.
  4. Read the systemd unit to find the application's working directory.
  5. Read the .env file in that directory to obtain production secrets.

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.

The application had a leftover debugging feature that let anyone ask it to read a file by name. Because the name wasn't checked, an attacker could use a trick called path traversal to make it read files outside the intended folder, including a file holding secret passwords and keys.

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.