Discovering a zero day and getting code execution on Mozilla's AWS Network
An unauthenticated WebPageTest instance allowed arbitrary Zip uploads that were extracted to a web-accessible directory, and a race condition let an attacker access a PHP file before it was deleted. By spoofing the client IP via a header, the attacker bypassed a localhost restriction and achieved remote code execution.
Published on shubs.io
When Assetnote Continuous Security (CS) monitors your attack surface, one of the things it looks for are instances of WebPageTest. WebPageTest is a website performance testing tool that lets you test network related metrics for any given URL/host.
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.
Context
WebPageTest is a website performance testing tool that lets you test network related metrics for any given URL or host. It ships with an array of testing tools, and those tools make outbound requests on your behalf. That is the point of the product, but it also means an exposed instance is a ready-made server-side request forgery primitive: the report describes SSRF here as a feature rather than a bug.
Basic authentication can be enabled by modifying the settings.ini file, and doing so is recommended to prevent anonymous access. In practice, most deployments that Assetnote Continuous Security (CS) identifies are unauthenticated. When CS monitors an attack surface it specifically looks for instances of WebPageTest.
In November 2017, CS discovered two such assets on Mozilla's AWS environment:
wpt-vpn.stage.mozaws.netwpt1.dev.mozaws.net
Neither required authentication. This was the first time CS had detected WebPageTest for a bug bounty. Working with Mathias, the author audited the source code and, within a few hours, built an attack chain that led to remote code execution.
At the time of discovery this was a zero day. The team worked with Mozilla and the WebPageTest maintainers to get it fixed upstream, and the patch was pushed in a commit on 17 January 2018.
Setup
The preconditions are minimal, which is what makes the chain interesting:
- An unauthenticated WebPageTest instance reachable over the network. Here,
wpt-vpn.stage.mozaws.net. - A valid test ID, which the interface hands out for free when you run any test.
- Two Burp Intruder attacks running in parallel: one to upload a malicious Zip, one to fetch the extracted PHP file while it still exists.
- The ability to send a custom request header, which any HTTP client gives you.
No account, no credentials and no access to the host were needed.
Finding it
The first thing that caught the author's attention in the codebase was the ability to upload and extract arbitrary Zip files via /www/work/workdone.php. That script contained logic to restrict access to sources other than [redacted]:
...
!strcmp($_SERVER['REMOTE_ADDR'], "[redacted]")
...
That check is the gate on the interesting functionality, and the author noted it and came back to it later.
In the same file there was a second vector: logic to upload an arbitrary Zip and have it extracted to a known location. Lines 133 to 136 of /www/work/workdone.php:
if (isset($_FILES['file']['tmp_name'])) {
ExtractZipFile($_FILES['file']['tmp_name'], $testPath);
CompressTextFiles($testPath);
}
If the source IP could be spoofed to look like [redacted], this looked like a route to code execution. It was not as straightforward as it first appeared, because of line 321 in the same file:
SecureDir($testPath);
The logic of SecureDir lives on lines 2322 to 2347 of /www/common_lib.inc. Its documented purpose is to make sure there are no risky files in the given directory and to make everything no-execute:
function SecureDir($path) {
$files = scandir($path);
foreach ($files as $file) {
$filepath = "$path/$file";
if (is_file($filepath)) {
$parts = pathinfo($file);
$ext = strtolower($parts['extension']);
if (strpos($ext, 'php') === false &&
strpos($ext, 'pl') === false &&
strpos($ext, 'py') === false &&
strpos($ext, 'cgi') === false &&
strpos($ext, 'asp') === false &&
strpos($ext, 'js') === false &&
strpos($ext, 'rb') === false &&
strpos($ext, 'htaccess') === false &&
strpos($ext, 'jar') === false) {
@chmod($filepath, 0666);
} else {
@chmod($filepath, 0666);
// just in case the unlink fails for some reason
unlink($filepath);
}
} elseif ($file != '.' && $file != '..' && is_dir($filepath)) {
SecureDir($filepath);
}
}
}
SecureDir deletes files whose extension matches any of the risky list, and recurses into subdirectories. But it runs later in the code flow than the extraction. That ordering creates an exploitable race condition: the PHP files extracted into the web server's directory are accessible for a short window before they are deleted.
Exploitation
Step 1: obtain a valid test ID
The first prerequisite was easy. A valid test ID was obtained by running a Traceroute on https://google.com through the WebPageTest interface on wpt-vpn.stage.mozaws.net.
Running a traceroute using WebPageTest
After the traceroute ran, WebPageTest redirected to a URL containing the test ID used in the later steps:
http://wpt-vpn.stage.mozaws.net/result/171124_GW_9/
The 171124_GW_9 segment is the test ID used in the later steps.
Step 2: spoof REMOTE_ADDR as [redacted]
The remaining problem was passing the [redacted] check so the vulnerable functions in workdone.php could be reached. The following logic, on line 70 of /www/common.inc, solved it:
if (isset($_SERVER["HTTP_FASTLY_CLIENT_IP"]))
$_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_FASTLY_CLIENT_IP"];
Any remote user can set $_SERVER["REMOTE_ADDR"] by sending a FASTLY-CLIENT-IP request header set to [redacted]. The application trusts a client-supplied header as the source address, so the loopback check in workdone.php passes for an arbitrary remote client.
Step 3: race the upload against SecureDir
With the test ID and the header spoof in hand, the author set up two Burp Intruder attacks to get code execution:
- One attack uploaded a malicious Zip file to
/www/work/workdone.php, with theFASTLY-CLIENT-IP: [redacted]header, soExtractZipFileunpacked the PHP payload into the test path. - The other attack repeatedly requested the extracted PHP file at its known location under the test path, trying to hit it during the window before
SecureDirunlinked it.
The solution to the race at the time was simply to raise Burp Intruder's thread count to around 200. The author notes that with tools such as Turbo Intruder, the speed of the requests makes this exploit much more reliable today.
Step 4: code execution
This technique achieved code execution on Mozilla.
phpinfo() output from wpt-vpn.stage.mozaws.net
The screenshot shows phpinfo() output served from wpt-vpn.stage.mozaws.net, confirming that the uploaded PHP file executed on the host.
The Bugzilla report in which the vulnerability was first reported is now public and contains thorough reproduction steps for testers who want to recreate the bugs.
Root cause
Three separate mistakes combine into the chain:
- Trusting a client header as the peer address.
/www/common.inccopiesHTTP_FASTLY_CLIENT_IPintoREMOTE_ADDRwhenever the header is present. The loopback restriction inworkdone.phpis therefore not a restriction at all: any remote client can claim to be[redacted]. - Extracting attacker-controlled archives into a web-served directory.
workdone.phpcallsExtractZipFileon the uploaded file and writes the contents to$testPath, which is reachable over HTTP. - Cleaning up after the fact instead of preventing execution.
SecureDirdeletes risky extensions, but it runs after extraction. Between the two, the file exists and is executable.
The existing defences did not stop the attack because the IP check was bypassable and the extension filter was a race rather than a barrier. The report does not describe any other control that would have blocked the upload or the execution.
Impact
An unauthenticated remote attacker could run arbitrary code on the WebPageTest host on Mozilla's AWS environment. The two affected assets were wpt-vpn.stage.mozaws.net and wpt1.dev.mozaws.net. Because WebPageTest is itself an SSRF primitive, an exposed instance also gives access to internal resources reachable from the host, as the report notes when describing the tool's normal behaviour.
The chain depends on the instance being unauthenticated and on winning the race window; the author's own approach was to brute-force the timing with around 200 threads, and notes that faster request tooling makes it more reliable. The report does not describe what internal network access the host had beyond the SSRF capability inherent to WebPageTest.
Fix
The vulnerability was fixed upstream in WebPageTest. The commit patching the bugs outlined in the write-up was pushed on 17 January 2018. The report does not enumerate the individual code changes in that commit.
For deployments that cannot patch immediately, basic authentication can be enabled via settings.ini to prevent anonymous access.
Variants to test
- Unauthenticated WebPageTest instances. Look for the WebPageTest interface on staging and development hostnames. A positive result is a reachable test form that runs a traceroute or similar test without credentials and redirects to a
/result/<test-id>/URL. - Header-based loopback spoofing. On any target that checks
REMOTE_ADDRagainst[redacted], try sendingFASTLY-CLIENT-IP: [redacted]and other proxy-style headers. A positive result is a restricted endpoint returning its normal response instead of a denial. - Archive extraction into web-served paths. Where an upload endpoint extracts a Zip into a directory served by the web server, upload a file with a script extension and request it repeatedly at the predictable path. A positive result is the script executing before cleanup removes it.
- Cleanup races generally. Any endpoint that writes attacker-controlled files and then deletes risky extensions is worth racing with parallel upload and fetch requests. A positive result is a response from the file during the window between write and unlink.
- SSRF through test tooling. On any performance or monitoring tool that fetches URLs on your behalf, point it at internal addresses and metadata endpoints. A positive result is content from an internal resource appearing in the test output.
What happened, in plain words
A security researcher found two servers belonging to Mozilla that were running a free tool called WebPageTest. That tool is meant to test how fast websites load, but it also lets anyone who can reach it make requests to other machines on the network. Because the servers were not protected by a password, the researcher could use the tool as a starting point. By reading the tool's source code, he found a way to upload a file that the server would run as a program. Within a few hours he had a working chain that gave him the ability to run his own code on Mozilla's machine. At the time nobody knew about the flaw, so it was a zero day. The team worked with Mozilla and the WebPageTest maintainers, and a fix was published on 17 January 2018. Mozilla paid a $500 bounty.
This article walks through the same steps for someone who has never done security work before. Every term is explained where it first appears, and every piece of code is broken down line by line.
The tool at the centre of it: WebPageTest
WebPageTest is a website performance testing tool. You give it a web address, and it loads that address from its own servers and reports back on how long things took: how long the page took to appear, how long each image took to download, and so on. To do that, the WebPageTest server has to make network requests out to the internet on your behalf.
That last point matters. When a server makes a request because a user asked it to, security people call that server-side request forgery, usually shortened to SSRF. The everyday comparison: imagine a hotel concierge who will fetch anything you ask for from anywhere in the city. Normally that is a helpful service. But if a guest asks the concierge to go into the hotel's own staff room and read out what is on the noticeboard, the concierge will do that too, because he does not distinguish between outside and inside. An SSRF is the same idea: the server is trusted to reach places the outside user cannot, and it will happily fetch internal addresses if you ask it to. In WebPageTest's case, the report describes SSRF as a feature rather than a bug, because making requests is literally what the product does.
WebPageTest can be protected with basic authentication. Basic authentication is the simplest kind of login: the browser pops up a small box asking for a username and password, and the server checks them before letting you in. It is switched on by editing a configuration file called settings.ini, and the report says doing so is recommended to prevent anonymous access. Anonymous access means anyone at all can use the tool without identifying themselves.
In practice, most WebPageTest installations that Assetnote Continuous Security (CS) finds are unauthenticated. Assetnote CS is a service that continuously scans an organisation's internet-facing systems (its attack surface) looking for things that are exposed. One of the specific things it looks for is WebPageTest.
The two servers that were found
In November 2017, Assetnote CS discovered two WebPageTest instances on Mozilla's Amazon Web Services (AWS) environment. AWS is Amazon's cloud platform: instead of owning physical servers, organisations rent virtual machines from Amazon and reach them over the internet.
The two assets were:
wpt-vpn.stage.mozaws.netwpt1.dev.mozaws.net
Neither required authentication. This was the first time Assetnote CS had detected WebPageTest during a bug bounty. A bug bounty is a programme where an organisation invites outside researchers to find security problems and pays them for reporting them responsibly instead of exploiting them.
Working with Mathias, the author audited the source code. Auditing source code means reading the program's instructions line by line, looking for places where it trusts something it should not. Within a few hours the pair had built an attack chain that led to remote code execution. Remote code execution (RCE) is the ability to make the target machine run commands or programs of your choosing, from a distance, without ever logging in to it. It is generally the most serious outcome in this kind of work, because from there an attacker can do almost anything the server's own user account can do.
At the time of discovery this was a zero day: a flaw that is not yet publicly known and for which no fix exists. The team worked with Mozilla and the WebPageTest maintainers to get it fixed upstream, meaning in the original WebPageTest project rather than only on Mozilla's copies. The patch was pushed in a commit on 17 January 2018. A commit is a saved change to a code repository, the shared store of a project's source code.
What you need before you can try this
The preconditions are minimal, which is what makes the chain interesting:
- An unauthenticated WebPageTest instance reachable over the network. Here,
wpt-vpn.stage.mozaws.net. - A valid test ID, which the interface hands out for free when you run any test.
- Two Burp Intruder attacks running in parallel: one to upload a malicious Zip, one to fetch the extracted PHP file while it still exists.
- The ability to send a custom request header, which any HTTP client gives you.
No account, no credentials and no access to the host were needed.
A few of those terms need unpacking. A test ID is simply a short label the tool gives to each test you run, so that it can store the results and show them to you later at a web address containing that label. Burp Intruder is a feature of Burp Suite, a tool security testers use to intercept and modify web traffic; Intruder sends the same request over and over with small variations, and can do several such attacks at once. A Zip file is a single file that contains other files compressed inside it, like a cardboard box with several items packed in. PHP is a programming language used to build web pages; a PHP file placed in a web server's folder can be run by the server when someone requests it. A request header is a small piece of extra information attached to a web request, such as the browser telling the server what kind of content it accepts. An HTTP client is any program that sends web requests: a browser, a command-line tool, or Burp.
Finding it
The first thing that caught the author's attention in the codebase was the ability to upload and extract arbitrary Zip files via /www/work/workdone.php. That script contained logic to restrict access to sources other than [redacted]:
...
!strcmp($_SERVER['REMOTE_ADDR'], "[redacted]")
...
Line by line:
...means code has been left out above and below; this is only the relevant fragment.$_SERVER['REMOTE_ADDR']is a value the web server fills in with the address of whoever made the request.[redacted]is the special address a computer uses to refer to itself, often called localhost or the loopback address. So this value is the caller's internet address.strcmp(...)compares two pieces of text and returns zero when they are identical.!means "not". So!strcmp(...)is true when the two strings are not equal.- Putting it together: the condition is true when the caller is not
[redacted]. The script uses this to restrict the interesting functionality to requests coming from the machine itself, and to refuse everyone else.
That check is the gate on the interesting functionality, and the author noted it and came back to it later.
In the same file there was a second vector: logic to upload an arbitrary Zip and have it extracted to a known location. Lines 133 to 136 of /www/work/workdone.php:
if (isset($_FILES['file']['tmp_name'])) {
ExtractZipFile($_FILES['file']['tmp_name'], $testPath);
CompressTextFiles($testPath);
}
Line by line:
isset($_FILES['file']['tmp_name'])asks whether the request included an uploaded file. When a browser uploads a file, PHP puts it in a temporary location on disk and records that location in$_FILES['file']['tmp_name'].issetreturns true if that value exists.ExtractZipFile($_FILES['file']['tmp_name'], $testPath)takes the uploaded file and unpacks its contents into the folder named by$testPath.$testPathis the folder belonging to the current test, derived from the test ID.CompressTextFiles($testPath)then compresses the text files in that folder, a housekeeping step.
If the source IP could be spoofed to look like [redacted], this looked like a route to code execution. Spoofing here means making the server believe the request came from somewhere other than where it really came from. It was not as straightforward as it first appeared, because of line 321 in the same file:
SecureDir($testPath);
This calls a function named SecureDir on the test folder. The logic of SecureDir lives on lines 2322 to 2347 of /www/common_lib.inc. Its documented purpose is to make sure there are no risky files in the given directory and to make everything no-execute:
function SecureDir($path) {
$files = scandir($path);
foreach ($files as $file) {
$filepath = "$path/$file";
if (is_file($filepath)) {
$parts = pathinfo($file);
$ext = strtolower($parts['extension']);
if (strpos($ext, 'php') === false &&
strpos($ext, 'pl') === false &&
strpos($ext, 'py') === false &&
strpos($ext, 'cgi') === false &&
strpos($ext, 'asp') === false &&
strpos($ext, 'js') === false &&
strpos($ext, 'rb') === false &&
strpos($ext, 'htaccess') === false &&
strpos($ext, 'jar') === false) {
@chmod($filepath, 0666);
} else {
@chmod($filepath, 0666);
// just in case the unlink fails for some reason
unlink($filepath);
}
} elseif ($file != '.' && $file != '..' && is_dir($filepath)) {
SecureDir($filepath);
}
}
}
Line by line:
function SecureDir($path) {defines a reusable block of code that takes a folder path as input.$files = scandir($path);lists everything inside that folder and stores the list in$files.foreach ($files as $file) {goes through the list one item at a time.$filepath = "$path/$file";builds the full location of the item by joining the folder and the item's name.if (is_file($filepath)) {checks whether the item is a regular file (as opposed to a folder).$parts = pathinfo($file);splits the file name into pieces, such as its name and its extension.$ext = strtolower($parts['extension']);takes the extension (the part after the last dot, likephpinshell.php) and converts it to lowercase so the comparison is not fooled by capital letters.- The long
ifwithstrpos($ext, 'php') === false && ...checks whether the extension contains any of a list of risky strings:php,pl,py,cgi,asp,js,rb,htaccess,jar.strposfinds one piece of text inside another and returns false when it is not there.&&means "and", so all of these must be false for the whole condition to be true. In other words: the file is safe only if its extension contains none of those risky strings. @chmod($filepath, 0666);in the safe branch changes the file's permissions to0666, which means readable and writable by everyone. The@suppresses any warning if the change fails.} else {is the branch for risky files.@chmod($filepath, 0666);sets the same permissions, then the comment// just in case the unlink fails for some reasonexplains the next line.unlink($filepath);deletes the file.} elseif ($file != '.' && $file != '..' && is_dir($filepath)) {handles the case where the item is a folder, skipping the special entries.and..that every folder contains.SecureDir($filepath);calls itself on that subfolder, so the cleanup reaches every level.
SecureDir deletes files whose extension matches any of the risky list, and recurses into subdirectories. But it runs later in the code flow than the extraction. That ordering creates an exploitable race condition: the PHP files extracted into the web server's directory are accessible for a short window before they are deleted.
A race condition is when a program's correctness depends on timing. The everyday comparison: a cleaner who tidies a hotel room after the guest has already walked in. If you can get into the room in the few seconds between the guest arriving and the cleaner arriving, you can use the room even though the cleaner will eventually remove everything. Here, the uploaded PHP file exists on disk and can be requested over the web for a brief moment before SecureDir deletes it. If your request arrives inside that moment, the server runs your file.
Exploitation
Step 1: obtain a valid test ID
The first prerequisite was easy. A valid test ID was obtained by running a Traceroute on https://google.com through the WebPageTest interface on wpt-vpn.stage.mozaws.net.
A traceroute is a network diagnostic that shows the path a connection takes from one machine to another, hop by hop. WebPageTest offers it as one of its tests. Running it is a normal, harmless use of the tool, and it is free: no login required.
Running a traceroute using WebPageTest
After the traceroute ran, WebPageTest redirected to a URL containing the test ID used in the later steps:
http://wpt-vpn.stage.mozaws.net/result/171124_GW_9/
Line by line:
http://is the scheme, telling the browser to speak the ordinary web protocol.wpt-vpn.stage.mozaws.netis the host, the WebPageTest server that was found./result/is the part of the site that shows test results.171124_GW_9is the test ID. It is the label the tool assigned to the traceroute run.- The trailing
/ends the path.
The 171124_GW_9 segment is the test ID used in the later steps.
Step 2: spoof REMOTE_ADDR as [redacted]
The remaining problem was passing the [redacted] check so the vulnerable functions in workdone.php could be reached. The following logic, on line 70 of /www/common.inc, solved it:
if (isset($_SERVER["HTTP_FASTLY_CLIENT_IP"]))
$_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_FASTLY_CLIENT_IP"];
Line by line:
isset($_SERVER["HTTP_FASTLY_CLIENT_IP"])checks whether the incoming request carried a header namedFASTLY-CLIENT-IP. PHP turns incoming headers into entries in$_SERVERwith anHTTP_prefix and dashes turned into underscores, so the headerFASTLY-CLIENT-IPappears asHTTP_FASTLY_CLIENT_IP.- If it did, the second line copies that header's value into
$_SERVER["REMOTE_ADDR"], the value the rest of the program treats as the caller's address.
Fastly is a content delivery network, a service that sits in front of a website and passes visitors' requests through to the real server. In that setup, the real server sees Fastly's address, not the visitor's, so Fastly adds a header saying who the original visitor was. Any remote user can set $_SERVER["REMOTE_ADDR"] by sending a FASTLY-CLIENT-IP request header set to [redacted]. The application trusts a client-supplied header as the source address, so the loopback check in workdone.php passes for an arbitrary remote client. In everyday terms: the hotel receptionist believes whatever name tag a visitor writes for themselves.
Step 3: race the upload against SecureDir
With the test ID and the header spoof in hand, the author set up two Burp Intruder attacks to get code execution:
- One attack uploaded a malicious Zip file to
/www/work/workdone.php, with theFASTLY-CLIENT-IP: [redacted]header, soExtractZipFileunpacked the PHP payload into the test path. - The other attack repeatedly requested the extracted PHP file at its known location under the test path, trying to hit it during the window before
SecureDirunlinked it.
A payload here means the file the attacker wants the server to run. The first attack is the delivery: it puts the file on disk. The second attack is the retrieval: it asks the server for that file over and over, hoping one request lands in the gap between extraction and deletion. Neither attack works alone. Uploading without fetching leaves a file that gets deleted before anyone uses it; fetching without uploading asks for a file that does not exist.
The solution to the race at the time was simply to raise Burp Intruder's thread count to around 200. A thread is one line of work a program runs at the same time; more threads means more requests in flight at once, which raises the chance that one of them arrives during the short window. The author notes that with tools such as Turbo Intruder, the speed of the requests makes this exploit much more reliable today. Turbo Intruder is a Burp extension built for sending very large numbers of requests very quickly.
Step 4: code execution
This technique achieved code execution on Mozilla.
phpinfo() output from wpt-vpn.stage.mozaws.net
The screenshot shows phpinfo() output served from wpt-vpn.stage.mozaws.net, confirming that the uploaded PHP file executed on the host. phpinfo() is a standard PHP function that prints a long page of details about the PHP installation and the server it runs on. Seeing that page means the server did not merely store the file: it ran it as a program. That is the difference between uploading a document and uploading a program, and it is why this step is the proof of remote code execution.
The Bugzilla report in which the vulnerability was first reported is now public and contains thorough reproduction steps for testers who want to recreate the bugs. Bugzilla is Mozilla's bug-tracking system, where issues are recorded and discussed.
Root cause
Three separate mistakes combine into the chain:
- Trusting a client header as the peer address.
/www/common.inccopiesHTTP_FASTLY_CLIENT_IPintoREMOTE_ADDRwhenever the header is present. The loopback restriction inworkdone.phpis therefore not a restriction at all: any remote client can claim to be[redacted]. - Extracting attacker-controlled archives into a web-served directory.
workdone.phpcallsExtractZipFileon the uploaded file and writes the contents to$testPath, which is reachable over HTTP. A web-served directory is a folder the web server will hand out files from. Putting unpacked, attacker-chosen files there is like letting a stranger post letters through your own front door. - Cleaning up after the fact instead of preventing execution.
SecureDirdeletes risky extensions, but it runs after extraction. Between the two, the file exists and is executable. Atomic means happening as one indivisible step; here the write and the delete are two separate steps, and anything can happen in between.
The existing defences did not stop the attack because the IP check was bypassable and the extension filter was a race rather than a barrier. The report does not describe any other control that would have blocked the upload or the execution.
Impact
An unauthenticated remote attacker could run arbitrary code on the WebPageTest host on Mozilla's AWS environment. The web server user is the limited account the web server runs under; code running there inherits that account's permissions, not full control of the machine. The two affected assets were wpt-vpn.stage.mozaws.net and wpt1.dev.mozaws.net. Because WebPageTest is itself an SSRF primitive, an exposed instance also gives access to internal resources reachable from the host, as the report notes when describing the tool's normal behaviour.
The chain depends on the instance being unauthenticated and on winning the race window; the author's own approach was to brute-force the timing with around 200 threads, and notes that faster request tooling makes it more reliable. Brute-forcing here means trying many times rather than being clever about timing. The report does not describe what internal network access the host had beyond the SSRF capability inherent to WebPageTest.
Fix
The vulnerability was fixed upstream in WebPageTest. The commit patching the bugs outlined in the write-up was pushed on 17 January 2018. The report does not enumerate the individual code changes in that commit.
For deployments that cannot patch immediately, basic authentication can be enabled via settings.ini to prevent anonymous access. A proxy is a server that sits between users and the real server and forwards requests; a trusted one is under your control, so it can be relied on to set headers honestly.
Variants to test
- Unauthenticated WebPageTest instances. Look for the WebPageTest interface on staging and development hostnames. A positive result is a reachable test form that runs a traceroute or similar test without credentials and redirects to a
/result/<test-id>/URL. - Header-based loopback spoofing. On any target that checks
REMOTE_ADDRagainst[redacted], try sendingFASTLY-CLIENT-IP: [redacted]and other proxy-style headers. A positive result is a restricted endpoint returning its normal response instead of a denial. - Archive extraction into web-served paths. Where an upload endpoint extracts a Zip into a directory served by the web server, upload a file with a script extension and request it repeatedly at the predictable path. A positive result is the script executing before cleanup removes it.
- Cleanup races generally. Any endpoint that writes attacker-controlled files and then deletes risky extensions is worth racing with parallel upload and fetch requests. A positive result is a response from the file during the window between write and unlink.
- SSRF through test tooling. On any performance or monitoring tool that fetches URLs on your behalf, point it at internal addresses and metadata endpoints. A positive result is content from an internal resource appearing in the test output. A metadata endpoint is a special internal address that cloud platforms expose to virtual machines so they can learn about themselves; it can carry credentials, which is why it is a favourite SSRF target.
Glossary
- Anonymous access: using a service without identifying yourself, with no username or password.
- Attack surface: everything an organisation exposes to the internet that someone could try to break into.
- Atomic: happening as a single indivisible step, with no moment in between where something else can happen.
- Auditing source code: reading a program's instructions line by line to look for mistakes.
- AWS: Amazon Web Services, Amazon's cloud platform where organisations rent virtual machines.
- Basic authentication: the simplest login, where the browser asks for a username and password and the server checks them.
- Brute-forcing: trying something many times rather than being clever about it.
- Bug bounty: a programme that pays outside researchers for responsibly reporting security flaws.
- Bugzilla: Mozilla's bug-tracking system.
- Burp Intruder: a feature of the Burp Suite testing tool that sends many variations of a request automatically.
- Commit: a saved change to a code repository.
- Content delivery network (CDN): a service that sits in front of a website and forwards visitors' requests to the real server.
- Extension: the part of a file name after the last dot, such as
phpinshell.php. - Fastly: a content delivery network; here, the service whose header the code trusted.
- Header: a small piece of extra information attached to a web request or response.
- HTTP client: any program that sends web requests, such as a browser or a command-line tool.
- Localhost / loopback: the special address
[redacted], which a computer uses to refer to itself. - Metadata endpoint: an internal address cloud platforms expose to virtual machines, sometimes carrying credentials.
- Patch: a change that fixes a flaw.
- Payload: the file or data an attacker wants the target to run or process.
- PHP: a programming language used to build web pages; PHP files in a web folder can be run by the server.
phpinfo(): a standard PHP function that prints details about the PHP installation and server.- Proxy: a server that sits between users and the real server and forwards requests.
- Race condition: a situation where the outcome depends on timing, because two steps happen close together.
- Remote code execution (RCE): making a target machine run programs of your choosing from a distance.
- Request: a message a client sends to a server asking for something.
- Server-side request forgery (SSRF): making a server fetch a resource on your behalf, including internal ones you could not reach yourself.
- Source code: the human-written instructions that make up a program.
- Spoofing: making something appear to come from somewhere other than where it really came from.
- Thread: one line of work a program runs at the same time as others.
- Traceroute: a network diagnostic showing the path a connection takes hop by hop.
- Turbo Intruder: a Burp extension for sending very large numbers of requests very quickly.
- Upstream: the original project that a piece of software comes from, as opposed to a copy.
- Web-served directory: a folder the web server will hand out files from.
- WebPageTest: a website performance testing tool that loads URLs on its own servers and reports timing.
- Zero day: a flaw that is not publicly known and has no fix yet.
- Zip file: a single file containing other files compressed inside it.