Skip to content
DevMarDe
Crawl Audit check 164Crawl AuditSecurity

Cross-site scripting defences: Crawl Audit check 164

Crawl Audit check 164 reads your Content-Security-Policy for unsafe-inline. What XSS is, why output encoding comes first, and how a CSP backs it up.

Zain Kazmi2 min read
On this page
Check
164 of 200
Module
Security & Infrastructure
Group
Server, DNS & File Exposure Security
Impact
High

Short answer: cross-site scripting (XSS) is when an attacker gets their own script to run on your page, usually through something a visitor typed or a link they clicked. The main fix is in your code; a strict Content-Security-Policy is the backup. Check 164 looks at whether your CSP would block inline scripts.

What Crawl Audit checks

  • Pass: a CSP without 'unsafe-inline'.
  • Warning: a CSP that includes 'unsafe-inline'.
  • Warning: no CSP.

The catalogue calls this an input field reflection test, but Crawl Audit sends no test input and never tries an attack. It only reads your CSP header. It also warns on any 'unsafe-inline', even in a policy that uses nonces or hashes, where MDN notes browsers ignore it.

What the sources say

  • OWASP: "Each variable used in the user interface should be passed through an output encoding function." That's the primary defence.
  • OWASP supports CSP "when it is used properly", as a "defense-in-depth technique".
  • MDN: "Developers should avoid 'unsafe-inline', because it defeats much of the purpose of having a CSP."
  • MDN: "If a directive contains nonce or hash expressions, then the unsafe-inline keyword is ignored by browsers."

What to do

  • Use your framework's built-in escaping, and don't bypass it to insert raw HTML from users.
  • Move inline scripts into files, or mark them with nonces or hashes, then drop 'unsafe-inline' from script-src.
  • Roll changes out in report-only mode first (check 149).

On devmarde.com

We don't send a CSP yet, so this check warns for us. Check 149 explains why and where it stands.

Sources

All 200 Crawl Audit checks

See how your site does on every check.

Crawl Audit runs this check and 199 others on your domain. The full report is $7.89, one time. The free check on this site covers 25.