Skip to content
SSRF Write-up Intermediate

On SSRF (Server Side Request Forgery) or Simple Stuff Rodolfo Found — Part I

PHP code that validates a user-supplied URL with filter_var and the query-required flag can still be tricked into reading local files, because a crafted file-scheme URL with a question mark passes validation. An attacker could then read files such as the password file on the server.

rodoassis.medium.com

Published on rodoassis.medium.com

I think the most we have to test against an application the better. But as you can see by yourself (correct me if I’m wrong please) the following set of scenarios and payloads are not addressed in most of the lists you can find out there for SSRF (Server Side Request Forgery).

Rodolfo Assis (Brute), on rodoassis.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 URL validation only checks the general shape of the string and the presence of a query string, not the scheme or the real target, so a file-scheme URL with a question mark satisfies it.

Impact

An attacker could read local files on the server through the vulnerable URL parameter, limited to the file-read outcome the author tested.

What the attacker needed

Attacker controls the url parameter; server-side PHP fetches the URL

How it was found

  1. Send a normal file-scheme URL to the vulnerable parameter and observe it is rejected by validation.
  2. Add a question mark with a trailing character so the string looks like it has a query, and observe the request is accepted.
  3. For the file_get_contents case, place the question mark as a directory name and use a parent-directory segment to return to the target folder.
  4. For the exec case, insert empty variable substitutions into the path to obfuscate it while the shell discards them.

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 takes a web address from the user and fetches it. It checks the address looks valid, but the check is weak, so a specially shaped address that points at a file on the server itself gets through. The server then reads that local file and shows it back to the user.

What is SSRF?

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

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.