ssrf-usenix-2024
ssrf-usenix-2024
Abstract SSRF ranks among the OWASP Top 10 [31] and CWE
Server-side requests (SSR) are a potent and important tool Top 25 [40] security risks. Recent incidents suggest that web
for modern web applications, as they enable features such applications are still exposed to SSR vulnerabilities. For exam-
as link preview and web hooks. Unfortunately, naive usage ple, an attacker recently elevated an attacker-controlled SSR
of SSR opens the underlying application up to Server-Side vulnerability affecting Microsoft Exchange servers into an
Request Forgery – an underappreciated vulnerability risk. To RCE vulnerability, bypassing authentication and firewalls, re-
shed light on this vulnerability class, we conduct an in-depth sulting in email theft [3, 17]. Most recently, PyTorch’s Torch-
analysis of known exploitation methods as well as defenses Serve suffered from an arbitrary code execution flaw caused
and mitigations across PHP. We then proceed to study the by an SSRF flaw, which allowed the attacker to load the ma-
prevalence of the vulnerability and defenses across 27,078 licious model [4]. Even applications that attempt to defend
open-source PHP applications. For this we perform an initial themselves frequently get it wrong, such as vSphere, which
data flow analysis, identifying attacker-controlled inputs into employed URL validation but suffered from an information
known SSR functions, followed up by a manual analysis of disclosure attack through SSRF [2].
our results to gain a detailed understanding of the involved Unfortunately, we know little about the prevalence of SSR
vulnerabilities and present defenses. Our results show that vulnerabilities and the effectiveness of the existing defenses,
defenses are sparse. The hypermajority of our 237 detected as the research community has given SSRs limited attention.
data flows are vulnerable. Only two analyzed applications Up to this point, prior work has been conducted only on a
implement safe SSR features. small scale and was focused on either understanding and
Since known defenses are not used and detected attacker- exploring the security risks (i.e., Pellegrino et al. [32]) or
controlled flows are almost always vulnerable, we can only novel defenses (i.e., Jabiyev et al. [21]). This paper addresses
conclude that developers are still unaware of SSR abuses and this gap by providing a large-scale analysis of SSR threats in
the need to defend against them. Consequently, SSRF is a PHP web applications.
present and underappreciated danger in modern web applica- Analyzing PHP SSRF vulnerabilities, at scale, and the code
tions. patterns associated with defenses is particularly challenging.
The lack of reliable, scalable and flexible investigation tools
hinders such analysis because it requires collecting, analyz-
1 Introduction ing, and reasoning on millions of lines of code. Tools such as
PHPJoern [9], a Code Property Graph Generator, have previ-
Server-side requests (SSRs) are a convenient service-to- ously been employed in large-scale analysis of PHP programs.
service communication pattern in which a web service sends However, our evaluation has revealed significant inaccuracies,
HTTP requests to external entities. Modern web applications such as an incorrect control flow graph and consequently in-
use SSRs to implement many user-facing functionalities, such accurate data flows edges, thereby increasing the likelihood
as URL previews [36] or integration of third-party content, of false positive results. Thus, beside our SSRF study, we also
such as external calendars [16]. While essential in practice, if present an up-to-date version of the CPG generator for PHP
not implemented correctly, SSRs can be abused, introducing web applications aiding us in our static analysis.
a wide variety of security risks, ranging from attacks such
In this paper, we present the first static security measure-
as network reconnaissance [32] to high severity ones such as
ment of SSR threats in PHP source code. Starting from a thor-
remote code execution (RCE) attacks.
ough survey of existing academic and non-academic work on
∗ Both authors contributed equally to this research. SSR vulnerabilities, attacks, and defenses, we create an up-to-
date taxonomy of SSR threats. Then, we use our taxonomy to req(URL) URL
study the prevalence of SSR vulnerabilities and defenses in
real web applications by downloading and analyzing 30.870 External
Client
popular open-source PHP web applications on GitHub. Server Server
To infer if protection mechanisms against SSR vulnerabil-
n res n res
ities are present, we study these applications with S URFER,
a flexible static analysis PHP framework tailored to sup-
Figure 1: A Server-Side Request.
port exploratory analysis of PHP vulnerabilities. S URFER
works on top of our novel PHP bytecode code property graph req(localhost)
(CPG) [47]. S URFER successfully analyzed 27,078 reposito-
ries. In this set, 15.308 applications utilize API sinks, such as Client Server SSRF
file_get_contents, that are potentially susceptible to SSR
problems. For 1.040 of these applications, S URFER was able n res
to identify at least one potentially suspicious flow into such
sinks. To further narrow down the set of vulnerability candi- Figure 2: An SSRF attack that accesses local resources.
dates, we only consider cases in which a direct data flow from
user-provided input into the sinks exists, and the adversary
controls the significant parts of the passed URL value. After the implications, including a case study and the answer to
applying these processing steps, we end up with 141 PHP our research questions (6). Finally, we provide an overview
projects that utilize server-side request sinks in a potentially of related work (7) and conclude with a summary of our key
insecure manner. takeaways (8).
To thoroughly examine the existence of potential defensive
measures and their robustness, we follow up with a manual
inspection of these applications. The results of this analysis
2 A Primer on SSRF
paint a somber picture: More than half of the identified ap-
We briefly introduced the SSR feature and its evil variation
plications use no defensive measures against SSRF and, thus,
SSRF. In this section we are providing a primer on why server-
are trivial to exploit. Only three projects leverage dedicated
side requests exist (2.1) and how they can turn into SSRF (2.2)
existing SSRF-secure request mechanism and only two of
arriving at our research questions (2.3).
the remaining PHP projects deployed robust countermeasures
against sophisticated attack techniques, such as using DNS
rebinding. Thus, our analysis demonstrates a widespread ig- 2.1 Server-Side Requests
norance by developers in respect to SSRF vulnerabilities.
In summary, this paper makes the following contributions: An application requires a server-side request as soon as it
needs information that is not stored within the application
• A survey and usage study of existing open source SSR components itself. Common examples are webhooks, pre-
abuse mitigation techniques in PHP. views of links, and interaction with external APIs like pay-
ment or authentication providers.
• A PHP Code Property Graph generator based on the The chain of events leading to a server-side request starts
modern CPG framework. with a (user) request for an application resource, depending on
• A CPG based static analysis tool chain (S URFER) to remote data. For example, if the application wants to display
identify SSRF vulnerable code. a link preview, it must perform a request and retrieve the
data required for the preview to answer the client’s request.
• A large scale study of 27,078 PHP projects for SSRF Figure 1 visualizes this event chain.
vulnerabilities and mitigation techniques. User-input-controlled SSRs are allowed for several reasons.
For instance, webhooks and link previews target user-provided
Organization of the paper We first discuss the difference URLs by design. Other SSR use cases allow the user to affect
between SSR and SSRF as well as the challenges of defending parts of the target URL, such as URL parameters.
against it, deriving our research questions (2). After having
established the required background, we detail the current 2.2 SSRF: Server-Side Requests Going Rogue
state of SSRF mitigation techniques in popular open-source
frameworks (3). We then lay the groundwork for our tooling Suppose an SSR request can be influenced by user input be-
and present S URFER, as well as our Manual Analysis to per- yond the scope envisioned by the developer. In that case,
form our large-scale static analysis study (4). The results of attackers can leverage this as an attack vector and guide the
our analysis are given next (5), followed by a discussion of request to malicious hosts and services. The developer is
responsible for ensuring that user-provided data cannot unin- known attacks and defenses according to the literature to
tentionally influence a request, e.g., by changing the target to frame our search later on.
network-internal resources. How an attacker can exploit their We start our systematization from Pellegrino et al. [32]’s
ability to influence the request depends on the deployment work on SSR attacks and amend it with results from an
context, including the network topology, the host machine’s academic literature survey. Additionally, we explored non-
configuration, and the influence’s scope. academic sources systematically by searching the web for
If a server with a vulnerable application runs localhost- ‘SSRF’ with keywords such as ‘Defense’ and ‘best practice’.
accessible services, an attacker can use the SSRF to access This resulted in the non-academic sources [8, 18, 25, 26, 30,
normally denied resources. Figure 2 visualizes such an attack. 39, 44] as well as the academic sources [21, 28, 32]. A system-
As in our introductory examples, this enables an attacker to ized overview of our results on SSR attacks and application-
conduct network reconnaissance, secret stealing, or even RCE. level defenses is given in Table 1. Table 2 augments it with
Cloud services often serve HTTP APIs on the local network, details about possible defense evasions and the respective
providing configuration and metadata [7, 12, 21]. An SSRF fixes.
vulnerability exposes this internal API to attackers.
Even if all local resources are adequately protected, an
3.1 Attacks
attacker can still abuse an SSRF vulnerability. Vulnerable
public access points can be attacked via SSR requests from Across the literature, we identified six distinct classes of at-
SSRF-vulnerable servers. As the vulnerable server performs tacks that leverage SSRF vulnerabilities to perform malicious
the request, the attacker hides their identity, impeding inves- and unintended activities:
tigations into attacks or laundering the presumed host to an
unsuspecting third party.
(A1) Recon Attack: The first class of attack tries to gain
Sometimes, vulnerabilities such as SSR occur in authen- information about a server’s network using the SSRF vul-
ticated areas of an application. They should not be ignored. nerability to reach behind the firewall and gain access to
Firstly, not all authenticated users should possess power over network internals. An attacker can identify deployed services
the whole system, e.g., regular users vs. admins. Secondly, and available machines using return values or timing-based
superuser rights inside an application, such as admin rights side channels.
in a CMS, do not equal to any rights on the host OS. This
applies especially in managed hosting environments, where
users might have superuser rights inside their application but (A2) Origin Laundering: In the second class of attack, the
not on the underlying machine. However, in both cases, a attacker uses the SSRF vulnerability to misuse the server as
malicious user or web admin could exploit an SSRF vulnera- a proxy to serve malicious data from another website. This
bility to gain access to sections of the application they are not can be used to circumvent block lists implemented by the
authenticated for or the underlying host OS. browser. An SSRF-vulnerable website can be misused as a
proxy serving otherwise blocked malicious content.
2.3 Research Questions (A3) Denial of Service: The next attack category is De-
SSRF poses a risk to anybody using SSR features, but the nial of Service (DoS) attacks, usually split into three distinct
state of SSRF is an orphaned domain in current research. To subtypes across the literature.
address this, we formulate four research questions that each Consider an SSR service using a GET parameter as input
provide a distinct insight: and reflecting the SSR’s response. An attacker can craft a URL
directing the service to a domain hosting illegal or known
RQ1: What is the current state-of-the-art of SSRF defenses? malicious content. They then provide this prepared link to a
RQ2: Are web application developers using existing SSR web scanner. When the scanner requests the prepared link,
mitigations? the SSR service requests the embedded target and mirrors
RQ3: Are web application developers using homegrown the content. The scanner then flags the SSR service due to
SSR mitigations? malicious content. Consequently, an attacker can use an SSRF
RQ4: How many web applications are prone to SSR abuses? vulnerability to put the victim server on block lists and thus
achieve a denial of service. Such a DoS is also possible on
a non-technical level. For example, if the prepared link is
3 Survey Of Attacks and Defenses reported to the authorities, the SSR provider could face legal
action.
SSRF is a multifaceted vulnerability class that allows for The remaining two kinds leverage amplification of the
varied exploitation options. The same holds for defending request. In case the SSRF does not trigger a single but multiple
against SSRF abuses. This warrants a detailed discussion of requests to a target, the vulnerable service can be abused as
Attacks D1 URL Valid. D2 DNS Valid. D3 Secure Conf. D4 Response Modification
HTTP(s) only
wrap result
C-D header
validation
rate limit
IP input
No OOP
fixed RT
Domain
Scheme
Path
Port
A1 Recon attack Port scan • ◦
Network scan △ • ◦ [21, 30, 31, 32, 49]
A2 Origin Laundering △ △ • • • [32]
A3 DoS attacks by blocklist △ • △ [30]
attack ES △ ◦ [32]
attack Ampl. △ ◦ [32]
A4 Bridging Attack • • [32, 44]
A5 Exploiting SSBs △ △ [28]
A6: Local Res. Leak △ ◦ △ [30, 39]
Table 1: Overview over SSR attacks and application-level defenses. •: Defense successfully prevents the attack. ◦: Defense
mitigates some version of the attack. △: Defense works in an allow list scenario.
(a) Computation of a max (b) The CPG representation of Figure 3a with the nodes (c) The extracted program slice for echo a
value. Highlighted state- that might influence the slicing node echo max. The of Figure 3b. The green lines represent data
ments might influence the black edges represent the AST, the blue edges the CFG, dependency and the blue line represents
slicing criterion echo max. and the green edges the DDG. control dependency.
Figure 3: A sequence of visualizations showing the transformation of a computer program (3a) into a Code Property Graph (3b)
and finally an extracted program slice (3c).
4 Identifying SSRF Vulnerable Code We present an up-to-date PHP CPG generator that is not
based on the source code but utilizes the PHP interpreter’s in-
Given the complexity of SSRF, we want to study its preva- ternal bytecode representation. The PHP interpreter provides a
lence and its expression in common software. For this, we debug function that dumps the bytecode representation of syn-
develop a static analysis methodology that leverages a Code tactically valid PHP source code. Our CPG generator parses
Property Graph (CPG) code representation [47] and interpro- this bytecode dump into an AST structure. The main advan-
cedural data flow analysis to identify interfunctional data flow tage of using the bytecode representation is that the dump
from user-controlled sources into a known SSRF sink. Subse- comes with a CFG, which we use to add our CFG edges. This
quently, we manually analyze identified data flows to gain an leads to a high degree of CFG correctness as the CFG is taken
in-depth understanding of vulnerable flows and any present directly from PHP. Based on the CFG, we generate the data
attempts to defend against SSRF exploitation. dependency graph using a standard algorithm [5]. Another
We first lay the theoretical groundwork establishing our advantage of using the bytecode representation provided by
static analysis methodology (4.1), which is followed by de- the interpreter is that each function and method reference
scribing our subsequent manual analysis of any identified data is represented with a fully qualified name, including possi-
flow (4.2). ble namespaces or class names in the case of static methods.
Therefore, we create the call graph by matching the qualified
names of functions and methods with their definitions if they
4.1 Automatic Static Analysis are unique. In cases where the names are not unique, e.g.,
method names shared across class definitions, we do not cre-
To present our static analysis methodology, we start by giving
ate a call edge. Our tool is implemented against the publicly
a brief introduction to CPGs (4.1.1) and Data Flow Analysis
available specifications and framework for the Code Property
(4.1.2), followed by an explanation of how we leverage those
Graph [48] and is publicly available1 .
techniques to detect SSRF vulnerabilities (4.1.3).
a real application but are used for red and blue teaming, such
as Capture-the-Flag tasks and solutions, applications that are Count 800
600
vulnerable by design for educational purposes, and malicious
applications such as web shells. These are not representative 400
of the regular developer and application and are thus out of 200
the URL are checked, e.g., if only non-HTTPS requests are CPG With Sink
Surfer Success
prevented. Additionally, we note any usage of a proper URL 800
Flow Detected
a AMD EPYC 7702P with 504 GB RAM with 10 parallel false positive (18)
flows (237)
processes. Each generation was allocated 20 GB of RAM
and forcefully terminated after 10 minutes. To determine the trivially exploitable (39)
coverage of relevant repositories in our dataset, we conducted
another ripgrep-based search for calls of our SSR sinks. This
is a rough over-approximation. 15.308 of our 30.870 repos- hackingtool (71)
Case Study: Insufficient Domain Validation We encoun- Case Study: unsafe esc_url_raw We found a vulner-
tered a vulnerability in LibreX during our work4 that serves able WordPress plugin that depends on the broken sanitizer
as a suiting example for an insufficient attempt at protecting function esc_url_raw. Figure 9 shows its sanitization func-
against SSRF. The vulnerable code is shown in Figure 8. tion, which uses some user input as a source. The input
The code defines a domain allowlist in line 3. It then at- is passed through sanitize_text_field from WordPress,
tempts to check the user input from line 1 against the allow which has no special effect on URLs. The plugin only depends
4 https://github.com/hnhx/librex. We notified the developers of on esc_url_raw as a sanitizer for SSR abuses. As established
the problem. The repository was deleted from GitHub. in Section 3.4 esc_url_raw’s documentation promises that
its result is safe for HTTP requests, but this is not true since 6.2 PHPJoern
it is not performing any SSR validation. This underlines the
importance of clear and correct documentation. We have discussed PHPJoern’s shortcomings we identified be-
fore conducting our study (4.1.1). We, a posteriori, evaluated
if they would have impacted our results if we had used PHPJo-
1 // We simplified this snippet. ern. Since we mitigate false positives through our subsequent
2 function get_response( $url ) {
3 $result = wp_remote_get(esc_url_raw( $url )); manual review, we focus on the version mismatch.
4 return $result; To estimate the impact of errors due to version mismatches,
5 } we conducted an experiment: Using PHP’s syntax check fea-
ture, we measured the PHP 7.1 compatibility of our dataset.
Figure 9: Vulnerable sanitizer function of a WP plugin. We found 4.990 repositories that use modern PHPJoern-
incompatible features, i.e., they pass PHP 8.2’s syntax check
but not PHP 7.1’s. We manually cross-checked these with our
vulnerable flows and identified one vulnerable code path miss-
ing from PHPJoern’s CPG. Therefore, we would be unable to
find it if we based SURFER on PHPJoern instead of our new
6.1 Limitations CPG generator. The breaking feature used by the vulnerable
code is DNF Type Declarations.
While we aim at being complete, our approach contains limi-
tations:
Static Analysis Static analysis suffers from inherent limi- 6.3 Research Questions Answered
tations that can lead to missed data flows due to programming We will now answer our research questions from Section 2.3
patterns that are inherently difficult, if not impossible, to re- and summarize our learnings.
construct. These patterns are a well-known limitation of static How Popular are SSRs? 49.6 % of the repositories in our
analysis that is under active research [e.g. 23, 24], and may dataset contained at least one SSR sink. Since this number
lead to missed data flows. Static analysis is also vulnerable to is string-search-based, it is a rough approximation. Filtering
false positives; however, as we manually verify each of our de- results for only those with user input in the data flow to the
tected flows, we eliminate this risk reliably. Additionally, our SSR sink, we get 141. This shows that application developers
static analysis failed for very complex applications as CPG are using SSR sinks mostly with static targets.
creation can experience exponential growth, which may lead Current State of SSRF defenses (RQ1) From an aca-
to time-outs or memory exhaustion depending on the struc- demic and documentation standpoint, SSR abuses are well
ture of the application, limiting our data set (ref. Figure 6). documented. The literature provides enough sources on de-
Finally, we had to decide on one of the different and only fenses, and OWASP is providing cheat sheets. The common
partially compatible PHP major versions against which to framework Symfony implemented a safer HTTP client, and
implement our CPG creation. We decided on the, at the time, there are drop-in replacements for safer curl usage in PHP.
most recent PHP 8.2. This will inevitably lead to projects with WordPress attempts to provide a defense but is flawed and
legacy code that are only partially translatable into bytecode, vulnerable to DNS rebinding. Other frameworks supporting
with the files containing the legacy code left out. Using static SSR lack defense capabilities and do not discuss the risks of
analysis potentially reduces the overall amount of analyzed SSRs in their documentation.
and reported SSRF-related data points.
Web developers are not using readily available defenses
Missed Second Order Vulnerabilities We do not con- (RQ2) We discussed the availability of ready-to-be-used safer
sider second-order data flows when performing our manual HTTP clients that defend against certain SSR abuses in Sec-
analysis, as we filter out any flow without attacker control. tion 3.4. However, only a negligible amount of PHP applica-
Second-order vulnerabilities are notoriously challenging to tions on GitHub are using them.
detect [13] and, given the typical usage pattern of SSR, are of Applications are lacking custom defenses (RQ3) Our
minor relevance to our overarching research question. static analysis results, in combination with an in-depth manual
Focus on Common Sinks and Exploits We use popular analysis, showed that proper defense and mitigation attempts
HTTP sinks with protocol-agnostic exploitation patterns as are rare. No application is equipped with DNS validation,
our starting point for the static analysis. This excludes more which is essential for a safe and proper deny-list-based de-
exotic attacks involving technically complex and situational fense against SSR abuses. Only two applications properly
exploitations, e.g., leveraging open_dir via ftp. While those used allow listing.
exploits are technically feasible, they do not represent this State of SSR vulnerabilities in applications (RQ4) Con-
research’s common and focused exploit scenario and should sidering that open-source web application developers are not
be considered for future work. using existing SSR defenses and are not implementing proper
SSR defenses, we conclude that SSR awareness has not ar- PHP Static Analysis Previous work covered information
rived in the mainstream of application developers. flow and taint-style vulnerabilities in PHP applications.
Huang et al. [19] detected vulnerabilities via information
flow analysis in PHP applications and were the first to do
7 Related Work so. Jovanovic et al. [22] proposed a static taint-flow analysis
for PHP applications. Kassar et al. [23, 24] are working on
SSR Studies Previous academic work introduced dynamic pushing the coverage of PHP static analysis tools but over-
scanners to detect vulnerable SSR, Pellegrino et al. [32] pro- look SSRF sinks and vulnerabilities in their work. Backes
posed a black-box testing tool and scanned 68 services. We et al. [9] were the first to leverage code property graphs to
leverage the benefits of static code analysis, enabling us to analyze PHP applications. Alhuzali et al. [6] combined it with
cover all possible code paths without any input except the ap- dynamic analysis to generate exploits more precisely. Shezan
plication itself. This allows us to conduct a large-scale study et al. [35] augmented it with cross-language capabilities to
on 27,078 applications. Jabiyev et al. [21] proposed defenses search for GDPR violations. Our novel PHP code property
against SSRF and benchmarked them against known SSRF graph converter, written against the modern CPG standard
vulnerabilities. Musch et al. [28] studied the prevalence and [48], works on the CFG provided by PHP itself, making it
security implications of Server-Side-Browsers as SSR clients. more reliable than the one proposed by Backes et al. [9].
Sahin et al. [33] have conducted a CTF experiment to study
developers’ awareness of different web attack types. SSRF
was exploited the least, showing that it is still an unknown
vulnerability class. Previous work focused on detecting SSR 8 Conclusion
vulnerabilities or defending against them — we are the first
to evaluate existing defenses in the wild. SSRF is a complex and multifaceted vulnerability class, and
our survey of the current state of the art shows that developers
SSR Systematization Pellegrino et al. [32] introduced a must consider multiple attack vectors. However, the exper-
classification of SSRs along the axes of Flaw, Behavior, Con- iments in this paper reveal that developers do not properly
trol, and Target. Additionally, they presented some mitigation defend against SSRF:
techniques they encountered. i) Our analysis of popular PHP frameworks and SSR li-
In contrast, our systematization, presented in section 3, in- braries shows that even if SSR capabilities are offered, de-
cludes defenses as a first-class citizen. Consequently, attacks fenses in any form are commonly missing or defective. In
are explicitly mapped to suitable defenses. They are classified particular, dedicated defenses against SSRF are either broken
as full, partial, or allow-list only protections. Additionally, we (WordPress) or are simply not used by the vast majority of
systematized known defense evasion techniques and linked PHP applications on GitHub (Symfony, SafeCurl, etc.) – Only
them with our previous efforts. four applications are using existing safe countermeasures, as
Furthermore, our systematization distinguishes between shown by our usage study.
allow listing and deny list cases, which Pellegrino et al. did not ii) As dedicated defensive measures are not used, we
cover. However, this differentiation is essential to a complete investigated if homegrown countermeasures are implemented
understanding of SSR defenses. Some defenses are sufficient instead. For this purpose, we examined 27,078 software
in the allow list case, e.g., complete URL validation is an projects sourced from GitHub using our CPG-based tool
adequate host validation. At the same time, more technical S URFER and a subsequent rigorous manual analysis. Our
effort and knowledge are required in the deny list case, i.e., investigation into the resulting flows and deployed defenses
DNS Rebinding protection is needed. revealed that only two applications employ their own safe
Additionally, while our systematization contains the attacks allow-list defense. Furthermore, we did not find any secure
from Pellegrino et al., it presents a current and updated picture. deny-list defense since protection against DNS rebinding was
It includes recent developments; for example, it encompasses absent in all cases.
the new attack surface of browsers as HTTP clients [28].
Additionally, we split the Probe class into the more suited In a somber conclusion, our results show that, while being
Port scan and Network scan categories to better reflect the comparatively infrequent, SSRF is widespread in the applica-
impact of different defense techniques. ble subset of software projects: Almost all applications that
Therefore, our defense-encompassing systematization can might be susceptible to SSRF due to their application logic
be used by both researchers and practitioners. Security re- (i.e., they utilize at least one functionality that requires the
searchers can easily classify their potential findings alongside retrieval of external HTTP resources based on user input) are
existing mitigations using our systematization. Similarly, de- indeed vulnerable to such attacks. Hence, our results suggest
velopers can leverage it to check if their implementation is that developers either are unaware of SSRF’s dangers or are
vulnerable and are provided with better options. unwilling/unable to implement effective defenses.
Acknowledgments //docs.aws.amazon.com/AWSEC2/latest/UserGu
ide/ec2-instance-metadata.html, March 2022.
We are thankful for the valuable feedback of our anonymous
reviewers and shepherd. This work has received funding from [8] Arr0way. SSRF Cheat Sheet & Bypass Techniques .
the European Union’s Horizon 2020 research and innova- Online https://highon.coffee/blog/ssrf-cheat
tion programme under project TESTABLE, grant agreement -sheet/, 2021.
No 101019206. Additionally, it was funded by the Deutsche
Forschungsgemeinschaft (DFG, German Research Founda- [9] Michael Backes, Konrad Rieck, Malte Skoruppa, Ben
tion) under Germany’s Excellence Strategy — EXC 2092 Stock, and Fabian Yamaguchi. Efficient and flexible
CASA — 390781972. discovery of php application vulnerabilities. In 2017
IEEE European Symposium on Security and Privacy
(EuroS&P), pages 334–349. IEEE, 2017.
Availability
[10] Jérémy Benoist. Server-Side Request Forgery (SSRF)
Our tooling is available as open-source software at https: protection plugin for HTTPlug. Online https://gith
//github.com/SSRF-vs-Developers. ub.com/j0k3r/httplug-ssrf-plugin, July 2022.
We contacted the developers of affected repositories that were [12] DigitalOcean, LLC. How to access droplet metadata.
not deprecated or archived. We preferred the contact informa- Online https://docs.digitalocean.com/produc
tion from security policies to disclose the issues responsibly. ts/droplets/how-to/retrieve-droplet-metad
If no security policy was present, we filed issues asking for ata, March 2022.
their preferred way of disclosure or tried to contact the devel-
opers via email. [13] Benjamin Eriksson, Giancarlo Pellegrino, and Andrei
Sabelfeld. Black widow: Blackbox data-driven web
scanning. In 42nd IEEE Symposium on Security and
References Privacy, SP 2021, San Francisco, CA, USA, 24-27 May
2021, pages 1125–1142. IEEE, 2021. doi: 10.1109/SP
[1] Cve-2016-4029. Online https://www.cve.org/CVER
40001.2021.00022. URL https://doi.org/10.110
ecord?id=CVE-2016-4029, 2016. visited 2023-06-02.
9/SP40001.2021.00022.
[2] Cve-2021-21973. Online https://www.cve.org/CV
[14] fin1te. SafeCurl: SSRF Protection, and a "Capture the
ERecord?id=CVE-2021-21973, 2021. visited 2023-
Bitcoins". Online https://whitton.io/articles/
06-02.
safecurl-ssrf-protection-and-a-capture-the
[3] Cve-2021-26855. Online https://www.cve.org/CV -bitcoins/, May 2014.
ERecord?id=CVE-2021-26855, 2021.
[15] Andrew Gallant. ripgrep (rg). Online https://gith
[4] NVD - CVE-2023-43654. Online https://nvd.nist ub.com/BurntSushi/ripgrep, 2021.
.gov/vuln/detail/CVE-2023-43654, 2023.
[16] Google. Subscribe to someone’s Google Calendar -
[5] Alfred V Aho, Ravi Sethi, and Jeffrey D Ullman. Computer - Google Calendar Help. Online https:
Compilerbau, Teil 2, Compilerbau. Oldenbourg Wis- //support.google.com/calendar/answer/37100,
senschaftsverlag, 2016. 2023.
[6] Abeer Alhuzali, Rigel Gjomemo, Birhanu Eshete, and [17] Josh Grunzweig, Matthew Meltzer, Sean Koessel,
V.N. Venkatakrishnan. NAVEX: Precise and scalable Steven Adair, and Thomas Lancaster. Operation ex-
exploit generation for dynamic web applications. In change marauder: Active exploitation of multiple zero-
27th USENIX Security Symposium (USENIX Security day microsoft exchange vulnerabilities. Online https:
18), pages 377–392. USENIX Association, August 2018. //www.volexity.com/blog/2021/03/02/active-e
ISBN 978-1-939133-04-5. URL https://www.usen xploitation-of-microsoft-exchange-zero-day
ix.org/conference/usenixsecurity18/present -vulnerabilities/, 2021. visited 2023-06-02.
ation/alhuzali.
[18] Tarunkant Gupta. Blog on Gopherus Tool. Online
[7] Amazon Web Services, Inc. Instance metadata and user https://tarunkant.github.io/2018/08/14/201
data - amazon elastic compute cloud. Online https: 8-08-14-blog-on-gopherus/index.html, 2018.
[19] Yao-Wen Huang, Fang Yu, Christian Hang, Chung-Hung [27] mozilla.org contributors. Content-Disposition - HTTP
Tsai, Der-Tsai Lee, and Sy-Yen Kuo. Securing web ap- | MDN. Online https://developer.mozilla.org/
plication code by static analysis and runtime protection. en-US/docs/Web/HTTP/Headers/Content-Dispo
In Proceedings of the 13th international conference on sition, 2023.
World Wide Web, WWW 2004, WWW ’04, pages 40–
[28] Marius Musch, Robin Kirchner, Max Boll, and Martin
52. Association for Computing Machinery, 2004. doi:
Johns. Server-Side Browsers: Exploring the Web’s Hid-
10.1145/988672.988679.
den Attack Surface. In Proc. of the 17th ACM Asia
[20] IncludeSec team. Introducing: SafeURL – A set of Conference on Computer and Communications Security
SSRF Protection Libraries. Online https://blog.i (AsiaCCS’22), May 2022.
ncludesecurity.com/2016/08/introducing-saf
[29] Ivan Novikov. SSRF bible. Cheatsheet. Online https:
eurl-a-set-of-ssrf-protection-libraries/,
//cheatsheetseries.owasp.org/assets/Server
2016.
_Side_Request_Forgery_Prevention_Cheat_She
[21] Bahruz Jabiyev, Omid Mirzaei, Amin Kharraz, and En- et_SSRF_Bible.pdf, Jan 2017.
gin Kirda. Preventing server-side request forgery at- [30] OWASP Contributors. Server Side Request Forgery
tacks. In Proceedings of the 36th Annual ACM Sym- Prevention - OWASP Cheat Sheet Series. Online https:
posium on Applied Computing, SAC ’21, pages 1626– //cheatsheetseries.owasp.org/cheatsheets/S
1635. Association for Computing Machinery, 2021. doi: erver_Side_Request_Forgery_Prevention_Chea
10.1145/3412841.3442036. t_Sheet.html, 2022.
[22] Nenad Jovanovic, Christopher Kruegel, and Engin Kirda. [31] OWASP Top 10 team. A10:2021 – server-side request
Static analysis for detecting taint-style vulnerabilities in forgery (SSRF). Online https://owasp.org/Top10/
web applications. Journal of Computer Security, 18(5): A10_2021-Server-Side_Request_Forgery_(SSRF
861–907, August 2010. doi: http://dx.doi.org/10.3233/J )/, September 2021.
CS-2009-0385.
[32] Giancarlo Pellegrino, Onur Catakoglu, Davide
[23] Feras Al Kassar, Giulia Clerici, Luca Compagna, Davide Balzarotti, and Christian Rossow. Uses and abuses of
Balzarotti, and Fabian Yamaguchi. Testability tarpits: server-side requests. In Research in Attacks, Intrusions,
the impact of code patterns on the security testing of web and Defenses - 18th International Symposium, RAID
applications. In 29th Annual Network and Distributed 2016, January 2016.
System Security Symposium, NDSS 2022, San Diego,
California, USA, April 24-28, 2022. The Internet Society, [33] Merve Sahin, Tolga Ünlü, Cédric Hébert, Lynsay A.
2022. URL https://www.ndss-symposium.org/n Shepherd, Natalie Coull, and Colin Mc Lean. Measur-
dss-paper/auto-draft-206/. ing Developers’ Web Security Awareness from Attack
and Defense Perspectives. In 2022 IEEE Security and
[24] Feras Al Kassar, Luca Compagna, and Davide Balzarotti. Privacy Workshops (SPW), pages 31–43, 2022. doi:
WHIP: improving static vulnerability detection in 10.1109/SPW54247.2022.9833858.
web application by forcing tools to collaborate. In
Joseph A. Calandrino and Carmela Troncoso, editors, [34] sbani. New Option ‘pin_base_uri‘ to Prevent Potential
32nd USENIX Security Symposium, USENIX Security SSRF · Issue #2859 · guzzle/guzzle. Online https://
2023, Anaheim, CA, USA, August 9-11, 2023. USENIX github.com/guzzle/guzzle/issues/2859, 2021.
Association, 2023. URL https://www.usenix.org [35] Faysal Hossain Shezan, Zihao Su, Mingqing Kang,
/conference/usenixsecurity23/presentation/ Nicholas Phair, Patrick William Thomas, Michelangelo
al-kassar. van Dam, Yinzhi Cao, and Yuan Tian. CHKPLUG:
Checking GDPR Compliance of WordPress Plugins via
[25] Vickie Li. Bypassing SSRF Protection. Online https:
Cross-language Code Property Graph. In NDSS, 2023.
//vickieli.medium.com/bypassing-ssrf-prote
ction-e111ae70727b, 2019. visited 2023-06-02. [36] Giada Stivala and Giancarlo Pellegrino. Deceptive pre-
views: A study of the link preview trustworthiness in so-
[26] Colm MacCarthaigh. Add defense in depth against open
cial platforms. In 27th Annual Network and Distributed
firewalls, reverse proxies, and SSRF vulnerabilities with
System Security symposium, February 2020. URL
enhancements to the EC2 Instance Metadata Service.
https://publications.cispa.saarland/3029/.
Online https://aws.amazon.com/de/blogs/secu
rity/defense-in-depth-open-firewalls-rever [37] Symfony. HTTP Client (Symfony Docs). Online https:
se-proxies-ssrf-vulnerabilities-ec2-insta //symfony.com/doc/current/http_client.html,
nce-metadata-service/, 2019. 2023.
[38] Symfony. New in Symfony 5.1: Server-side request Appendix
forgery protection (Symfony Blog). Online https:
//symfony.com/blog/new-in-symfony-5-1-ser 8.1 List of Supported PHP SSR sinks
ver-side-request-forgery-protection, 2023.
We compiled PHP functions that can trigger HTTP requests in
[39] Laurence Tennant. Mitigating SSRF in 2023. Online default configurations. We included the popular ‘curl’ exten-
https://blog.includesecurity.com/2023/03/m sion. We amended the list with request sinks from WordPress,
itigating-ssrf-in-2023/, 2023. since it is the most-used PHP framework. Please note that
get_headers performs a GET and not a HEAD request.
[40] The MITRE Corporation. 2021 CWE top 25 most dan- We chose not to include sinks in this work that re-
gerous software weaknesses. Online https://cwe.mi quire a configuration change to trigger an SSR, e.g., if
tre.org/data/definitions/1387.html, 2021. allow_url_include is set to true, the include and require
[41] The PHP Group. PHP: Deprecated Features - Manual. functions of PHP are able to trigger network requests. We
Online https://www.php.net/manual/en/migrat include file_get_contents due to a similar reasoning. It
ion80.deprecated.php#migration80.deprecate requires allow_url_fopen to be set to true – which is the
d.libxml, 2020. default.
However, since our methodology is general, the list can be
[42] The PHP Group. PHP: cURL. Online https://www. easily modified to broaden the scope of sinks.
php.net/manual/en/book.curl.php, 2024.
• file_get_contents
[43] The PHP HTTP group. HTTPlug. Online https:
//httplug.io/, 2023. • curl_init
A.1 Abstract A recent Linux system with docker and git installed.
Our toolchains are docker-based. We will provide recent We will use one of the repositories from our dataset to show
toolchain versions in the GitHub organization at https: the functionality. For the sake of demonstration, instead of
//github.com/PHP-CPG. However, for the purpose of this using a productive application as an analysis subject, we use
artifact evaluation, we created dockerfiles that pin the versions. a publicly available PHP reverse shell, which we found in our
To build these, clone their repository: https://github.com/ dataset and classified as a ‘hacking tool’4 .
SSRF-vs-Developers/CpgGeneration. We provide scripts E1 addresses C1, and E2 addresses C2, respectively.
that create (build and test) these docker containers. Change (E1): [∼ 1 compute-minute + < 100 MB disk]: Creating a
the directory to their folders and run them in this order: CPG from a project: We fetch the source code and create
a CPG. Additionally, this runs S URFER on the created
1. CPG/resources/docker/PHP-StringPatched/create.sh CPG.
Preparation: Install docker, wget, and a tool to unpack
2. CPG/resources/docker/multilayer-php-cpg/create.sh zip files, e.g., unzip.
How to: First, cd into the ‘in’ folder: ‘surfer/ba-
3. ExperimentRunner/template/create.sh sictestfiles/in’. Then download and extract https:
//github.com/ivan-sincek/php-reverse-shell/
Each dockerfile will build the toolchain, including pulling archive/refs/tags/v2.6.zip.
dependencies and running test cases. We, finally, build our Execution: Rerun the command from A.3.2:
tool S URFER by running the following commands: ./surfer_docker_run.sh ./basictestfiles/in/
./basictestfiles/cpg ./basictestfiles/out
• Clone https://github.com/SSRF-vs-Developers/ Results: Cd into the ‘basictestfiles/cpg‘ folder and ob-
surfer serve that a .cpg file was created. Optionally: Load
it into joern5 via ‘joern file.cpg’ and run queries, e.g.,
• cd resources/docker ‘cpg.call.size’. If using dockererized joern:
docker run --rm -it -v / tmp :/ tmp -v
• ./create.sh $( pwd ) :/ app : rw -w / app -t ghcr . io
/ joernio / joern : nightly joern / app
/ file . cpg
A.3.2 Basic Test
joern > cpg . call . size
The repositories ships with the most basic SSRF (E2): [S URFER] [1 min]: The previous experiment also ran
example to test the pipeline. Run this command: S URFER automatically. Navigate to the ‘out’ folder and
./surfer_docker_run.sh ./basictestfiles/in/ confirm that a JSON file with the project’s name was
./basictestfiles/cpg ./basictestfiles/out created. It should have 2 SSRF candidate flows under
This creates a cpg in the cpg folder. Additionally, a testpro- the ‘candidates’ key. Each candidate contains a reversed
ject.json file is created in the out folder. This JSON contains string. Additionally, .dot files are created to visualize the
one candidate: slice through our CPG.