Lune

NDSS2023Top-tier venue

DiffCSP: Finding Browser Bugs in Content Security Policy Enforcement through Differential Testing

Seongil Wi, Trung Tin Nguyen, Jihwan Kim, Ben Stock, Sooel Son

Abstract

—The Content Security Policy (CSP) is one of the de facto security mechanisms that mitigate web threats. Many websites have been deploying CSPs mainly to mitigate cross-site scripting (XSS) attacks by instructing client browsers to constrain JavaScript (JS) execution. However, a browser bug in CSP enforcement enables an adversary to bypass a deployed CSP, posing a security threat. As the CSP specification evolves, CSP becomes more complicated in supporting an increasing number of directives, which brings additional complexity to implementing correct enforcement behaviors. Unfortunately, the finding of CSP enforcement bugs in a systematic way has been largely understudied. In this paper, we propose DiffCSP, the first differential testing framework to find CSP enforcement bugs involving JS execution. DiffCSP generates CSPs and a comprehensive set of HTML instances that exhibit all known ways of executing JS snippets. DiffCSP then executes each HTML instance for each generated policy across different browsers, thereby collecting inconsistent execution results. To analyze a large volume of the execution results, we leverage a decision tree and identify common causes of the observed inconsistencies. We demonstrate the efficacy of DiffCSP by finding 29 security bugs and eight functional bugs. We also show that three bugs are due to unclear descriptions of the CSP specification. We further identify the common root causes of CSP enforcement bugs, such as incorrect CSP inheritance and hash handling. We confirm the risky trend of client browsers deriving completely different interpretations from the same CSPs, which raises security concerns. Our study demonstrates the effectiveness of DiffCSP for identifying CSP enforcement bugs, and our findings have contributed to patching 12 security bugs in major browsers, including Chrome and Safari.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

11 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • BUIzz: Finding Policy Enforcement Bugs via Interaction Simulation on the Browser User Interface cites How the Web Tangled Itself: Uncovering the History of Client-Side Web (In)Security
  • BUIzz: Finding Policy Enforcement Bugs via Interaction Simulation on the Browser User Interface cites Skyfire: Data-Driven Seed Generation for Fuzzing
  • BUIzz: Finding Policy Enforcement Bugs via Interaction Simulation on the Browser User Interface cites Content Security Problems?: Evaluating the Effectiveness of Content Security Policy in the Wild
  • BUIzz: Finding Policy Enforcement Bugs via Interaction Simulation on the Browser User Interface cites Web Platform Threats: Automated Detection of Web Security Issues With WPT
  • BUIzz: Finding Policy Enforcement Bugs via Interaction Simulation on the Browser User Interface cites CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy
  • Parse Me, Baby, One More Time: Bypassing HTML Sanitizer via Parsing Differentials cites How the Web Tangled Itself: Uncovering the History of Client-Side Web (In)Security
  • Parse Me, Baby, One More Time: Bypassing HTML Sanitizer via Parsing Differentials cites Content Security Problems?: Evaluating the Effectiveness of Content Security Policy in the Wild
  • Parse Me, Baby, One More Time: Bypassing HTML Sanitizer via Parsing Differentials cites CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy
  • Rise of Inspectron: Automated Black-box Auditing of Cross-platform Electron Apps cites Content Security Problems?: Evaluating the Effectiveness of Content Security Policy in the Wild
  • MatriXSSed: A New Taxonomy for XSS in the Modern Web cites CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security Policy
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers11

  1. Parse Me, Baby, One More Time: Bypassing HTML Sanitizer via Parsing DifferentialsDavid Klein, Martin JohnsS&P 2024 · 7 citations
  2. Web Platform Threats: Automated Detection of Web Security Issues With WPTPedro Bernardo, Lorenzo Veronese, Valentino Dalla Valle, Stefano Calzavara et al.USENIX Security 2024 · 6 citations
  3. Rise of Inspectron: Automated Black-box Auditing of Cross-platform Electron AppsMir Masood Ali, Mohammad Ghasemisharif, Chris Kanich, Jason PolakisUSENIX Security 2024 · 2 citations
  4. MatriXSSed: A New Taxonomy for XSS in the Modern WebDolière Francis SoméWWW 2025 · 2 citations
  5. BUIzz: Finding Policy Enforcement Bugs via Interaction Simulation on the Browser User InterfaceMingi Jung, Donggyu Kim, Mijung Kim, Seongil WiUSENIX Security 2026

Builds on16

  1. Skyfire: Data-Driven Seed Generation for FuzzingJunjie Wang, Bihuan Chen, Lei Wei, Yang LiuS&P 2017 · 382 citations
  2. CSP Is Dead, Long Live CSP! On the Insecurity of Whitelists and the Future of Content Security PolicyLukas Weichselbaum, Michele Spagnuolo, Sebastian Lekies, Artur JancCCS 2016 · 114 citations
  3. Content Security Problems?: Evaluating the Effectiveness of Content Security Policy in the WildStefano Calzavara, Alvise Rabitti, Michele BugliesiCCS 2016 · 71 citations
  4. How the Web Tangled Itself: Uncovering the History of Client-Side Web (In)SecurityBen Stock, Martin Johns, Marius Steffens, Michael BackesUSENIX Security 2017 · 67 citations
  5. CSPAutoGen: Black-box Enforcement of Content Security Policy upon Real-world WebsitesXiang Pan, Yinzhi Cao, Shuangping Liu, Yu Zhou et al.CCS 2016 · 55 citations

Related papers

  1. A Bug's Life: Analyzing the Lifecycle and Mitigation Process of Content Security Policy BugsGertjan Franken, Tom van Goethem, Lieven Desmet, Wouter JoosenUSENIX Security 2023
  2. A Tale of Two Headers: A Formal Analysis of Inconsistent Click-Jacking Protection on the WebStefano Calzavara, Sebastian Roth, Alvise Rabitti, Michael Backes et al.USENIX Security 2020
  3. CCSP: Controlled Relaxation of Content Security Policies by Runtime Policy CompositionStefano Calzavara, Alvise Rabitti, Michele BugliesiUSENIX Security 2017 · 15 citations
  4. Head(er)s Up! Detecting Security Header Inconsistencies in BrowsersJannis Rautenstrauch, Trung Tin Nguyen, Karthik Ramakrishnan, Ben StockCCS 2025
  5. 12 Angry Developers - A Qualitative Study on Developers' Struggles with CSPSebastian Roth, Lea Gröber, Michael Backes, Katharina Krombholz et al.CCS 2021 · 22 citations
Dusk over the sea between two cliffs drawn in fine vertical lines