Skip to main content
Log in

XSnare: application-specific client-side cross-site scripting protection

  • Published:
Empirical Software Engineering Aims and scope Submit manuscript

Abstract

We present XSnare, a client-side Cross-Site Scripting (XSS) solution implemented as a Firefox extension. The client-side design of XSnare can protect users before application developers release patches and before server operators apply them. XSnare blocks XSS attacks by using previous knowledge of a web application’s HTML template content and the rich DOM context. XSnare uses a database of exploit descriptions, which are written with the help of previously recorded CVEs. It singles out injection points for exploits in the HTML and dynamically sanitizes content to prevent malicious payloads from appearing in the DOM. XSnare displays a secured version of the site, even if is exploited. We evaluated XSnare on 81 recent CVEs related to XSS attacks, and found that it defends against 93.8% of these exploits. We compared XSnare’s funcitonality and protection with two well known content filtering extensions: NoScript and uBlockOrigin. To the best of our knowledge, XSnare is the first protection mechanism for XSS that is application-specific, and based on publicly available CVE information. We show that XSnare’s specificity protects users against exploits which evade other, more generic, XSS defenses. Our performance evaluation shows that our extension’s overhead on web page loading time is less than 10% for 72.6% of the sites in the Moz Top 500 list. We also show that XSnare has as a slowdown of less than 10% on 60% of the vulnerable sites that we considered. XSnare has a false positive rate of 1/4876 (0.0205%) on the Alexa top 5000 sites.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Algorithm 1
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15
Fig. 16

Similar content being viewed by others

Data Availability

The datasets for this paper, including the XSnare artifact, are available from the corresponding author on reasonable request.

Notes

  1. As early as 2012, JavaScript was used by almost 100% of the Alexa top 500 sites (Stock et al. 2017)

  2. https://www.cvedetails.com/cve/CVE-2018-5213/

  3. https://github.com/cure53/DOMPurify/tree/main/demos#what-is-this

  4. In these cases, the signature developer can weigh the trade-offs and decide whether the added cost is worth it.

  5. https://gist.github.com/chilts/7229605

  6. https://www.cvedetails.com/cve/CVE-2018-5213/

  7. This image was taken from the w3 spec: https://www.w3.org/TR/navigation-timing-2/

  8. The Spearman’s correlation coefficient measures the strength and direction of association between two ranked variables: https://statistics.laerd.com/statistical-guides/spearmans-rank-order-correlation-statistical-guide.php

  9. There are 15,303 CVEs related to XSS in CVE Details (xss 2020).

  10. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/filterResponseData

  11. https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API

  12. https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType

References

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Ivan Beschastnikh.

Ethics declarations

The three authors do not have any conflicts of interest with regard to this publication. This research did not involve any human participants.

Additional information

Communicated by: Rick Kazman, Marouane Kessentini, Yuanfang Cai.

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

This article belongs to the Topical Collection: Software Analysis, Evolution and Reengineering (SANER)

Appendix A Signature Language Description

Appendix A Signature Language Description

We now provide further description of our signature language. We implement a signature as a key-value JavaScript object. Each of the fields details an aspect of the signature’s behaviour. Table 4 describes this.

Table 4 XSnare Language Description
Table 5 Additional fields for listenerData when a type of ‘listener’ has been specified in a signature

If the value of type in Table 4 is ‘listener’, the signature will have an additional field called listenerData, which acts as a nested signature with fields that identify a particular dynamic request. A developer can optionally specify the request’s injection points using this nested signature. Table 5 describes this sub-signature format.

Rights and permissions

Springer Nature or its licensor (e.g. a society or other partner) holds exclusive rights to this article under a publishing agreement with the author(s) or other rightsholder(s); author self-archiving of the accepted manuscript version of this article is solely governed by the terms of such publishing agreement and applicable law.

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Pazos, J.C., Légaré, JS. & Beschastnikh, I. XSnare: application-specific client-side cross-site scripting protection. Empir Software Eng 28, 110 (2023). https://doi.org/10.1007/s10664-023-10323-w

Download citation

  • Accepted:

  • Published:

  • DOI: https://doi.org/10.1007/s10664-023-10323-w

Keywords

Navigation