Skip to content
SSRF Write-up Intermediate

Bypassing SSRF Protections

A proxy endpoint that made outbound HTTP requests only checked that the supplied URL contained the site's hostname, so an attacker could bypass the filter using a backslash and reach the AWS metadata service. This could expose internal cloud credentials and data.

Tobydavenn Follow

Published on medium.com

It has been a while since I last posted. I wanted to share a neat SSRF bypass I found while hunting on a private program.

Tobydavenn, 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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 3 min read.

Context

This is a short write-up about a server side request forgery (SSRF) bypass found while hunting on a private bug bounty program. SSRF lets an attacker abuse HTTP requests made by the server to request information about the server itself or its internal network. The feature involved was a proxy.php endpoint that made an outbound HTTP request to a URL supplied by the user. The report does not name the program, the hostname of the website, or the exact request format beyond the url= parameter.

Setup

The work was done during recon on a private program. The researcher had gathered a large list of subdomains, mainly from Censys, then brute forced and searched the Wayback Machine for URLs across all hosts. With SSRF as the focus, the directory and endpoint output was grepped for proxy.php, which produced a hit. The main tool referenced is Burp Collaborator, used to detect out-of-band lookups. No versions or account details are given.

Finding it

Parameters worth watching for are those that look like they make a web request to a server, such as url=, next=, host=, image= and img=. The proxy.php endpoint took a URL and fetched it. Sending a Burp Collaborator link produced no lookup, and the usual basics, [redacted] and IP notations of internal hosts, were each blocked unless the request contained the website's hostname. That hostname check was the defence to get around.

Exploitation

Step 1: confirm the filter and get an out-of-band hit

Sending a request with the Collaborator link together with browser credentials formatting produced a hit:

Text
url=https://hostnameofwebsite.com@myburpcollablink

Here the browser treats hostnameofwebsite.com as the username and myburpcollablink as the host, so the request goes to the Collaborator. The hostname check passed because the website's hostname appeared in the value. This produced a hit, but it was no good for exploitation because the request still went to the Collaborator.

Step 2: reverse the order with a backslash

A video on SSRF explained that using a \ stops parsing on the backend after the first host. The front end interprets the request as the website hostname being credentials to the Collaborator, while the backend processes only the front part, the website hostname. The researcher reversed the arrangement:

Text
url=http://169.254.1698.254\@hostnameofwebsite

169.254 is the internal IP address of the AWS metadata service. The front end sees 169.254 as credentials to hostnameofwebsite, which passes the check because the website's hostname must be in the request. The backend ignores that format and processes the value as http://[redacted], which then cuts off and passes just that request. The report notes the endpoint was closed as resolved.

Root cause

The filter appears to require that the website's hostname is present in the supplied URL, rather than validating the actual host that will be contacted. The front end and the backend disagree about where the host ends: the front end treats the part before @ as credentials, while the backend stops parsing at the backslash and contacts the address before it. An attacker can place the allowed hostname after the @ and the internal address before it. The report does not describe the backend implementation, so the exact parsing behaviour is likely rather than confirmed.

Impact

An attacker who can reach the proxy can make the server issue requests to internal addresses such as the AWS metadata service, bypassing the hostname filter. What data could be read, and under which conditions, is not stated in the report. The endpoint was closed as resolved.

Fix

A robust fix would parse the URL, resolve the host, and validate the resolved address against an allow list or a block list of internal ranges, rejecting credentials and backslash forms before the request is made.

Variants to test

  1. Credentials formatting: url=https://allowed.example@collaborator and check for a Collaborator hit, which shows the filter is a substring check.
  2. Backslash truncation: url=http://[redacted]\@allowed.example and look for a metadata response or an internal lookup.
  3. Decimal, octal and hex IP notations of internal addresses, each placed before the @, and check whether the filter still passes.
  4. Redirect chains: point the allowed host at a redirect to an internal address and see whether the proxy follows it.
  5. DNS rebinding: a hostname that resolves to an allowed address first and an internal address later, and check whether the second request reaches the internal service.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

A security researcher was testing a private bug bounty program, which is a scheme where companies invite people to look for security weaknesses in their systems and report them. While doing that, the researcher found a way to trick a website's server into making requests to places it should not be able to reach. The weakness is called server side request forgery, or SSRF for short.

To understand SSRF, imagine a hotel receptionist who will fetch anything you ask for. Normally you ask for a newspaper from the lobby shop, and the receptionist brings it. But if the receptionist does not check carefully, you could ask them to fetch a document from the manager's private office, or from a locked room in the basement. The receptionist has keys you do not have, so they can go places you cannot. In a website, the server is the receptionist: it sits inside a network with access to internal machines, and if you can make it fetch a URL of your choosing, you can use its position to peek at things that are not meant to be public.

The feature involved was a file called proxy.php. A proxy is a middleman: you give it a web address, and it goes and fetches that address for you. The researcher found that this proxy would fetch any URL supplied in a parameter called url=. The report does not name the program, the website's hostname, or the exact request format beyond that url= parameter.

Setup

The work started with reconnaissance, usually shortened to recon. Recon is the information-gathering phase: before attacking anything, you map out what exists. The researcher gathered a large list of subdomains. A subdomain is a smaller section of a main website, like shop.example.com next to example.com. Most of these came from Censys, a search engine that indexes devices and services connected to the internet.

With that list in hand, the researcher brute forced and searched the Wayback Machine for URLs across all hosts. Brute forcing here means trying a long list of common file and folder names against each host to see which ones exist. The Wayback Machine is an archive that keeps old copies of web pages, so it can reveal URLs that no longer appear on the live site.

Because SSRF was the focus at the time, the researcher took the directory and endpoint output and grepped for proxy.php. Grep is a command-line tool that searches text for a pattern; think of it as Ctrl+F for a terminal. That search produced a hit: a proxy.php file existed somewhere in the collected results.

The main tool referenced is Burp Collaborator. Burp is a toolkit for testing web applications, and Collaborator gives you a unique web address you control. You put that address into a target, and if the target's server ever tries to visit it, Collaborator records the visit. That is called an out-of-band lookup: a signal that comes back through a separate channel rather than in the response you are looking at. It is how you prove a server really made a request on your behalf. No versions or account details are given in the report.

Finding it

Some URL parameters are worth watching for because they look like they make a web request to a server. Examples are url=, next=, host=, image= and img=. If a website takes one of these and fetches whatever address you put there, that is a candidate for SSRF.

The proxy.php endpoint took a URL and fetched it. The researcher first sent a Burp Collaborator link as the value, expecting the server to visit it. No lookup arrived. Then the usual basics were tried: [redacted], which is the standard address a machine uses to refer to itself, and various IP notations of internal hosts. Each request was blocked unless the request contained the website's hostname. In other words, the proxy had a filter: it only allowed URLs that mentioned the site's own name somewhere in the text. That hostname check was the defence to get around.

Exploitation

Step 1: confirm the filter and get an out-of-band hit

The researcher sent a request with the Collaborator link together with browser credentials formatting. Credentials formatting is the way a URL can carry a username and password before the host, separated by an @ sign, like https://user:[redacted]. The request was:

Text
url=https://hostnameofwebsite.com@myburpcollablink

Line by line: url= is the parameter the proxy reads. https:// is the scheme, telling the proxy to use encrypted HTTP. hostnameofwebsite.com sits before the @, so in URL syntax it is treated as the username. myburpcollablink sits after the @, so it is the actual host that will be contacted. The browser, or whatever parses the URL, treats hostnameofwebsite.com as the username and myburpcollablink as the host, so the request goes to the Collaborator. The hostname check passed because the website's hostname appeared in the value as plain text. This showed the hostname check could be passed by including the website's hostname in the value. But it was no good for exploitation, because the request still went to the Collaborator rather than to anything internal.

Step 2: reverse the order with a backslash

A video on SSRF explained that using a \ stops parsing on the backend after the first host. A backslash is the \ character, the one above the Enter key on many keyboards. The idea is that different pieces of software read the same URL differently. The front end, the part that checks the input, interprets the request as the website hostname being credentials to the Collaborator. The backend, the part that actually makes the request, processes only the front part, the website hostname. The researcher reversed the arrangement:

Text
url=http://169.254.1698.254\@hostnameofwebsite

Line by line: url= is again the parameter. http:// is the scheme, this time unencrypted HTTP. 169.254.1698.254 is the address placed before the @, so the front end sees it as credentials. The \ is the backslash that, according to the video, makes the backend stop parsing. @hostnameofwebsite is the part after the @, so the front end sees hostnameofwebsite as the host. 169.254 is described in the report as the internal IP address of the AWS metadata service. AWS is Amazon Web Services, a cloud platform, and its metadata service is an internal address that cloud servers can query for information about themselves, such as configuration details. It is not meant to be reachable from the outside.

The front end sees 169.254 as credentials to hostnameofwebsite, which passes the check because the website's hostname must be in the request. The backend ignores that format and processes the value as http://[redacted], which then cuts off and passes just that request. The report notes the endpoint was closed as resolved.

Root cause

The filter appears to require that the website's hostname is present in the supplied URL, rather than validating the actual host that will be contacted. The front end and the backend disagree about where the host ends: the front end treats the part before @ as credentials, while the backend stops parsing at the backslash and contacts the address before it. An attacker can place the allowed hostname after the @ and the internal address before it. The report does not describe the backend implementation, so the exact parsing behaviour is likely rather than confirmed.

Impact

An attacker who can reach the proxy can make the server issue requests to internal addresses such as the AWS metadata service, bypassing the hostname filter. What data could be read, and under which conditions, is not stated in the report. The endpoint was closed as resolved.

Fix

A robust fix would parse the URL, resolve the host, and validate the resolved address against an allow list or a block list of internal ranges, rejecting credentials and backslash forms before the request is made. An allow list is a list of things that are permitted; a block list is a list of things that are forbidden. Resolving the host means turning a name like example.com into the numeric address the network actually uses, so the check runs on the real destination rather than on the text the user typed.

Variants to test

  1. Credentials formatting: url=https://allowed.example@collaborator and check for a Collaborator hit, which shows the filter is a substring check.
  2. Backslash truncation: url=http://[redacted]\@allowed.example and look for a metadata response or an internal lookup.
  3. Decimal, octal and hex IP notations of internal addresses, each placed before the @, and check whether the filter still passes. These are different ways of writing the same number, so a filter that only recognises the familiar dotted form can be fooled.
  4. Redirect chains: point the allowed host at a redirect to an internal address and see whether the proxy follows it. A redirect is a server telling the client to go somewhere else instead.
  5. DNS rebinding: a hostname that resolves to an allowed address first and an internal address later, and check whether the second request reaches the internal service. DNS is the system that turns names into addresses; rebinding means changing the answer between checks.

Glossary

  • SSRF (server side request forgery): a weakness where an attacker makes a server send requests to addresses the attacker cannot reach directly.
  • Bug bounty program: a scheme where organisations pay or credit people for reporting security weaknesses.
  • Private program: a bug bounty program that only invited researchers can see and take part in.
  • Recon (reconnaissance): the information-gathering phase before testing, mapping out hosts, files and endpoints.
  • Subdomain: a smaller section of a main website, such as shop.example.com under example.com.
  • Censys: a search engine that indexes devices and services connected to the internet.
  • Brute forcing: trying a long list of common names or values to discover what exists.
  • Wayback Machine: an archive that keeps old copies of web pages, useful for finding URLs that no longer appear live.
  • Grep: a command-line tool that searches text for a pattern.
  • Endpoint: a specific address or file on a server that handles a request, such as proxy.php.
  • Proxy: a middleman that fetches a web address on your behalf.
  • Parameter: a named value in a URL or request, such as url=.
  • Burp Collaborator: a tool that gives you a unique address and records any server that visits it.
  • Out-of-band lookup: a signal that comes back through a separate channel, proving a server made a request.
  • [redacted]: the standard address a machine uses to refer to itself.
  • IP address: the numeric address of a machine on a network.
  • Credentials formatting: putting a username and password before the host in a URL, separated by @.
  • Front end: the part of a system that receives and checks input.
  • Backend: the part of a system that actually processes the request and makes the connection.
  • Backslash: the \ character, used here to make different parsers disagree about where a URL ends.
  • AWS: Amazon Web Services, a cloud platform.
  • Metadata service: an internal address on cloud servers that returns information about the server itself.
  • Substring check: a filter that only looks for a piece of text anywhere inside a value.
  • Allow list: a list of things that are permitted.
  • Block list: a list of things that are forbidden.
  • Resolve: turning a hostname into the numeric address the network uses.
  • Redirect: a server telling the client to go to a different address instead.
  • DNS: the system that turns names into IP addresses.
  • DNS rebinding: changing the address a name resolves to between checks, so a later request reaches a different target.

More by Tobydavenn

View all

11 more disclosed reports, 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.