Skip to content
Path traversal Write-up Intermediate

Hacking a .NET API in the real world

A report generation endpoint in a .NET API was vulnerable to local file inclusion because the developers' directory traversal protection did not account for encoded UNIX paths. An attacker could download arbitrary files, including the API's .NET assembly, decompile it, and find further vulnerabilities such as command injection or SQL injection.

Dana Epp Follow

Published on danaepp.com

I have an interesting story I want to share with you about the fragility of modern web applications. I’ve been struggling with how to share this in a way to protect the innocent while still telling the tale that can educate and enlighten you about red teaming in the real world.

Dana Epp (@DanaEpp), on danaepp.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 developers implemented a basic directory traversal check that did not normalise or decode encoded UNIX path sequences before using the user-supplied value to read a file.

Impact

An attacker could read arbitrary files from the server, including application configuration and the compiled API code, which could then be decompiled to discover further vulnerabilities such as command injection or SQL injection.

What the attacker needed

Access to the report endpoint; ability to send crafted requests

How it was found

  1. Send a request to the report download endpoint with a valid GUID and observe a PDF stream response.
  2. Replace the GUID with an invalid value and observe a 404 response.
  3. Fuzz the GUID parameter with a wordlist of interesting inputs and observe successful responses returning file contents.
  4. Identify that one response contains the contents of the system password file, confirming local file inclusion.
  5. Use the LFI to read system release and container marker files to confirm the operating system and container environment.
  6. Trigger an error that leaks a stack trace containing the assembly name, then use the LFI to download the main API assembly from the application folder.

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 API had a feature that let users download a report by giving an ID in the web address. The code that checked the ID was meant to stop people from reading other files on the server, but it missed a way of writing file paths that the operating system still understood. So an attacker could ask for files like the system's password file or the application's own code, then study that code to find more ways in.

What is Path traversal?

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

More by Dana Epp

View all

2 more disclosed reports, best first.

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.