Content Security Policy Builder: write a CSP from your pages
Pricing
from $10.00 / 1,000 policy built
Content Security Policy Builder: write a CSP from your pages
Reads a site and writes a ready-to-paste starting Content-Security-Policy to deploy as Report-Only first, with hashes for inline scripts, known third-party hosts, and server snippets.
Pricing
from $10.00 / 1,000 policy built
Rating
0.0
(0)
Developer
Red Center Studio
Maintained by CommunityActor stats
0
Bookmarked
1
Total users
0
Monthly active users
20 hours ago
Last modified
Categories
Features
Share
Reads a site and writes a ready-to-paste starting Content-Security-Policy to deploy as Report-Only first, with hashes for inline scripts, known third-party hosts, and server snippets.
What it does
Header checkers grade a Content Security Policy. This Actor writes one. Give it a list of websites. For each site it reads the homepage and then more pages of the same site, one for each kind of address, up to the number you set: pages linked from its menu first, then other links on the homepage, then, if there is still room, pages listed in /sitemap.xml. It returns one row with a ready-to-paste starting policy:
- The origins named in the pages it reads, sorted into the right directive: script-src, style-src, img-src, font-src, connect-src, frame-src, media-src, manifest-src, worker-src and form-action. It reads script, link, img, srcset, picture, video, audio, track, iframe, form, embed, object, base, and the url() and @import rules in inline CSS and in up to 10 same-origin stylesheets. From inline scripts it takes an address for connect-src only when it is written directly in a fetch, XMLHttpRequest open, sendBeacon, WebSocket, EventSource or axios call.
- A SHA-256 hash for each inline script (up to 100 different ones), so you do not need unsafe-inline for scripts. It also counts inline event handlers such as onclick, which need 'unsafe-hashes' (up to 50 hashes) or a small refactor. A warning says when either list is cut short.
- Safe defaults: object-src 'none' (unless a page that was read uses embed or object, in which case their origins are listed instead and a warning asks you to check them), base-uri 'self', frame-ancestors 'self', and upgrade-insecure-requests on https sites.
- Known third-party hosts that static HTML cannot show (see the table below), each marked with what was found on the site.
- The site's current Content-Security-Policy and Report-Only headers, and a list of what the site loads that the current policy would block.
- Snippets for a Cloudflare _headers file, nginx, Apache, netlify.toml and an HTML meta tag.
- Warnings: eval-like code, resources loaded over http on an https site, hosts that might need a wildcard, and more.
Two modes. compatible (default) lists inline scripts by hash and allows 'unsafe-inline' for styles when the site uses inline styles. strict lists inline scripts and style elements by hash, never allows unsafe-inline, and tells you which inline handlers and style attributes to move out of the HTML. An optional report address adds report-uri and report-to.
Why Report-Only first
A policy written from the HTML can only be a starting point. If you enforce it straight away, anything it missed breaks for your visitors. Deploy it as Content-Security-Policy-Report-Only for about a week. The browser then loads everything as before and reports what the policy would have blocked. Fix or allow what is reported, then rename the header to Content-Security-Policy to enforce. Every row ends with this plan, and every snippet uses the Report-Only header name. The one exception is the meta tag, which can only enforce.
Known third-party expansions
When one of these is found as a script, frame or other resource, or its address is written inside an inline script, the hosts it is known to need at run time are added. Each addition appears in expansionsAdded as "added because ..." with the reason. The table is short on purpose and lists only hosts the vendors document.
| Service | Found by | Added |
|---|---|---|
| Google Tag Manager and gtag.js | www.googletagmanager.com | script-src and frame-src googletagmanager.com; connect-src www.google-analytics.com, analytics.google.com, region1.google-analytics.com; img-src googletagmanager.com and google-analytics.com |
| Google Analytics (analytics.js) | www.google-analytics.com | script-src and img-src www.google-analytics.com; the same connect-src hosts |
| Google Fonts | fonts.googleapis.com or fonts.gstatic.com | style-src fonts.googleapis.com; font-src fonts.gstatic.com |
| Stripe.js | js.stripe.com | script-src js.stripe.com; frame-src js.stripe.com and hooks.stripe.com; connect-src api.stripe.com |
| YouTube embeds | www.youtube.com/embed, iframe_api, youtube-nocookie.com/embed | frame-src www.youtube.com and www.youtube-nocookie.com |
| Vimeo embeds | player.vimeo.com | frame-src and script-src player.vimeo.com; img-src i.vimeocdn.com |
| Cloudflare Turnstile | challenges.cloudflare.com | script-src and frame-src challenges.cloudflare.com |
| Google reCAPTCHA | www.google.com/recaptcha, www.gstatic.com/recaptcha | script-src and frame-src for the recaptcha paths on www.google.com, www.gstatic.com and recaptcha.google.com |
| Intercom messenger | widget.intercom.io, js.intercomcdn.com | script, connect, img, font and frame hosts from Intercom's own list; check its guide for your region |
| HubSpot tracking and forms | js.hs-scripts.com, js.hsforms.net, js.hs-analytics.net | connect-src api.hubapi.com, forms.hsforms.com, forms.hubspot.com |
| Hotjar | static.hotjar.com, script.hotjar.com | script, connect, img, font and frame hosts, with the wildcards Hotjar itself recommends |
| Meta Pixel | connect.facebook.net | script-src connect.facebook.net; img-src www.facebook.com; connect-src www.facebook.com and connect.facebook.net |
| jsDelivr, unpkg, cdnjs | cdn.jsdelivr.net, unpkg.com, cdnjs.cloudflare.com | Nothing extra. A warning explains that these hosts serve every package, so pin versions with Subresource Integrity or serve the file yourself |
Who it is for
Site owners, agencies and developers who know they should have a Content Security Policy but do not want to write one by hand, security reviewers who want a first draft to check, and AI agents that need a policy as a tool call.
Input
Run it from the Console, the API, or as an agent tool. Minimal input:
{"sites": ["redcenterstudio.com"]}
Every field is described in the input form. Free to run: you pay only for the policy built you get back.
Output
One row per input item. Rows with status: "ok" are results. Rows with status: "error" explain what went wrong and are never charged. A run summary is stored in the OUTPUT record.
Real output from a live run:
{"status": "ok","inputRef": "https://redcenterstudio.com","auditedAt": "2026-12-05T21:48:49.913Z","site": "https://redcenterstudio.com","pagesRead": 2,"strictness": "compatible","currentPolicy": "frame-ancestors 'self'","currentPolicyReportOnly": null,"currentPolicyBlocks": [],"policy": "Content-Security-Policy: default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests","policyReportOnly": "Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests","directives": {"default-src": ["'self'"],"script-src": ["'self'","'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg='","'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I='","'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ='","'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c='","'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0='","'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0='","'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8='","'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc='","'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co='","'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60='","'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg='","'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='"],"style-src": ["'self'","'unsafe-inline'"],"img-src": ["'self'","data:"],"connect-src": ["'self'"],"object-src": ["'none'"],"base-uri": ["'self'"],"form-action": ["'self'"],"frame-ancestors": ["'self'"]},"inlineScripts": {"count": 12,"hashes": ["'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg='","'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc='","'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ='","'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60='","'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='","'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8='","'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg='","'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0='","'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I='","'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c='","'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co='","'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0='"]},"inlineEventHandlers": 0,"inlineStyles": 47,"unsafeInlineNeeded": true,"expansionsAdded": [],"warnings": ["Many different inline scripts usually means the HTML generates them per page. A hash only matches one exact text, so use a nonce for those."],"snippets": {"cloudflareHeadersFile": "/*\n Content-Security-Policy-Report-Only: default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests","nginx": "add_header Content-Security-Policy-Report-Only \"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests\" always;","apache": "Header always set Content-Security-Policy-Report-Only \"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests\"","netlifyToml": "[[headers]]\n for = \"/*\"\n [headers.values]\n Content-Security-Policy-Report-Only = \"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests\"","htmlMeta": "<!-- A meta tag always enforces: it cannot be Report-Only. frame-ancestors, report-uri and report-to do not work in a meta tag, so they are left out. Test with a header first. -->\n<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'self'; script-src 'self' 'sha256-/aDReTAQHvEjUmWEz8w+2g+emwe9QJjCkVkz6gR+ZJg=' 'sha256-/JL7W434DOf+BR1hMCmV7MzdZCrm5BrTQYgEUlL9m0I=' 'sha256-1dxj2NxRdM48qy5hgGrrhkppVhHs9qiJCfDKQafNcNQ=' 'sha256-6pUD4bKj2gbiBWaQm14KvnBBbFjKzColP0L1/zloE8c=' 'sha256-dV1yD2YPKEWmvKrOwH5ILhof9S3QwwtBY8woQ9WiOX0=' 'sha256-FTGS5SHbnCp9EcZUsGop4kdUgDGr6UVHozQ0WaaOYx0=' 'sha256-IAkXtx+FpVPot5ykBpTumvyDLyuzTPjIA+CQalxAkM8=' 'sha256-LH+G+Jk0QPTlFYRchCPtaEBJn4LvqX8lyiRmY1dkScc=' 'sha256-n0nPi43hIgExAHPInZDLmViO5Vlm6tR2G5YwDR7Z7co=' 'sha256-pI8rdgSRUPP1zJbnn/voH6ZAf+fJWddwsnbpvaEhB60=' 'sha256-raQOI/r9YhZyKQuM5fFsatn755FJe6ByLx4cs7cghKg=' 'sha256-uR+ZdfomG8dL1OQPr4ewAMLm6s/4TiHQ7fh6S4VMt2U='; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; upgrade-insecure-requests\">"},"nextStep": "Deploy the Report-Only header for about a week and watch the browser console for violations, or run again with a report address to collect them. Fix or allow what is reported, then switch the header name to Content-Security-Policy to enforce. Site Watch can separately tell you about domain and certificate expiry and DNS and email record changes; it does not check Content-Security-Policy or other headers: https://redcenterstudio.com/sitewatch/"}
Pricing
Pay per event. No monthly fee. The platform start event is charged automatically by Apify.
| Event | Charged when | Price |
|---|---|---|
Policy built (policy-built) | Charged once for each website that returns a policy row. Error rows are free. | $0.01 per policy built ($10 per 1,000) |
Set a maximum cost per run on the run options. The Actor stops cleanly when the limit is reached and never charges beyond it.
Use with Apify MCP
AI assistants can call this Actor as a tool through the Apify MCP server:
https://mcp.apify.com?tools=bodacious_mistral/csp-builder
Limits
- Static reading cannot see every runtime request. It reads the HTML and the same-origin stylesheets, never runs JavaScript and uses no browser. External script files are never downloaded or read. Anything a script loads or adds while it runs, such as a chat widget loading its own parts, is only covered when the service is in the expansions table or, for connect-src, when the address is written directly in a network call inside an inline script. The policy is a starting point, not a finished one.
- Only
/sitemap.xmlis read, not other sitemap addresses named in robots.txt, and gzip sitemap files are not read. For a sitemap index, child sitemaps are read in order until there are enough pages, at most 10 of them. - It never changes any site. It only reads public pages with ordinary GET requests.
- Cross-origin stylesheets are not opened, so fonts and images named inside them come only from the expansions table.
- Only the homepage headers are read for the current policy. If other pages send a different policy, a warning says so.
- Hashes match one exact piece of inline text. If your server changes an inline script on every request, use a nonce instead.
- Up to 50 websites per run, 3 at a time by default, and up to 50 pages per site. Each site is limited to 60 seconds.
- Private and internal addresses are refused for safety and come back as an error row.
- A homepage that answers with a status outside 200 to 299, or with an empty body, is a free error row.
Next step
Watch your domain and certificate expiry with Site Watch. Built by Red Center Studio. Related: Site Watch.