Skip to content
SSRF Write-up Advanced

How SSRF Leads to RCE in a .NET Application

An endpoint that converted user-supplied URLs to PDFs did not validate the URL, allowing an attacker to read local files via the file:// scheme. By then locating the web.config file and extracting the ViewState encryption keys, the attacker could craft a malicious ViewState payload that executed arbitrary commands on the server.

0xun7h1nk4ble Follow

Published on medium.com

In the world of web application security, a Server-Side Request Forgery (SSRF) vulnerability can sometimes open a Pandora’s box, leading to Remote Code Execution (RCE) with the right set of conditions. This is the story of how I explored an SSRF vulnerability and escalated it to RCE within a .NET web application.

0xUN7H1NK4BLE, 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 application failed to validate or restrict user-supplied URLs, allowing the file:// scheme to be used, and stored ViewState keys in a web.config file that was accessible via path brute-forcing.

Impact

The attacker could read local files and then execute arbitrary commands on the server, leading to full server takeover.

What the attacker needed

Access to the ConvertToPDF endpoint; ability to supply a URL; web.config file accessible via path brute-forcing

The fix

The application should validate and whitelist URLs to prevent SSRF, and protect ViewState keys by storing them securely and avoiding insecure deserialization.

How it was found

  1. Provide a URL to the ConvertToPDF.aspx endpoint and observe that it fetches and converts the content to PDF.
  2. Replace the URL with a file:// URL pointing to a local file, such as the hosts file, and observe that the file contents appear in the generated PDF.
  3. Brute-force paths to locate the web.config file and extract the ViewState validation and decryption keys.
  4. Use ysoserial.net with the extracted keys to generate a malicious ViewState payload that executes a PowerShell command.
  5. Inject the generated ViewState into the __VIEWSTATE parameter of a vulnerable .aspx page to trigger command execution.

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 let users give a web address to fetch and turn into a PDF, but it did not check what address was given. An attacker could give a special address that points to a file on the server itself, like a password file, and read it. Then, by finding the secret keys that protect a hidden form field, the attacker could make the server run their own commands.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by 0xun7h1nk4ble

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.