=Paper= {{Paper |id=Vol-2217/paper-ruo |storemode=property |title=A Case-Control Study on the Server-Side Bandages Against XSS |pdfUrl=https://ceur-ws.org/Vol-2217/paper-ruo.pdf |volume=Vol-2217 |authors=Jukka Ruohonen,Ville Leppänen |dblpUrl=https://dblp.org/rec/conf/sqamia/RuohonenL18 }} ==A Case-Control Study on the Server-Side Bandages Against XSS== https://ceur-ws.org/Vol-2217/paper-ruo.pdf
                                                                                                                                      17




A Case-Control Study on the Server-Side Bandages
Against XSS
JUKKA RUOHONEN and VILLE LEPPÄNEN, University of Turku

This paper surveys the server-side use of security-related options for protecting websites against cross-site scripting (XSS)
attacks. By using data from a bug bounty platform, the use of these header-based options is approached with a case-control
study that contrasts popular Internet domains against less popular domains that have explicitly been verified to have been
vulnerable to XSS. According to the results based on the analysis of nearly 800 thousand domains, (a) the header-based
security options are only infrequently used. However, (b) the domains known to have been vulnerable to XSS have been much
less likely to use these options compared to popular domains. Furthermore, (c) the options surveyed tend to statistically form
clear latent dimensions, which can be speculated to relate to the effort required to enforce strict security policies for websites.




1.   INTRODUCTION
Cross-site scripting vulnerabilities have continued to frequently appear in the top-rankings of the
most common security bugs in web applications [OWASP 2018]. The essence behind these security
bugs is simple: an attacker injects malicious executable code to a vulnerable website, and a client’s
web browser executes this code during rendering of the website. The consequences for clients may
range from stealing of web cookies and browsing history to phishing and even key logging.
   If time, resources, and talent are all available, the “best strategy for protecting webservers is to write
secure Web applications from scratch” [Stritter et al. 2016]. Combined with the commonplace lack of
time, resources, and talent, the sheer complexity and the chaotic nature of the current Web have
prompted the introduction of many countermeasures against XSS. Most of these are bandages that
merely patch the symptom—the only real remediation against cross-site scripting is arguably proper
input validation. However, as it is deviously difficult to do this in practice [Weinberger et al. 2011],
different remediation solutions have been considered practically on all sides of the current Web [Strit-
ter et al. 2016]. On the infrastructure side, remediation is deep-rooted in the fundamental issues af-
fecting web standards, encryption of hypertext transfer protocol (HTTP) traffic, the global public key
infrastructure, the domain name system, the so-called same-origin policy, and ultimately the whole
client-server paradigm. On the client-side, the mitigation solutions include sandboxes, blacklists, and
different heuristics to profile the execution of JavaScript. On the server-side, the remediation solu-
tions include web application firewalls, algorithmic solutions, and different options that can be set in
HTTP header responses for instructing browsers about intended behavior. Although much of exist-
ing research has focused on the detection and prevention of XSS vulnerabilities with algorithms and
heuristics [Hydara et al. 2015], the header options are noteworthy for a couple of important reasons.
   First, many of these satisfy the desirable property of bandages: these are easy to apply to fix bleed-
ing in existing implementations, and these are recognized by most browsers due to (implicit) stan-


Authors’ addresses: University of Turku, FI-20014 Turun yliopisto, Finland, juanruo@utu.fi, ville.leppanen@utu.fi

Copyright c by the paper’s authors. Copying permitted only for private and academic purposes.
In: Z. Budimac (ed.): Proceedings of the SQAMIA 2018: 7th Workshop of Software Quality, Analysis, Monitoring, Improvement,
and Applications, Novi Sad, Serbia, 27–30.8.2018. Also published online by CEUR Workshop Proceedings (http://ceur-ws.org,
ISSN 1613-0073)
17:2     •    J. Ruohonen and V. Leppänen

dardization [Ross et al. 2013; W3C 2016; 2017]. Second, these have enlarged the scholarly intersection
between web application security research and the increasingly popular large-scale Internet measure-
ment research [Lekies et al. 2013; Tajalizadehkhoob et al. 2017; Vasek et al. 2016; Weissbacher et al.
2014]. This intersection is also the area to which this paper contributes. The contribution stems from
the data used. While numerous studies have collected data based on blacklists and related collections
about domains and websites associated with spam, phishing, and malware [Ruohonen et al. 2016; Ta-
jalizadehkhoob et al. 2017; Vasek et al. 2016], these are only implicitly related to web vulnerabilities.
In contrast, this paper uses data from a so-called bug bounty specialized to the discovery and disclosure
of XSS vulnerabilities in particular. In other words, a part of the data used is explicitly about websites
that have been verified to have been vulnerable to security bugs the headers surveyed are meant to
partially address. Equipped with this improvement to the always difficult ground truth problem, the
paper sets to answer to the following three research questions (RQs):
—RQ1 : How common is the use of HTTP headers for XSS prevention?
—RQ2 : Are different HTTP header fields used in conjunction with other fields designed to mitigate XSS?
—RQ3 : Is there a difference in the use of XSS-related HTTP header fields between popular Internet
 domains and less popular domains that have been vulnerable to XSS according to data from a bug
 bounty?
  To answer to these three questions, the paper proceeds by introducing the materials and methods in
Section 2. The empirical results are presented in Section 3 and further discussed in the final Section 4.

2.     MATERIALS AND METHODS
The following discussion will outline the headers surveyed, the empirical materials, and the methods
used.

2.1    Header Fields
The header fields surveyed are listed in Table I. The listing is not comprehensive; only well-known
fields either explicitly or at least implicitly related to XSS are surveyed. Even with this narrowing of
the scope, it is not easy to demarcate between fields related to cross-site scripting and those not related
to it. In other words: in many attack scenarios, XSS can be used to facilitate other attacks, or cross-site
scripting can be facilitated by other attacks. The header fields surveyed can be further elaborated as
follows:
—The HttpOnly field can be set for cookies to prevent these from being accessible by scripts executed
 by a client’s browser [Ruohonen and Leppänen 2017b]. Setting this flag is generally recommended
 for session cookies in order to mitigate theft of session information via XSS.
—A value nosniff can be set to prevent some browsers from deducing about media types and file
 formats (i.e., MIME types) that do not match the declared Content-Type. The rationale for sniffing
 MIME types relates to the lack of universally accepted meta-data for web content and the common
 occurrence of incorrectly defined types. Unfortunately, this sniffing exposes XSS attacks [Barth et al.
 2009].
—X-Frame-Options are not directly related to XSS per se, although the so-called clickjacking can be
 used in conjunction with XSS, cross-site request forgery (CSRF), and related attacks [Kim and Kim
 2015; Takamatsu and Kono 2014]. The values specified for X-Frame-Options can mitigate some of
 these attacks by either preventing or restricting a client’s browser from displaying web content
 through  and