skip to main content
10.1145/3320269.3372201acmconferencesArticle/Chapter ViewBasic AbstractPublication Pagesasia-ccsConference Proceedingsconference-collections
Several features on this page require Premium Access.
You are using the Basic Edition. Features requiring a subscription appear in grey.
research-article
Free access

Assessing the Impact of Script Gadgets on CSP at Scale

Published: 05 October 2020 Publication History

Abstract

The Web, as one of the core technologies of modern society, has profoundly changed the way we interact with people and data. One of the worst attacks on the Web is Cross-Site Scripting (XSS), in which an attacker is able to inject their malicious JavaScript code into a Web application, giving this code full access to the victimized site. To mitigate the impact of markup injection flaws that cause XSS, support for the Content Security Policy (CSP) is nowadays shipped in all browsers. Deploying such a policy enables a Web developer to whitelist from where script code can be loaded, essentially constraining the capabilities of the attacker to only be able to execute injected code from the said whitelist. As recently shown by Lekies et al., injecting script markup is not a necessary prerequisite for a successful attack in the presence of so-called script gadgets. These small snippets of benign JavaScript code transform non-script markup contained in a page into executable JavaScript, opening the door for bypasses of a deployed CSP. Especially in combination with CSP's logic in handling redirected resources, script gadgets enable attackers to bypass an otherwise secure policy. In this paper, we, therefore, ask the question: is securely deploying CSP even possible without a priori knowledge of all files hosted on even a partially trusted origin? To answer this question, we investigate the severity of the findings of Lekies et al., showing real-world Web sites on which, even in the presence of CSP and without code containing such gadgets being added by the developer, an attacker can sideload libraries with known script gadgets, as long as the hosting site is whitelisted in the CSP. In combination with CSPs matching logic for redirects, this enables us to bypass 10% of otherwise secure policies in the wild. To further answer our main research question, we conduct a hypothetical what-if analysis. Doing so, we automatically generate sensible CSPs for all of the Top 10,000 sites and show that around one-third of all sites would still be susceptible to a bypass through script gadget sideloading due to heavy reliance on third parties that also host such libraries.

Formats available

You can view the full content in the following formats:

Supplementary Material

MP4 File (3320269.3372201.mp4)
The Web, as one of the core technologies of modern society, has profoundly changed the way we interact with people and data. One of the worst attacks on the Web is XSS, in which an attacker is able to inject their malicious JavaScript code into a Web application, giving this code full access to the victimized site.\r\nTo mitigate the impact of markup injection flaws that cause XSS, support for the CSP is nowadays shipped in all browsers.\r\nHowever, as recently shown injecting script markup is not a necessary prerequisite for a successful attack in the presence of so-called script gadgets.\r\nIn combination with CSPs logic in handling redirected resources, script gadgets enable attackers to bypass an otherwise secure policy. In this paper, we, therefore, ask the question: is securely deploying CSP even possible without a priori knowledge of all files hosted on even a partially trusted origin?

References

[1]
A. Barth. RFC 6454. Online at https://www.ietf.org/rfc/rfc6454.txt, 2011.
[2]
T. Berners-Lee, R. Fielding, and H. Frystyk. RFC 1945: Hypertext Transfer Protocol? HTTP/1.0. Online at https://www.ietf.org/rfc/rfc1945.txt, 1996.
[3]
S. Calzavara, Alvise Rabitti, and Michele Bugliesi. Content security problems?: Evaluating the effectiveness of content security policy in the wild. In CCS, 2016.
[4]
S. Calzavara, Alvise Rabitti, and Michele Bugliesi. Semantics-Based Analysis of Content Security Policy Deployment.TWEB, 2018.
[5]
A. Doupé, W. Cui, M. H. Jakubowski, M. Peinado, C. Kruegel, and G. Vigna. deDacota: Toward Preventing Server-Side XSS via Automatic Code and Data Separation. In CCS, 2013.
[6]
GitHub - Google Chrome. Puppeteer.Online at https://github.com/GoogleChrome/puppeteer, 2019.
[7]
D. Hausknecht, J. Magazinius, and A. Sabelfeld. May I?-Content Security Policy Endorsement for Browser Extensions. In DIMVA, 2015.
[8]
E. Homakov. Using Content Security Policy for Evil.Online at http://homakov.blogspot.com/2014/01/using-content-security-policy-for-evil.html, 2014.
[9]
C. Kerschbaumer, S. Stamm, and S. Brunthaler. Injecting CSP for Fun and Security. In ICISSP, 2016.
[10]
D. Kumar, Z. Ma, Z. Durumeric, A. Mirian, J. Mason, A. J. Halderman, and M. Bailey. Security challenges in an increasingly tangled web. In WWW, 2017.
[11]
T. Lauinger, A. Chaabane, S. Arshad, W. Robertson, C. Wilson, and E. Kirda. Thou shalt not depend on me: Analysing the use of outdated javascript libraries on the web. In NDSS, 2017.
[12]
V. Le Pochat, T. Van Goethem, S. Tajalizadehkhoob, M. Korczy'ski, and W. Joosen. Tranco: A Research-Oriented Top Sites Ranking Hardened Against Manipulation. In NDSS, 2019.
[13]
S. Lekies, B. Stock, and M. Johns. 25 million flows later: Large-scale detection of dom-based xss. InCCS, 2013.
[14]
S. Lekies, K. Kotowicz, S. Groß, E. A. Vela Nava, and M. Johns. Code-reuse attacks for the web: Breaking cross-site scripting mitigations via script gadgets. In CCS, 2017.
[15]
W. Melicher, A. Das, M. Sharif, L. Bauer, and L. Jia. Riding out DOMsday: Toward detecting and preventing DOM cross-site scripting. In NDSS, 2018.
[16]
Microsoft Developer. Edge HTML Platform Status. Online at https://tinyurl.com/skxpgsy, 2019.
[17]
E. Oftedal. Retire.js: What you require you must also retire.Online at https://retirejs.github.io/retire.js/, 2018.
[18]
X. Pan, Y. Cao, S. Liu, Y. Zhou, Y. Chen, and T. Zhou. CSP AutoGen: Black-box enforcement of Content Security Policy upon Real-World Websites. In CCS, 2016.
[19]
S. Roth, T. Barron, S. Calzavara, N. Nikiforakis, and B. Stock. Complex security policy? a longitudinal analysis of deployed content security policies. In NDSS, 2020.
[20]
C. A. Shue, A. J. Kalafut, and M. Gupta. Exploitable Redirects on the Web: Identification, Prevalence, and Defense. In WOOT, 2008.
[21]
D. F. Some, N. Bielova, and T. Rezk. On the Content Security Policy Violations due to the Same-Origin Policy. In WWW, 2017.
[22]
S. Stamm, B. Sterne, and G. Markham. Reining in the Web with Content Security Policy. In WWW, 2010.
[23]
S. Van Acker, D. Hausknecht, and A. Sabelfeld. Data Exfiltration in the Face of CSP. In AsiaCCS, 2016.
[24]
W3C. CSP 1.0.Online at https://www.w3.org/TR/CSP1/, 2015.
[25]
W3C. CSP Level 2.Online at https://www.w3.org/TR/CSP2/, 2016.
[26]
W3C. CSP Level 3. Online at https://www.w3.org/TR/CSP3/, 2016.
[27]
L. Weichselbaum, M. Spagnuolo, S. Lekies, and A. Janc. CSP is dead, long live CSP! On the insecurity of whitelists and the future of content security policy. In CCS, 2016.
[28]
M. Weissbacher, T. Lauinger, and W. Robertson. Why is CSP failing? Trends and challenges in CSP adoption. In RAID, 2014.
[29]
WHATWG HTML Standard. The Script Element. Online at https://html.spec.whatwg.org/multipage/scripting.html#the-script-element, 2019.
[30]
WhiteHat Security. 2018 Whitehat Application Security Statistics. Online at https://www.whitehatsec.com/blog/2018-whitehat-app-sec-statistics-report/.

Cited By

View all
  • (2025)In the DOM We Trust: Exploring the Hidden Dangers of Reading from the DOM on the WebProceedings of the 2025 ACM SIGSAC Conference on Computer and Communications Security10.1145/3719027.3765117(3042-3056)Online publication date: 19-Nov-2025
  • (2025){{alert(’CSTI’)}}: Large-Scale Detection of Client-Side Template Injection2025 28th International Symposium on Research in Attacks, Intrusions and Defenses (RAID)10.1109/RAID67961.2025.00057(363-377)Online publication date: 19-Oct-2025
  • (2024)Trust me if you canProceedings of the 33rd USENIX Conference on Security Symposium10.5555/3698900.3699236(6003-6020)Online publication date: 14-Aug-2024
  • Show More Cited By

Index Terms

  1. Assessing the Impact of Script Gadgets on CSP at Scale

    Recommendations

    Comments