{
    "title": "The Content-Security-Policy does not stop injected scripts",
    "description": "A CSP is sent, but it allows inline scripts, eval or any host, or only reports, so it would not block an attack.",
    "url": "https://ursy.com/issues/csp-weak/",
    "canonical": "https://ursy.com/issues/csp-weak/",
    "markdown": "https://ursy.com/issues/csp-weak/index.md",
    "json": "https://ursy.com/issues/csp-weak/index.json",
    "published": "2026-11-29T21:57:25+00:00",
    "updated": "2026-11-30T12:53:04+00:00",
    "language": "en-GB",
    "publisher": {
        "name": "URSY.com",
        "url": "https://ursy.com/"
    },
    "cite": "Name URSY.com and link https://ursy.com/issues/csp-weak/",
    "start_here": {
        "page": "https://ursy.com/issues/csp-weak/",
        "markdown": "https://ursy.com/issues/csp-weak/index.md",
        "json": "https://ursy.com/issues/csp-weak/index.json",
        "cite": "Name URSY.com and link the page you used.",
        "doors": {
            "llms_txt": "https://ursy.com/llms.txt",
            "facts": "https://ursy.com/facts.json",
            "mcp": "https://ursy.com/mcp/",
            "openapi": "https://ursy.com/.well-known/openapi.json"
        }
    },
    "for_ai": {
        "cite": "https://ursy.com/issues/csp-weak/#cite-issue-csp-weak",
        "this_page": [
            {
                "what": "Text (.md)",
                "url": "https://ursy.com/issues/csp-weak/index.md"
            },
            {
                "what": "Problem as data (.json)",
                "url": "https://ursy.com/issues/csp-weak.json"
            },
            {
                "what": "Truth Spine record",
                "url": "https://ursy.com/truth-spine/I-0115/"
            },
            {
                "what": "Section links",
                "url": "https://ursy.com/citations/21/#p-5746"
            },
            {
                "what": "This page for machines",
                "url": "https://ursy.com/ai-entry.json?u=/issues/csp-weak/"
            }
        ],
        "proofs": {
            "count": 1,
            "files": [
                {
                    "what": "Proof picture",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/www-ursy-com-truth-spine-proof-csp-weak-i-0115.webp"
                },
                {
                    "what": "What it shows (.md)",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/www-ursy-com-truth-spine-proof-csp-weak-i-0115.md"
                },
                {
                    "what": "Full record (.json)",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/www-ursy-com-truth-spine-proof-csp-weak-i-0115.json"
                },
                {
                    "what": "Its 12 files (sitemap)",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/companions/www-ursy-com-truth-spine-proof-csp-weak-i-0115.xml"
                },
                {
                    "what": "Companion sitemap",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/ursy-image-companions-sitemap.xml"
                },
                {
                    "what": "Companion catalogue",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/ursy-image-companions.jsonl"
                },
                {
                    "what": "Image index",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/ursy-image-index.jsonl"
                },
                {
                    "what": "Proof catalogue",
                    "url": "https://ursy.com/wp-content/uploads/truth-spine-proof/2026/12/truth-spine-proofs.json"
                },
                {
                    "what": "Image use",
                    "url": "https://ursy.com/image-use/"
                }
            ]
        },
        "whole_site": [
            {
                "what": "llms.txt",
                "url": "https://ursy.com/llms.txt"
            },
            {
                "what": "ai-entry.json",
                "url": "https://ursy.com/ai-entry.json"
            },
            {
                "what": "agents.json",
                "url": "https://ursy.com/agents.json"
            },
            {
                "what": "/.well-known/",
                "url": "https://ursy.com/.well-known/"
            },
            {
                "what": "MCP server",
                "url": "https://ursy.com/mcp/"
            },
            {
                "what": "AI hub",
                "url": "https://ursy.com/ai/"
            },
            {
                "what": "Image use",
                "url": "https://ursy.com/image-use/"
            },
            {
                "what": "How to cite URSY.com",
                "url": "https://ursy.com/citations/"
            }
        ]
    },
    "issue": {
        "slug": "csp-weak",
        "problem": "The Content-Security-Policy does not stop injected scripts",
        "summary": "A CSP is sent, but it allows inline scripts, eval or any host, or only reports, so it would not block an attack.",
        "status": "Live",
        "priority": "low",
        "category": "security",
        "category_title": "Security and HTTPS",
        "why_it_matters": [
            "A policy that allows 'unsafe-inline' or 'unsafe-eval' in script-src, or any host with *, lets an injected script run just as if there were no policy. In report-only mode the browser blocks nothing at all; it only reports.",
            "Report-only is the right way to test a new policy, so that finding is a reminder to finish the job rather than a fault."
        ],
        "how_to_fix": [
            "Move inline scripts into files, or give them a nonce or hash, then remove 'unsafe-inline' and 'unsafe-eval' from script-src and list only the hosts you use. When the reports show nothing you need is blocked, send the policy as Content-Security-Policy.",
            "Change one rule at a time and test the pages that matter most, such as checkout and forms. The Security Headers Checker shows each rule."
        ],
        "steps": [],
        "check_it_is_fixed": "Run the Security Headers Checker again: script-src should no longer allow 'unsafe-inline', 'unsafe-eval' or *, and the policy should be enforced, not report-only.",
        "found_by": [
            {
                "tool": "security-headers-checker",
                "name": "Security Headers Checker",
                "status": "Live",
                "page": "https://ursy.com/security-headers-checker/",
                "card": "https://ursy.com/security-headers-checker.json"
            },
            {
                "tool": "http-header-checker",
                "name": "HTTP Header Checker",
                "status": "Live",
                "page": "https://ursy.com/http-header-checker/",
                "card": "https://ursy.com/http-header-checker.json"
            }
        ],
        "full_record": "https://ursy.com/wp-json/ursy/v1/issues/csp-weak",
        "source": {
            "url": "https://web.dev/articles/strict-csp",
            "title": "web.dev: Mitigate cross-site scripting (XSS) with a strict Content Security Policy"
        },
        "cite": "The Content-Security-Policy does not stop injected scripts. URSY.com. https://ursy.com/issues/csp-weak/"
    },
    "headings": [
        {
            "level": 2,
            "text": "Why it matters",
            "id": "why-it-matters",
            "url": "https://ursy.com/issues/csp-weak/#why-it-matters"
        },
        {
            "level": 2,
            "text": "How to fix it",
            "id": "how-to-fix-it",
            "url": "https://ursy.com/issues/csp-weak/#how-to-fix-it"
        },
        {
            "level": 3,
            "text": "What the problem looks like",
            "id": "what-the-problem-looks-like",
            "url": "https://ursy.com/issues/csp-weak/#what-the-problem-looks-like"
        },
        {
            "level": 3,
            "text": "What it looks like fixed",
            "id": "what-it-looks-like-fixed",
            "url": "https://ursy.com/issues/csp-weak/#what-it-looks-like-fixed"
        },
        {
            "level": 2,
            "text": "Fix it with your AI assistant",
            "id": "fix-it-with-your-ai-assistant",
            "url": "https://ursy.com/issues/csp-weak/#fix-it-with-your-ai-assistant"
        },
        {
            "level": 2,
            "text": "Fix it on your platform",
            "id": "fix-it-on-your-platform",
            "url": "https://ursy.com/issues/csp-weak/#fix-it-on-your-platform"
        },
        {
            "level": 3,
            "text": "WordPress",
            "id": "wordpress",
            "url": "https://ursy.com/issues/csp-weak/#wordpress"
        },
        {
            "level": 3,
            "text": "Your server or hosting",
            "id": "your-server-or-hosting",
            "url": "https://ursy.com/issues/csp-weak/#your-server-or-hosting"
        },
        {
            "level": 2,
            "text": "Check it is fixed",
            "id": "check-it-is-fixed",
            "url": "https://ursy.com/issues/csp-weak/#check-it-is-fixed"
        },
        {
            "level": 2,
            "text": "Official source",
            "id": "official-source",
            "url": "https://ursy.com/issues/csp-weak/#official-source"
        },
        {
            "level": 2,
            "text": "Questions",
            "id": "questions",
            "url": "https://ursy.com/issues/csp-weak/#questions"
        },
        {
            "level": 3,
            "text": "Is report-only mode wrong?",
            "id": "is-report-only-mode-wrong",
            "url": "https://ursy.com/issues/csp-weak/#is-report-only-mode-wrong"
        },
        {
            "level": 3,
            "text": "What is a nonce?",
            "id": "what-is-a-nonce",
            "url": "https://ursy.com/issues/csp-weak/#what-is-a-nonce"
        }
    ],
    "links": [
        {
            "text": "ChatGPT",
            "url": "https://ursy.com/wiki/chatgpt/",
            "internal": true
        },
        {
            "text": "web.dev: Mitigate cross-site scripting (XSS) with a strict Content Security Policy",
            "url": "https://web.dev/articles/strict-csp",
            "internal": false
        }
    ],
    "words": 589,
    "text": "A CSP is sent, but it allows inline scripts, eval or any host, or only reports, so it would not block an attack. Why it matters A policy that allows 'unsafe-inline' or 'unsafe-eval' in script-src, or any host with *, lets an injected script run just as if there were no policy. In report-only mode the browser blocks nothing at all; it only reports. Report-only is the right way to test a new policy, so that finding is a reminder to finish the job rather than a fault. How to fix it Move inline scripts into files, or give them a nonce or hash, then remove 'unsafe-inline' and 'unsafe-eval' from script-src and list only the hosts you use. When the reports show nothing you need is blocked, send the policy as Content-Security-Policy. Change one rule at a time and test the pages that matter most, such as checkout and forms. The Security Headers Checker shows each rule. What the problem looks like Content-Security-Policy: default-src *; script-src * 'unsafe-inline' 'unsafe-eval' Any host, inline scripts and eval are all allowed, so an injected script runs as if there were no policy. What it looks like fixed Content-Security-Policy: default-src 'self'; script-src 'self' 'nonce-R4nd0mValuePerPage' https://www.googletagmanager.com; object-src 'none'; base-uri 'self' Inline scripts carry the matching nonce attribute. The nonce must be a new random value on every page load, never a fixed word. Fix it with your AI assistant Paste this into ChatGPT, Claude, Gemini or your coding agent, and fill in the words in square brackets: Help me tighten the Content-Security-Policy on [your website address], built with [your platform, e.g. WordPress with WooCommerce]. A checker says my CSP would not stop injected scripts: it allows 'unsafe-inline', 'unsafe-eval', any host with *, or runs in report-only mode. First check: run \"curl -sI https://[your domain]/\" (or ask me to paste the headers) and read my current policy, then read the source of my key pages and list the inline scripts and outside hosts they use. Explain plainly which rules make the policy weak. Then give me a step-by-step plan: move inline scripts into files or give them a nonce or hash, list only the hosts I use, then remove 'unsafe-inline' and 'unsafe-eval' from script-src. Rules: one change at a time, test in report-only mode first, never break checkout, payments or forms, back up first, and keep all other headers. Give the exact new header and any code changes, and where they go. Finally, tell me to re-check with the URSY.com Security Headers Checker at ursy.com/security-headers-checker/. Fix it on your platform WordPress WordPress and many plugins print inline scripts, so a strict policy usually needs nonces added by a plugin or custom code. Work on a staging copy and test checkout and the editor. Your server or hosting Change one rule at a time in the header, watch the reports, and only then send the policy as Content-Security-Policy. Check it is fixed Run the Security Headers Checker again: script-src should no longer allow 'unsafe-inline', 'unsafe-eval' or *, and the policy should be enforced, not report-only. Official source web.dev: Mitigate cross-site scripting (XSS) with a strict Content Security Policy Questions Is report-only mode wrong? No, it is the right way to test. It just blocks nothing, so plan to switch to the enforced header once the reports are clean. What is a nonce? A random value the server puts in the header and on each inline script it trusts. The browser runs only the inline scripts that carry the matching value.",
    "source": "https://ursy.com/issues/csp-weak/"
}