Change search
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf
CSPeare: Content Security Policy generation using the Playwright browser automation library
Blekinge Institute of Technology, Faculty of Computing, Department of Software Engineering.
2025 (English)Independent thesis Basic level (degree of Bachelor), 10 credits / 15 HE creditsStudent thesis
Abstract [en]

Background. Cross-site scripting (XSS) has been a significant security risk to web applications for many years. Content Security Policy (CSP) can defend against XSS by limiting what sources a website can load scripts and other types of content from; however, many websites either do not implement it or use it insecurely, partly due to CSP's perceived complexity.

Objectives. This thesis investigates the effectiveness of using browser automation to generate CSP that can mitigate stored and reflected XSS by automating the generation and evaluation of CSP rules with a simple command-line tool. The tool requires only a regular development environment and operates in a non-invasive manner that does not require modifications to website code to be useful.

Methods. Following a Design Science Research methodology, a program, CSPeare, is developed. It uses the Playwright browser automation library and Google's CSP Evaluator library to detect website requirements, generate suitable CSP rules, and provide both feedback on the rules' strength as well as recommendations on how the tested website can be changed to allow for stricter rules. The tool is empirically evaluated using both constructed test sites and real-world websites, analyzing both the effectiveness of the generated CSP as well as whether website functionality is preserved. 

Results. The tool successfully generated CSP mitigating reflected and stored XSS in a number of websites without breaking website functionality, providing relevant recommendations where applicable. However, the findings also reveal trade-offs between security and usability in cases where inline scripts and dynamic content prevent effective CSP.

Conclusions. The study provides empirical insights into automated CSP generation. CSPeare shows that browser automation can effectively aid in the creation of CSP rules, lowering the barrier to adoption of CSP, although its non-invasive approach limits what it can do and precludes the use of strict CSP. Future work could explore more complex scenarios, such as interactive web applications, combining CSPeare's approach with more invasive methods to make more restrictive rules possible, and cover more types of XSS.

Place, publisher, year, edition, pages
2025. , p. 35
Keywords [en]
Content Security Policy, CSP, Cross-Site Scripting, XSS, web application security
National Category
Software Engineering
Identifiers
URN: urn:nbn:se:bth-27471OAI: oai:DiVA.org:bth-27471DiVA, id: diva2:1938872
Subject / course
PA1445 Kandidatkurs i Programvaruteknik
Supervisors
Examiners
Available from: 2025-02-24 Created: 2025-02-19 Last updated: 2025-09-30Bibliographically approved

Open Access in DiVA

fulltext(716 kB)186 downloads
File information
File name FULLTEXT01.pdfFile size 716 kBChecksum SHA-512
ab1951a06cb93db59c400e744d90f82260543760868182fc6050c312c86f6a3f7e3294c624e9bffd23578c89a8bac743c21ee047cca352f524b7615af3041061
Type fulltextMimetype application/pdf

By organisation
Department of Software Engineering
Software Engineering

Search outside of DiVA

GoogleGoogle Scholar
Total: 188 downloads
The number of downloads is the sum of all downloads of full texts. It may include eg previous versions that are now no longer available

urn-nbn

Altmetric score

urn-nbn
Total: 392 hits
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf