FULL AI ANALYSIS

Chrome extension content script blocked on pages with CSP 'strict-dynamic' — programmatic injection appears successful but inline script execution is refused

Generated Oct 19, 2026, 9:33:36 AM

Analysis summary

Page CSP controls what runs in the page context; content scripts execute in an isolated world and are not subject to the page's script-src restrictions for their own code, but scripts injected into the page's execution context (by inserting script tags) are subject to the page CSP. With 'strict-dynamic', only scripts with a valid nonce/hash or fetched from trusted https: origins run. Extensions cannot add a matching nonce. The recommended pattern: keep your logic in the content script (isolated world) and use a safe bridge to interact with page JS: create a tiny, non-executing DOM element or use window.postMessage to exchange data; if you must run code in page context, use an injected script created by chrome.scripting.executeScript that runs in the isolated world and communicates with page context through custom DOM events or postMessage. Avoid injecting inline scripts into page DOM.

Possible causes

Trying to inject inline script tags into page DOM; these are blocked by strict-dynamic CSP

90%

Confusion between content script isolated world and page execution context

60%

Browser regression in executeScript handling (unlikely with current Chrome stable)

10%

Suggested fixes

1

Diagnostic step 1

Refactor so the extension's logic runs inside the content script (isolated world) and avoids adding inline <script> tags to the page.

2

Diagnostic step 2

If you need to interact with page JS, implement a small messaging bridge: content script injects a minimalist, non-executing marker and uses window.postMessage or CustomEvent to communicate; the page-side code (if present) can respond.

3

Diagnostic step 3

Use chrome.scripting.executeScript to run code in the isolated world and then exchange data through DOM events rather than injecting executable inline scripts.

4

Diagnostic step 4

Test on pages with strict CSP by checking the console for CSP refusal messages and verifying the content script can still manipulate DOM and communicate via postMessage.