Skip to content
SSRF Write-up Intermediate

ESEA Server-Side Request Forgery and Querying AWS Meta Data

The media_preview.php endpoint on play.esea.net accepted a user-supplied URL and fetched its contents server-side, allowing an attacker to make requests to internal resources. By pointing it at the AWS instance metadata service, an attacker could retrieve sensitive instance information, potentially including IAM role credentials.

Brett Buerhaus Follow

Published on buer.haus

Bounty$1,000 View original

For anyone familiar with the Counter-Strike competitive scene, you know about ESEA. They just recently launched a bounty program that puts their website, game client, and game servers in scope for security research.

Brett Buerhaus (@bbuerhaus), on buer.haus

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. 7 min read.

(ESEA)

Context

ESEA is a competitive Counter-Strike platform, and the target here is its website at play.esea.net. Shortly before this research, ESEA launched a bounty programme that put their website, game client and game servers in scope for security research.

The feature that mattered is an endpoint called media_preview.php. Its apparent purpose is to load an external image and render it back to the client. That behaviour means the server takes a user-supplied URL, fetches it, and returns the response body to the browser, which is exactly the shape of a server-side request forgery primitive.

Setup

No accounts, roles or special tooling are described. The work was done over a single night of looking at the public website, using Google to enumerate endpoints and a server the researcher controls at ziot.org to observe incoming requests. ESEA's stack is inferred to be PHP from the endpoint's file extension and from the wrapper attempts later in the report.

Finding it

The starting point was initial recon by Google dorking across the play.esea.net site. The example given is a search for PHP files:

Text
site:https://play.esea.net/ ext:php

One endpoint stood out:

Text
https://play.esea.net/global/media_preview.php?url=

The url parameter suggests the server loads the response content for a user-supplied address and renders it back. If that is what happens, the server can be made to issue requests on the attacker's behalf.

Exploitation

Step 1: a plain external URL

The first attempt pointed the parameter at the researcher's own server and checked the access logs to see whether the request arrived:

Text
https://play.esea.net/global/media_preview.php?url=http://ziot.org/

Nothing arrived. Looking again at the Google results, every hit was an image. The file is named media_preview, so the reasonable assumption is that it was built to render images only, and that some form of URL or file validation was in place to prevent file inclusion or the rendering of dangerous URLs.

Step 2: confirming that remote fetches work

Two image URLs were tried, first a well-known remote image (the Google logo):

Text
https://play.esea.net/global/media_preview.php?url=http://www.google.com/images/logo.png

That worked. Then the same test against the researcher's own server:

Text
https://play.esea.net/global/media_preview.php?url=http://ziot.org/1.png

That worked too, so the server will render files from a host the attacker controls. The working hypothesis was that the endpoint checks the file extension, and possibly validates the file type server-side as well.

Step 3: bypassing the extension check

The first thing to test is the extension check itself. Typical tricks from past cases are a null byte (%00), extra forward slashes, and question marks. What the endpoint uses to parse the extension is unknown: it could be something reasonably secure such as Python's urlparse (unlikely, since the site is PHP), or it could simply look at the text after the last . in the URL.

The payload used a question mark so that the .png becomes a request variable rather than part of the path:

Text
https://play.esea.net/global/media_preview.php?url=http://ziot.org/?.png

(The endpoint returning the full contents of the supplied URL)

The endpoint returned the entirety of the contents of the supplied URL. It is not restricted to image files, and the extension check can be bypassed by placing the extension after a question mark, where it becomes a request variable.

Step 4: cross-site scripting through the preview

At this point several questions follow naturally: how limited is the SSRF, can other protocols such as file:// or php:// be used to read local files, is it restricted to HTTP, and are domains blacklisted?

The first obvious demonstration is XSS. The endpoint can be forced to load an HTML file containing a JavaScript payload. Because the content is delivered by play.esea.net and is not placed in an iframe or similar isolation, the script executes in the context of ESEA's domain.

(JavaScript executing in the context of the ESEA domain)

Step 5: other protocols

A few protocol and wrapper attempts were made, none of which succeeded:

  • https://play.esea.net/global/media_preview.php?url=file://\etc\passwd?.png
  • https://play.esea.net/global/media_preview.php?url=php://filter/resource=http://www.mrzioto.com?.png
  • A couple of other PHP-specific wrappers, documented at http://php.net/manual/en/wrappers.php

The working assumption after these failures was that the endpoint is restricted to HTTP.

Step 6: querying the AWS instance metadata service

While discussing ideas for SSRF and file inclusion tricks with NahamSec, the researcher was shown a technique for AWS instances: any AWS instance can query a link-local address to pull metadata about the instance and about the AWS account that owns it. ESEA hosts their website on AWS, so the technique applies.

The reference is the EC2 instance metadata documentation at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html. Querying http://[redacted]/ returns information about the instance such as the private address, hostname, public keys and subnet IDs. The most sensitive data available is the IAM role secret keys, which give API access to the AWS account.

The report gives a generic example of the metadata service:

Text
URL: http://[redacted]/latest/meta-data/hostname
Response: ec2-203-0-113-25.compute-1.amazonaws.com

No example of this against ESEA is shown, because the responses would contain sensitive data. The researcher judged this sufficient evidence of a high-impact issue and stopped there.

Root cause

The endpoint fetches a user-supplied URL server-side and returns the response body to the client. The report does not describe any restriction on the destination address. The only validation appears to be an extension check on the URL string, which is trivially defeated by moving the extension behind a question mark so it is parsed as a query string rather than a path. Because the check operates on the URL text rather than on the fetched resource, the researcher judged the server could be pointed at the link-local metadata address, and stopped there. The report does not describe the validation code itself, so the exact implementation is inferred from behaviour.

Impact

Through the endpoint an attacker can make the ESEA server issue HTTP requests to arbitrary destinations. Two consequences are demonstrated or described:

  1. JavaScript executes in the context of play.esea.net, because the fetched HTML is served from the ESEA domain without isolation.
  2. The AWS instance metadata service at http://[redacted]/ is reachable, exposing instance details such as private address, hostname, public keys and subnet IDs, and potentially IAM role secret keys that grant API access to the AWS account.

The metadata exposure is described as the most shocking data available, and the researcher stopped once this was enough evidence of a high-impact issue rather than extracting ESEA's actual metadata.

Fix

The timeline records the endpoint as fixed on 14 April 2016, with the researcher noting, based on the email response, that it may have been fixed earlier. What the change consisted of is not stated.

Variants to test

  • Extension checks on URL strings. Append a query string so the required extension sits after a ?, as in ...?url=http://attacker/?.png. A positive result is the full body of a non-image resource being returned.
  • Destination allowlisting. Point the parameter at a host you control and watch your access logs. A request arriving from the target's infrastructure confirms server-side fetching; no request suggests filtering or a different fetch path.
  • Protocol restrictions. Try file://, php://filter and other wrappers with the same extension trick. A positive result is local file contents or filtered resource output appearing in the response.
  • Cloud metadata reachability. On any target hosted in a cloud environment, request the metadata address through the SSRF. A positive result is instance metadata such as a hostname or credentials being returned in the response body.
  • Response rendering context. Serve an HTML file with a script through the parameter. A positive result is the script executing in the target's origin rather than being downloaded or rendered inert.

Timeline

Event Date
Discovery/Reported April 11, 2016
Triaged/Verified April 12, 2016
Fixed April 14, 2016 (possibly earlier, based on the email response)
Rewarded April 18, 2016: $1,000 USD, 1,000 ESEA points, profile badge

(Reward notification)

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. 17 min read.

What happened, in plain words

ESEA is a website and service for people who play Counter-Strike competitively, a popular first-person shooter game. The researcher looked at ESEA's public website at play.esea.net and found a feature that loads images from other websites and shows them to you. The problem was that the ESEA server would fetch whatever address you gave it, including addresses that only the server itself can reach. That would have let the researcher make ESEA's own server fetch private information about the machine it runs on, hosted at Amazon Web Services (AWS), a large cloud hosting provider. The researcher reported it, ESEA fixed it, and paid a reward of $1,000 USD plus some in-game points and a profile badge.

(ESEA)

Context

ESEA runs a competitive platform for Counter-Strike, and the target here is its website at play.esea.net. Shortly before this research, ESEA launched a bounty programme. A bounty programme is an offer from a company: if you find a security flaw in our systems and report it responsibly, we pay you. ESEA put their website, their game client (the program players install to play) and their game servers in scope, meaning those were the things you were allowed to test.

The feature that mattered is an endpoint called media_preview.php. An endpoint is simply a particular address on a website that does a particular job, like a counter in a shop: you go to that address, you ask for something, and it responds. This endpoint's apparent purpose is to load an external image and render it back to the client. "Render" means display it in your browser. So the flow is: you give the endpoint a web address, the ESEA server goes and fetches that address itself, and then it hands the result back to your browser.

That behaviour is exactly the shape of a server-side request forgery primitive. Server-side request forgery, usually shortened to SSRF, is a vulnerability where an attacker can make a server send requests to places the attacker cannot reach directly. A simple comparison: imagine a hotel concierge who will fetch anything you ask for from anywhere in the building. Normally that is helpful. But if you can ask the concierge to go into the staff room and read out what is written on the noticeboard, you have used the concierge's access to get into a room you were never allowed into. The server is the concierge; the attacker is the guest; the staff room is the internal network.

Setup

No accounts, roles or special tooling are described. The work was done over a single night of looking at the public website, using Google to enumerate endpoints and a server the researcher controls at ziot.org to observe incoming requests. "Enumerate" means making a list of things that exist. A server you control is useful because you can watch its logs, the records of who asked for what and when, to see whether the target server actually came knocking.

ESEA's stack is inferred to be PHP from the endpoint's file extension and from the wrapper attempts later in the report. PHP is a programming language commonly used to build websites; files ending in .php are usually written in it. "Inferred" means worked out from clues rather than stated outright.

Finding it

The starting point was initial recon by Google dorking across the play.esea.net site. Recon, short for reconnaissance, means looking around before attacking, the way a burglar might walk past a house to note the windows. Google dorking means using advanced search operators in Google to find pages that match a pattern. The example given is a search for PHP files:

Text
site:https://play.esea.net/ ext:php

Line by line: site:https://play.esea.net/ tells Google to return only results from that one website. ext:php tells Google to return only pages whose file extension is .php. Together they ask: show me every PHP page Google knows about on ESEA's site. The reason for doing this is that each PHP page is a potential endpoint, and each endpoint is a potential door.

One endpoint stood out:

Text
https://play.esea.net/global/media_preview.php?url=

Line by line: https:// is the secure version of the protocol browsers use to talk to websites. play.esea.net is the site's address. /global/media_preview.php is the path to the specific page. ?url= starts the query string, the part of a URL after the question mark that carries extra information. Here the parameter is named url and its value is empty, waiting to be filled in. A parameter is a named input, like a blank on a form.

The url parameter suggests the server loads the response content for a user-supplied address and renders it back. If that is what happens, the server can be made to issue requests on the attacker's behalf. That is the whole idea of SSRF: the attacker does not need direct access to a destination, because the server does the fetching.

Exploitation

Step 1: a plain external URL

The first attempt pointed the parameter at the researcher's own server and checked the access logs to see whether the request arrived:

Text
https://play.esea.net/global/media_preview.php?url=http://ziot.org/

Line by line: the endpoint is the same as before. The url parameter now holds http://ziot.org/, the researcher's own web server. http:// is the ordinary, unencrypted web protocol. The idea is simple: if ESEA's server fetches this address, the researcher's server will record a visit in its logs. That record is proof that ESEA's server made the request.

Nothing arrived. Looking again at the Google results, every hit was an image. The file is named media_preview, so the reasonable assumption is that it was built to render images only, and that some form of URL or file validation was in place to prevent file inclusion or the rendering of dangerous URLs. Validation means checking input before using it, like a bouncer checking IDs. File inclusion is a related class of bug where a server is tricked into loading a file it should not, often a file from its own disk.

Step 2: confirming that remote fetches work

Two image URLs were tried, first a well-known remote image (the Google logo):

Text
https://play.esea.net/global/media_preview.php?url=http://www.google.com/images/logo.png

Line by line: the same endpoint, but the url parameter now points at a picture of the Google logo on Google's own website. .png is a common image file format. The purpose is to test whether the endpoint will fetch an image from a completely different company's server. If it does, the endpoint really does make outbound requests.

That worked. Then the same test against the researcher's own server:

Text
https://play.esea.net/global/media_preview.php?url=http://ziot.org/1.png

Line by line: this time the address is the researcher's server, and the file is named 1.png, an image.

That worked too, so the server will render files from a host the attacker controls. The working hypothesis was that the endpoint checks the file extension, and possibly validates the file type server-side as well. An extension is the part of a filename after the last dot, such as .png. A hypothesis is an educated guess you then test.

Step 3: bypassing the extension check

The first thing to test is the extension check itself. Typical tricks from past cases are a null byte (%00), extra forward slashes, and question marks. A null byte is a special character that some programs treat as the end of a string, so text after it can be ignored. Extra slashes can confuse parsers about where a path ends. A question mark, as we saw, starts the query string.

What the endpoint uses to parse the extension is unknown: it could be something reasonably secure such as Python's urlparse (unlikely, since the site is PHP), or it could simply look at the text after the last . in the URL. A parser is a piece of code that breaks text into its parts. urlparse is a Python function that does this carefully. If the site is written in PHP, it probably uses a PHP equivalent, and the guess is that the check is crude.

The payload used a question mark so that the .png becomes a request variable rather than part of the path:

Text
https://play.esea.net/global/media_preview.php?url=http://ziot.org/?.png

Line by line: the outer endpoint is unchanged. The url parameter now holds http://ziot.org/?.png. Notice the ? inside the value. To a naive check that looks for .png at the end of the string, this looks like an image. To a proper URL parser, everything after the ? is the query string, so the actual address being fetched is just http://ziot.org/, with a query string of .png. The extension is present for the check but ignored by the fetch.

(The endpoint returning the full contents of the supplied URL)

The endpoint returned the entirety of the contents of the supplied URL. It is not restricted to image files, and the extension check can be bypassed by placing the extension after a question mark, where it becomes a request variable. In other words, the guard was looking at the label on the parcel, not at what was inside.

Step 4: cross-site scripting through the preview

At this point several questions follow naturally: how limited is the SSRF, can other protocols such as file:// or php:// be used to read local files, is it restricted to HTTP, and are domains blacklisted? A protocol is a set of rules for how two computers talk, such as http:// for web pages or file:// for files on a disk. A blacklist is a list of things that are forbidden; a whitelist is a list of things that are allowed.

The first obvious demonstration is XSS. XSS stands for cross-site scripting: a vulnerability where an attacker gets their own JavaScript code to run inside someone else's website in the victim's browser. JavaScript is the programming language that browsers run to make pages interactive. If an attacker's script runs on ESEA's domain, it can do anything a legitimate ESEA script could do, such as read the page or act as the logged-in user.

The endpoint can be forced to load an HTML file containing a JavaScript payload. HTML is the language web pages are written in, and a payload is the part of an attack that does the damage. Because the content is delivered by play.esea.net and is not placed in an iframe or similar isolation, the script executes in the context of ESEA's domain. An iframe is a page inside a page; content in an iframe is kept separate from the surrounding site. Here there is no such separation, so the browser treats the fetched HTML as if ESEA itself had written it.

(JavaScript executing in the context of the ESEA domain)

Step 5: other protocols

A few protocol and wrapper attempts were made, none of which succeeded. A wrapper is a PHP feature that lets one protocol be used through another, for example reading a file through a filter.

  • https://play.esea.net/global/media_preview.php?url=file://\etc\passwd?.png
  • https://play.esea.net/global/media_preview.php?url=php://filter/resource=http://www.mrzioto.com?.png
  • A couple of other PHP-specific wrappers, documented at http://php.net/manual/en/wrappers.php

Line by line for the first: the url parameter holds file://\etc\passwd?.png. file:// is the protocol for files on the local disk. /etc/passwd is a classic file on Linux systems that lists user accounts; reading it is a common way to prove local file access. The ?.png is the same extension trick as before. The attempt failed, which suggests the endpoint only speaks HTTP.

Line by line for the second: the url parameter holds php://filter/resource=http://www.mrzioto.com?.png. php://filter is a PHP wrapper that can transform data as it is read. The resource= part names what to read, here a web address. Again the ?.png is the extension trick. This also failed.

The working assumption after these failures was that the endpoint is restricted to HTTP.

Step 6: querying the AWS instance metadata service

While discussing ideas for SSRF and file inclusion tricks with NahamSec, the researcher was shown a technique for AWS instances: any AWS instance can query a link-local address to pull metadata about the instance and about the AWS account that owns it. An instance is a virtual computer rented from a cloud provider. Metadata is data about the machine itself, such as its name and network settings. A link-local address is an address that only works from inside the same machine or local network, not from the internet.

ESEA hosts their website on AWS, so the technique applies. The reference is the EC2 instance metadata documentation at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html. EC2 is Amazon's service for renting virtual computers. Querying http://[redacted]/ returns information about the instance such as the private address, hostname, public keys and subnet IDs. A hostname is the machine's name on the network. A public key is half of a cryptographic key pair, used to prove identity. A subnet ID is a label for the network segment the machine sits in.

The most sensitive data available is the IAM role secret keys, which give API access to the AWS account. IAM stands for Identity and Access Management, AWS's system for deciding who can do what. An API is a way for one program to talk to another, like a service counter where you make requests and get answers. Secret keys are like passwords for programs. If an attacker gets them, they can act as that account, potentially creating, reading or deleting resources.

The report gives a generic example of the metadata service:

Text
URL: http://[redacted]/latest/meta-data/hostname
Response: ec2-203-0-113-25.compute-1.amazonaws.com

Line by line: URL: labels the address being requested. http://[redacted]/ is the special link-local address of the metadata service. /latest/meta-data/hostname asks for the hostname field. Response: labels what came back. ec2-203-0-113-25.compute-1.amazonaws.com is the machine's name, which shows the request succeeded. This example is generic, not from ESEA.

No example of this against ESEA is shown, because the responses would contain sensitive data. The researcher judged this sufficient evidence of a high-impact issue and stopped there. "High impact" means the consequences would be serious if exploited.

Root cause

The endpoint fetches a user-supplied URL server-side and returns the response body to the client. The report does not describe any restriction on the destination address. The only validation appears to be an extension check on the URL string, which is trivially defeated by moving the extension behind a question mark so it is parsed as a query string rather than a path. Because the check operates on the URL text rather than on the fetched resource, the researcher judged the server could be pointed at the link-local metadata address, and stopped there. The report does not describe the validation code itself, so the exact implementation is inferred from behaviour.

In plain terms: the door had a lock, but the lock was on the wrong side of the door. The check looked at the spelling of the address instead of at where the address actually led.

Impact

Through the endpoint an attacker can make the ESEA server issue HTTP requests to arbitrary destinations. Two consequences are demonstrated or described:

  1. JavaScript executes in the context of play.esea.net, because the fetched HTML is served from the ESEA domain without isolation. This means an attacker's script runs as if it were part of ESEA, with the same trust the browser gives to ESEA.
  2. The AWS instance metadata service at http://[redacted]/ is reachable, exposing instance details such as private address, hostname, public keys and subnet IDs, and potentially IAM role secret keys that grant API access to the AWS account. With those keys, an attacker could operate the cloud account itself.

The metadata exposure is described as the most shocking data available, and the researcher stopped once this was enough evidence of a high-impact issue rather than extracting ESEA's actual metadata.

Fix

The timeline records the endpoint as fixed on 14 April 2016, with the researcher noting, based on the email response, that it may have been fixed earlier. What the change consisted of is not stated.

Variants to test

These are patterns other researchers can try on similar features. Each one is a small experiment with a clear signal for success.

  • Extension checks on URL strings. Append a query string so the required extension sits after a ?, as in ...?url=http://attacker/?.png. A positive result is the full body of a non-image resource being returned. The lesson: if a check looks at the text of a URL, try to make the text look right while the actual destination is different.
  • Destination allowlisting. Point the parameter at a host you control and watch your access logs. A request arriving from the target's infrastructure confirms server-side fetching; no request suggests filtering or a different fetch path. This is the simplest SSRF test: make the server call you and see if it does.
  • Protocol restrictions. Try file://, php://filter and other wrappers with the same extension trick. A positive result is local file contents or filtered resource output appearing in the response. If the server only speaks HTTP, these will fail, which is itself useful information.
  • Cloud metadata reachability. On any target hosted in a cloud environment, request the metadata address through the SSRF. A positive result is instance metadata such as a hostname or credentials being returned in the response body. This is often the highest-value outcome, because credentials can lead to control of the cloud account.
  • Response rendering context. Serve an HTML file with a script through the parameter. A positive result is the script executing in the target's origin rather than being downloaded or rendered inert. "Origin" here means the combination of protocol, domain and port that the browser uses to decide what a page is allowed to touch.

Timeline

Event Date
Discovery/Reported April 11, 2016
Triaged/Verified April 12, 2016
Fixed April 14, 2016 (possibly earlier, based on the email response)
Rewarded April 18, 2016: $1,000 USD, 1,000 ESEA points, profile badge

"Triaged" means the company looked at the report and confirmed it was real and worth working on. "Verified" means they reproduced it. The reward included ESEA points, which are used on the platform, and a profile badge, a small marker shown on the researcher's profile.

(Reward notification)

Glossary

  • API: a way for one program to talk to another, like a service counter where you make requests and get answers.
  • AWS: Amazon Web Services, a cloud provider that rents out computers and storage over the internet.
  • Blacklist: a list of things that are forbidden.
  • Bounty programme: a company's offer to pay people who find and report security flaws responsibly.
  • Client: the program on your side, usually your browser, that asks a server for things.
  • Cross-site scripting (XSS): a flaw where an attacker's JavaScript runs inside someone else's website in a victim's browser.
  • EC2: Amazon's service for renting virtual computers.
  • Endpoint: a particular address on a website that does a particular job.
  • Enumerate: to make a list of things that exist, such as all pages on a site.
  • Extension: the part of a filename after the last dot, such as .png.
  • File inclusion: a flaw where a server is tricked into loading a file it should not.
  • Google dorking: using advanced Google search operators to find pages matching a pattern.
  • Hostname: a machine's name on a network.
  • HTML: the language web pages are written in.
  • HTTP: the ordinary, unencrypted protocol browsers use to talk to websites.
  • HTTPS: the encrypted version of HTTP.
  • IAM: Identity and Access Management, AWS's system for deciding who can do what.
  • Iframe: a page embedded inside another page, kept separate from the surrounding site.
  • Instance: a virtual computer rented from a cloud provider.
  • JavaScript: the programming language browsers run to make pages interactive.
  • Link-local address: an address that only works from inside the same machine or local network.
  • Metadata: data about a machine itself, such as its name and network settings.
  • Null byte: a special character some programs treat as the end of a string.
  • Origin: the combination of protocol, domain and port that a browser uses to decide what a page may touch.
  • Parameter: a named input in a URL or form, like a blank on a form.
  • Parser: code that breaks text into its parts.
  • Payload: the part of an attack that does the damage.
  • PHP: a programming language commonly used to build websites.
  • Protocol: a set of rules for how two computers talk, such as http:// or file://.
  • Query string: the part of a URL after the question mark that carries extra information.
  • Recon: reconnaissance, looking around before attacking.
  • Render: to display content in a browser.
  • Server: the computer that stores a website and answers requests.
  • Server-side request forgery (SSRF): a flaw where an attacker makes a server send requests to places the attacker cannot reach directly.
  • Subnet ID: a label for the network segment a machine sits in.
  • Triaged: reviewed and confirmed as real and worth working on.
  • Validation: checking input before using it, like a bouncer checking IDs.
  • Wrapper: a PHP feature that lets one protocol be used through another.
  • Whitelist: a list of things that are allowed.

More by Brett Buerhaus

View all

8 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.