skip to main content
10.1145/3133956.3134091acmconferencesArticle/Chapter ViewAbstractPublication PagesccsConference Proceedingsconference-collections
research-article
Open access

Code-Reuse Attacks for the Web: Breaking Cross-Site Scripting Mitigations via Script Gadgets

Authors:
Sebastian Lekies
Google, Zürich, Switzerland
,
Krzysztof Kotowicz
Google, Zürich, Switzerland
,
Samuel Groß
SAP, Karlsruhe, Germany
,
Eduardo A. Vela Nava
Google, Zürich, Switzerland
,
Martin Johns
SAP, Karlsruhe, Germany
Authors Info & Claims
Published: 30 October 2017 Publication History

Abstract

Cross-Site Scripting (XSS) is an unremitting problem for the Web. Since its initial public documentation in 2000 until now, XSS has been continuously on top of the vulnerability statistics. Even though there has been a considerable amount of research and developer education to address XSS on the source code level, the overall number of discovered XSS problems remains high. Because of this, various approaches to mitigate XSS have been proposed as a second line of defense, with HTML sanitizers, Web Application Firewalls, browser-based XSS filters, and the Content Security Policy being some prominent examples. Most of these mechanisms focus on script tags and event handlers, either by removing them from user-provided content or by preventing their script code from executing.
In this paper, we demonstrate that this approach is no longer sufficient for modern applications: We describe a novel Web attack that can circumvent all of theses currently existing XSS mitigation techniques. In this attack, the attacker abuses so called script gadgets (legitimate JavaScript fragments within an application's legitimate code base) to execute JavaScript. In most cases, these gadgets utilize DOM selectors to interact with elements in the Web document. Through an initial injection point, the attacker can inject benign-looking HTML elements which are ignored by these mitigation techniques but match the selector of the gadget. This way, the attacker can hijack the input of a gadget and cause processing of his input, which in turn leads to code execution of attacker-controlled values. We demonstrate that these gadgets are omnipresent in almost all modern JavaScript frameworks and present an empirical study showing the prevalence of script gadgets in productive code. As a result, we assume most mitigation techniques in web applications written today can be bypassed.

Supplemental Material

MP4 File

References

[1]
Acker, S. V., Hausknecht, D., and Sabelfeld, A. Data Exfiltration in the Face of CSP. In AsiaCCS (2016).
[2]
Athanasopoulos, E., Pappas, V., Krithinakis, A., Ligouras, S., Markatos, E. P., and Karagiannis, T. xjs: practical xss prevention for web application development. In Proceedings of the 2010 USENIX conference on Web application development (2010), USENIX Association, pp. 13--13.
[3]
Bates, D., Barth, A., and Jackson, C. Regular expressions considered harmful in client-side XSS filters. In WWW '10: Proceedings of the 19th international conference on World wide web (New York, NY, USA, 2010), ACM, pp. 91--100.
[4]
Calzavara, S., Rabitti, A., and Bugliesi, M. Content security problems?: Evaluating the effectiveness of content security policy in the wild. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (New York, NY, USA, 2016), CCS '16, ACM, pp. 1365--1375.
[5]
CERT/CC. CERT Advisory CA-2000-02 Malicious HTML Tags Embedded in Client Web Requests. [online], http://www.cert.org/advisories/CA-2000-02.html (01/30/06), February 2000.
[6]
Chen, E. Y., Gorbaty, S., Singhal, A., and Jackson, C. Self-exfiltration: The dangers of browser-enforced information flow control. In Proceedings of the Workshop of Web (2012), vol. 2, Citeseer.
[7]
Gundy, M. V., and Chen, H. Noncespaces: Using Randomization to Enforce Information Flow Tracking and Thwart Cross-site Scripting Attacks. In 16th Annual Network and Distributed System Security Symposium (NDSS 2009) (2009).
[8]
Heiderich, M. Towards Elimination of XSS Attacks with a Trusted and Capability Controlled DOM. PhD thesis, Ruhr-University Bochum, 2012.
[9]
Heiderich, M. Jsmvcomfg - to sternly look at javascript mvc and templating frameworks. [online], https://www.slideshare.net/x00mario/jsmvcomfg-to-sternly-look-at-javascript-mvc-and-templating-frameworks, 2013.
[10]
Heiderich, M. Mustache security wiki. [online], https://github.com/cure53/mustache-security, 2014.
[11]
Heiderich, M., Niemietz, M., Schuster, F., Holz, T., and Schwenk, J. Scriptless attacks: stealing the pie without touching the sill. In Proceedings of the 2012 ACM conference on Computer and communications security (2012), ACM, pp. 760--771.
[12]
Heiderich, M., Schwenk, J., Frosch, T., Magazinius, J., and Yang, E. Z. mxss attacks: Attacking well-secured web-applications by using innerhtml mutations. In Proceedings of the 2013 ACM SIGSAC conference on Computer & communications security (2013), ACM, pp. 777--788.
[13]
Hickson, I. The iframe element, November 2013.
[14]
Jim, T., Swamy, N., and Hicks, M. Defeating script injection attacks with browserenforced embedded policies. In Proceedings of the 16th international conference on World Wide Web (2007), ACM, pp. 601--610.
[15]
Kern, C. Securing the tangled web. Communications of the ACM 57, 9 (2014), 38--47.
[16]
Klein, A. Dom based cross site scripting or xss of the third kind. Web Application Security Consortium, Articles 4 (2005), 365--372.
[17]
Lekies, S., Stock, B., and Johns, M. 25 Million Flows Later - Large-scale Detection of DOM-based XSS. In Proceedings of the 20th ACM Conference on Computer and Communication Security (CCS '13) (2013).
[18]
Louw, M. T., and Venkatakrishnan, V. BluePrint: Robust Prevention of Crosssite Scripting Attacks for Existing Browsers. In IEEE Symposium on Security and Privacy (Oakland'09) (May 2009).
[19]
Maone, G. Noscript, 2009.
[20]
MSDN. toStaticHTML method. [API], https://msdn.microsoft.com/library/Cc848922.
[21]
Nadji, Y., Saxena, P., and Song, D. Document Structure Integrity: A Robust Basis for Cross-site Scripting Defense. In Network & Distributed System Security Symposium (NDSS 2009) (2009).
[22]
Nava, E. A. V. Fighting XSS with Isolated Scripts. [online], http://sirdarckcat.blogspot.de/2017/01/fighting-xss-with-isolated-scripts.html, January 2017.
[23]
Nava, E. V., and Lindsay, D. Our favorite XSS filters/IDS and how to attack them. Presentation at the BlackHat US conference, 2009.
[24]
Oda, T., Wurster, G., van Oorschot, P. C., and Somayaji, A. Soma: Mutual approval for included content in web pages. In Proceedings of the 15th ACM conference on Computer and communications security (2008), ACM, pp. 89--98.
[25]
Pan, X., Cao, Y., Liu, S., Zhou, Y., Chen, Y., and Zhou, T. Cspautogen: Black-box enforcement of content security policy upon real-world websites. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (New York, NY, USA, 2016), CCS '16, ACM, pp. 653--665.
[26]
Parameshwaran, I., Budianto, E., Shinde, S., Dang, H., Sadhu, A., and Saxena, P. Auto-patching dom-based xss at scale. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (New York, NY, USA, 2015), ACM, pp. 272--283.
[27]
Roemer, R., Buchanan, E., Shacham, H., and Savage, S. Return-oriented programming: Systems, languages, and applications. ACM Trans. Info. & System Security 15, 1 (Mar. 2012).
[28]
Ross, D. Ie 8 xss filter architecture/implementation. Blog: http://blogs.technet.com/srd/archive/2008/08/18/ie-8-xss-filter-architecture-implementation.aspx (2008).
[29]
Ross, D. Happy 10th birthday cross-site scripting! [online], https://blogs.msdn.microsoft.com/dross/2009/12/15/happy-10th-birthday-cross-site-scripting/, 2009.
[30]
Stamm, S., Sterne, B., and Markham, G. Reining in the web with content security policy. In Proceedings of the 19th international conference on World wide web (2010), ACM, pp. 921--930.
[31]
Stamm, S., Sterne, B., and Markham, G. Reining in the web with content security policy. In Proceedings of the 19th international conference on World wide web (New York, NY, USA, 2010), WWW '10, ACM, pp. 921--930.
[32]
Stock, B., Lekies, S., Mueller, T., Spiegel, P., and Johns, M. Precise Client-side Protection against DOM-based Cross-Site Scripting. In 23rd USENIX Security Symposium (USENIX Security '14) (2014).
[33]
Tantek Celik, Daniel Glazman, I. H. P. L. J. W. Selectors level 4. W3C Editor's Draft (2017).
[34]
W3C. Content Content Security Policy Level 3. W3C Editor's Draft, 10 May 2017, https://w3c.github.io/webappsec-csp/, May 2017.
[35]
Weichselbaum, L., Spagnuolo, M., Lekies, S., and Janc, A. Csp is dead, long live csp! on the insecurity of whitelists and the future of content security policy. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (2016), ACM, pp. 1376--1387.
[36]
Weinberger, J., Akhawe, D., and Eisinger, J. Suborigins. W3C Editor's Draft, 18 May 2017, https://w3c.github.io/webappsec-suborigins/, May 2017.
[37]
Zalewski, M. Postcards from the post-xss world. Online at http://lcamtuf.coredump.cx/postxss (2011).

Cited By

View all
  • (2024)Unveiling the Invisible: Detection and Evaluation of Prototype Pollution Gadgets with Dynamic Taint AnalysisProceedings of the ACM Web Conference 202410.1145/3589334.3645579(1800-1811)Online publication date: 13-May-2024
  • (2024)The Great Request Robbery: An Empirical Study of Client-side Request Hijacking Vulnerabilities on the Web2024 IEEE Symposium on Security and Privacy (SP)10.1109/SP54263.2024.00098(166-184)Online publication date: 19-May-2024
  • (2024)Twenty-two years since revealing cross-site scripting attacksComputer Science Review10.1016/j.cosrev.2024.10063452:COnline publication date: 18-Jul-2024
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
CCS '17: Proceedings of the 2017 ACM SIGSAC Conference on Computer and Communications Security
October 2017
2682 pages
ISBN:9781450349468
DOI:10.1145/3133956
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike International 4.0 License.

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 30 October 2017

Check for updates

Author Tags

  1. content security policy
  2. waf
  3. web application security
  4. xss
  5. xss filters
  6. xss mitigations

Qualifiers

  • Research-article

Conference

CCS '17
Sponsor:

Acceptance Rates

CCS '17 Paper Acceptance Rate 151 of 836 submissions, 18%;
Overall Acceptance Rate 1,261 of 6,999 submissions, 18%

Upcoming Conference

CCS '25

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)375
  • Downloads (Last 6 weeks)61
Reflects downloads up to 23 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Unveiling the Invisible: Detection and Evaluation of Prototype Pollution Gadgets with Dynamic Taint AnalysisProceedings of the ACM Web Conference 202410.1145/3589334.3645579(1800-1811)Online publication date: 13-May-2024
  • (2024)The Great Request Robbery: An Empirical Study of Client-side Request Hijacking Vulnerabilities on the Web2024 IEEE Symposium on Security and Privacy (SP)10.1109/SP54263.2024.00098(166-184)Online publication date: 19-May-2024
  • (2024)Twenty-two years since revealing cross-site scripting attacksComputer Science Review10.1016/j.cosrev.2024.10063452:COnline publication date: 18-Jul-2024
  • (2023)Silent springProceedings of the 32nd USENIX Conference on Security Symposium10.5555/3620237.3620546(5521-5538)Online publication date: 9-Aug-2023
  • (2023)Honey, I Cached our Security Tokens Re-usage of Security Tokens in the WildProceedings of the 26th International Symposium on Research in Attacks, Intrusions and Defenses10.1145/3607199.3607223(714-726)Online publication date: 16-Oct-2023
  • (2023)It’s (DOM) Clobbering Time: Attack Techniques, Prevalence, and Defenses2023 IEEE Symposium on Security and Privacy (SP)10.1109/SP46215.2023.10179403(1041-1058)Online publication date: May-2023
  • (2023)ODDFuzz: Discovering Java Deserialization Vulnerabilities via Structure-Aware Directed Greybox Fuzzing2023 IEEE Symposium on Security and Privacy (SP)10.1109/SP46215.2023.10179377(2726-2743)Online publication date: May-2023
  • (2023)Scaling JavaScript Abstract Interpretation to Detect and Exploit Node.js Taint-style Vulnerability2023 IEEE Symposium on Security and Privacy (SP)10.1109/SP46215.2023.10179352(1059-1076)Online publication date: May-2023
  • (2023)The Nonce-nce of Web Security: An Investigation of CSP Nonces ReuseComputer Security. ESORICS 2023 International Workshops10.1007/978-3-031-54129-2_27(459-475)Online publication date: 25-Sep-2023
  • (2022)A Survey on an Investigation of Detection & Prevention Methods for Cross-Site Scripting (XSS) AttacksInternational Journal of Advanced Research in Science, Communication and Technology10.48175/IJARSCT-2553(405-413)Online publication date: 20-Feb-2022
  • Show More Cited By

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media

References

References

[1]
Acker, S. V., Hausknecht, D., and Sabelfeld, A. Data Exfiltration in the Face of CSP. In AsiaCCS (2016).
[2]
Athanasopoulos, E., Pappas, V., Krithinakis, A., Ligouras, S., Markatos, E. P., and Karagiannis, T. xjs: practical xss prevention for web application development. In Proceedings of the 2010 USENIX conference on Web application development (2010), USENIX Association, pp. 13--13.
[3]
Bates, D., Barth, A., and Jackson, C. Regular expressions considered harmful in client-side XSS filters. In WWW '10: Proceedings of the 19th international conference on World wide web (New York, NY, USA, 2010), ACM, pp. 91--100.
[4]
Calzavara, S., Rabitti, A., and Bugliesi, M. Content security problems?: Evaluating the effectiveness of content security policy in the wild. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (New York, NY, USA, 2016), CCS '16, ACM, pp. 1365--1375.
[5]
CERT/CC. CERT Advisory CA-2000-02 Malicious HTML Tags Embedded in Client Web Requests. [online], http://www.cert.org/advisories/CA-2000-02.html (01/30/06), February 2000.
[6]
Chen, E. Y., Gorbaty, S., Singhal, A., and Jackson, C. Self-exfiltration: The dangers of browser-enforced information flow control. In Proceedings of the Workshop of Web (2012), vol. 2, Citeseer.
[7]
Gundy, M. V., and Chen, H. Noncespaces: Using Randomization to Enforce Information Flow Tracking and Thwart Cross-site Scripting Attacks. In 16th Annual Network and Distributed System Security Symposium (NDSS 2009) (2009).
[8]
Heiderich, M. Towards Elimination of XSS Attacks with a Trusted and Capability Controlled DOM. PhD thesis, Ruhr-University Bochum, 2012.
[9]
Heiderich, M. Jsmvcomfg - to sternly look at javascript mvc and templating frameworks. [online], https://www.slideshare.net/x00mario/jsmvcomfg-to-sternly-look-at-javascript-mvc-and-templating-frameworks, 2013.
[10]
Heiderich, M. Mustache security wiki. [online], https://github.com/cure53/mustache-security, 2014.
[11]
Heiderich, M., Niemietz, M., Schuster, F., Holz, T., and Schwenk, J. Scriptless attacks: stealing the pie without touching the sill. In Proceedings of the 2012 ACM conference on Computer and communications security (2012), ACM, pp. 760--771.
[12]
Heiderich, M., Schwenk, J., Frosch, T., Magazinius, J., and Yang, E. Z. mxss attacks: Attacking well-secured web-applications by using innerhtml mutations. In Proceedings of the 2013 ACM SIGSAC conference on Computer & communications security (2013), ACM, pp. 777--788.
[13]
Hickson, I. The iframe element, November 2013.
[14]
Jim, T., Swamy, N., and Hicks, M. Defeating script injection attacks with browserenforced embedded policies. In Proceedings of the 16th international conference on World Wide Web (2007), ACM, pp. 601--610.
[15]
Kern, C. Securing the tangled web. Communications of the ACM 57, 9 (2014), 38--47.
[16]
Klein, A. Dom based cross site scripting or xss of the third kind. Web Application Security Consortium, Articles 4 (2005), 365--372.
[17]
Lekies, S., Stock, B., and Johns, M. 25 Million Flows Later - Large-scale Detection of DOM-based XSS. In Proceedings of the 20th ACM Conference on Computer and Communication Security (CCS '13) (2013).
[18]
Louw, M. T., and Venkatakrishnan, V. BluePrint: Robust Prevention of Crosssite Scripting Attacks for Existing Browsers. In IEEE Symposium on Security and Privacy (Oakland'09) (May 2009).
[19]
Maone, G. Noscript, 2009.
[20]
MSDN. toStaticHTML method. [API], https://msdn.microsoft.com/library/Cc848922.
[21]
Nadji, Y., Saxena, P., and Song, D. Document Structure Integrity: A Robust Basis for Cross-site Scripting Defense. In Network & Distributed System Security Symposium (NDSS 2009) (2009).
[22]
Nava, E. A. V. Fighting XSS with Isolated Scripts. [online], http://sirdarckcat.blogspot.de/2017/01/fighting-xss-with-isolated-scripts.html, January 2017.
[23]
Nava, E. V., and Lindsay, D. Our favorite XSS filters/IDS and how to attack them. Presentation at the BlackHat US conference, 2009.
[24]
Oda, T., Wurster, G., van Oorschot, P. C., and Somayaji, A. Soma: Mutual approval for included content in web pages. In Proceedings of the 15th ACM conference on Computer and communications security (2008), ACM, pp. 89--98.
[25]
Pan, X., Cao, Y., Liu, S., Zhou, Y., Chen, Y., and Zhou, T. Cspautogen: Black-box enforcement of content security policy upon real-world websites. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (New York, NY, USA, 2016), CCS '16, ACM, pp. 653--665.
[26]
Parameshwaran, I., Budianto, E., Shinde, S., Dang, H., Sadhu, A., and Saxena, P. Auto-patching dom-based xss at scale. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (New York, NY, USA, 2015), ACM, pp. 272--283.
[27]
Roemer, R., Buchanan, E., Shacham, H., and Savage, S. Return-oriented programming: Systems, languages, and applications. ACM Trans. Info. & System Security 15, 1 (Mar. 2012).
[28]
Ross, D. Ie 8 xss filter architecture/implementation. Blog: http://blogs.technet.com/srd/archive/2008/08/18/ie-8-xss-filter-architecture-implementation.aspx (2008).
[29]
Ross, D. Happy 10th birthday cross-site scripting! [online], https://blogs.msdn.microsoft.com/dross/2009/12/15/happy-10th-birthday-cross-site-scripting/, 2009.
[30]
Stamm, S., Sterne, B., and Markham, G. Reining in the web with content security policy. In Proceedings of the 19th international conference on World wide web (2010), ACM, pp. 921--930.
[31]
Stamm, S., Sterne, B., and Markham, G. Reining in the web with content security policy. In Proceedings of the 19th international conference on World wide web (New York, NY, USA, 2010), WWW '10, ACM, pp. 921--930.
[32]
Stock, B., Lekies, S., Mueller, T., Spiegel, P., and Johns, M. Precise Client-side Protection against DOM-based Cross-Site Scripting. In 23rd USENIX Security Symposium (USENIX Security '14) (2014).
[33]
Tantek Celik, Daniel Glazman, I. H. P. L. J. W. Selectors level 4. W3C Editor's Draft (2017).
[34]
W3C. Content Content Security Policy Level 3. W3C Editor's Draft, 10 May 2017, https://w3c.github.io/webappsec-csp/, May 2017.
[35]
Weichselbaum, L., Spagnuolo, M., Lekies, S., and Janc, A. Csp is dead, long live csp! on the insecurity of whitelists and the future of content security policy. In Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security (2016), ACM, pp. 1376--1387.
[36]
Weinberger, J., Akhawe, D., and Eisinger, J. Suborigins. W3C Editor's Draft, 18 May 2017, https://w3c.github.io/webappsec-suborigins/, May 2017.
[37]
Zalewski, M. Postcards from the post-xss world. Online at http://lcamtuf.coredump.cx/postxss (2011).