Chrome extension content script blocked on pages with CSP 'strict-dynamic' — programmatic injection appears successful but inline script execution is refused
Environment
Chrome 117 on Windows 10, extension using Manifest V3 and chrome.scripting.executeScript to inject code into third-party pages. Target pages send a strict Content-Security-Policy header containing 'script-src' with 'strict-dynamic' and nonces.
Symptoms
chrome.scripting.executeScript calls succeed, but scripts that inject inline script tags or write <script> elements into the page DOM fail silently; console shows 'Refused to execute inline script because of Content-Security-Policy' for the injected code. Extension-hosted resources (chrome-extension://) are not authorized by the page CSP.
Observations
Content scripts run in an isolated world and can access the DOM, but any attempt to add inline script textContent or to inject a script tag that executes page-context JS is blocked by the page's CSP strict-dynamic policy unless the script carries a valid nonce or hash. Network-fetched scripts from https: with relevant trust can be allowed, but extension URLs and blob URLs are typically not considered trusted by strict-dynamic.
Already attempted
Tried creating script tags with textContent via content script, tried injecting external script URLs, attempted earlier-style chrome.tabs.executeScript approaches. Also attempted messaging from service worker to content script to have content script insert DOM script; CSP still blocked inline page-executable script.
Question
How can my extension run necessary code on pages protected by strict-dynamic CSP? What are safe, supported patterns to interact with page JavaScript without violating CSP?
Verified community troubleshooting
No answers yet..
Incident analysis
Most likely causes
Summary
Suggested Fixes
Continue troubleshooting
Related troubles
Matched from the title, description and tags