Extension weakens its Content-Security-Policy

The extension's content_security_policy loosens the default protections, permitting inline scripts, eval or remote scripts inside the extension's own pages.

Do this: Uninstall it; a weakened CSP undoes the browser's protection. A relaxed extension CSP re-enables exactly the script execution Manifest V3 was designed to stop.
PassThe extension keeps the default Content-Security-Policy.
MediumThe extension weakens its Content-Security-Policy.

The fix, in one snippet

Example to adapt What a safe one looks like
"content_security_policy": { "extension_pages": "script-src 'self'; object-src 'none'" }

Illustrative values. Change the paths, hostnames and options to match your own site before using it.

The sections below explain what is tested, why it matters and the alternatives.

What we test

The analyser reads content_security_policy: a string in Manifest V2, an object with extension_pages and sandbox keys in Manifest V3. It flags 'unsafe-eval' in extension pages (forbidden in MV3; 'wasm-unsafe-eval' is allowed), 'unsafe-inline' for scripts (ignored by browsers but a sign of intent), any remote host in script-src or object-src (MV2 permitted specific HTTPS hosts; MV3 permits none), a missing object-src 'self', and a sandbox policy that admits remote scripts. The offending directive is quoted. Limits: browsers enforce a minimum policy and refuse to load an MV3 extension with an invalid one, so a weak CSP in a store-installed extension usually means it is MV2; sideloaded packages are checked less strictly.

Why it matters

The popup, options and background pages run with the extension's full permissions. The default policy, script-src 'self'; object-src 'self', means only packaged code can run there. If the developer adds 'unsafe-eval' or a remote host, any injection into those pages, for example rendering a tab title or a fetched string with innerHTML, becomes code that runs with the extension's cookie, tab and host access. That is cross-site scripting at extension privilege, and it is the reason Manifest V3 removed the ability to relax the policy.

How to fix it

Users: prefer Manifest V3 extensions, whose policy cannot be weakened. If an MV2 extension whitelists remote script hosts, weigh whether you need it.

Developers: omit the content_security_policy key unless you need a sandbox. Never add 'unsafe-eval' to extension_pages; put libraries that require it in a sandboxed page and communicate with postMessage. Use textContent rather than innerHTML for untrusted strings.

"content_security_policy": {
  "extension_pages": "script-src 'self'; object-src 'self'",
  "sandbox": "sandbox allow-scripts; script-src 'self' 'unsafe-eval'"
}

Related: remote code and, for websites, the CSP check. Guides: the practical CSP guide and are browser extensions safe?

Where this fits

Extension weakens its Content-Security-Policy is check 7 of 9 that the browser extension analyzer runs under extension permissions and behaviour, ordered the way they are worth fixing. That ordering is the point: Fixing this one while the check above it still fails buys less than it looks like.

Fix this one first

Above it in the same category sits Extension contacts external endpoints (medium), where the extension's code contains addresses of external servers it communicates with, so some of your data or activity may leave the browser. An attacker who has that does not need this, so it is the better use of the same hour.

What fixing this still leaves open

Extension weakens its Content-Security-Policy closes one route in. Immediately below it: Extension uses Manifest V2, where the extension still declares manifest_version 2, a format Chrome no longer runs and that lacks the stricter code and policy rules of Manifest V3; Extension declares optional permissions, where the extension declares optional permissions or optional host permissions that it can request later at runtime.

Prompt for an AI Hand this check to an assistant Sign in to copy it
The first few lines
You are a senior web engineer. I ran a security and SEO scanner against my site and it reported the finding below. Fix it properly rather than suppressing the symptom.

Finding: Extension weakens its Content-Security-Policy (medium severity)
Scanner check id: extension-weak-csp
17 more lines, including the evidence and the exact fix

The rest of this prompt names the pages and line numbers we found the problem on, the configuration to change, and the constraints a good answer has to respect. It is free, it just needs an account so the work is not scraped wholesale.

Sign in with Google

Signing in is free and takes one click. We store your email address and nothing else.

References

  1. Chrome: Manifest content_security_policy
  2. Chrome: Manifest sandbox
  3. MDN: Content Security Policy for extensions

Related guides