Third-party scripts can send your visitors’ data anywhere
Your page runs scripts from other sites, and no Content-Security-Policy limits which servers a script can send data to.
- Severity
- Low
- Who can exploit it
- Whoever controls, or breaks into, any script host your page loads
- Found by
- PatchLabs Live posture: your home page’s HTML and Content-Security-Policy
- Lab proof
- Not lab-proven: read from your home page’s response
What it is
Every <script src> from another site (analytics, A/B testing, chat widgets, tag managers) runs with the same power as your own code: it can read what visitors type into your forms and send it wherever it likes. PL-040 means your home page loads at least one such script and your Content-Security-Policy doesn’t say where scripts may send data, through connect-src (fetch, XHR, WebSocket, beacons) and img-src (image requests), directly or through default-src.
If one of those vendors is compromised, the injected code arrives from a host you trust. On 16 November 2026 that happened to Optimizely: an attacker wrote code into customers’ Project JavaScript, and at least 178 organisations served it to their visitors from Optimizely’s own CDN, with card skimming, wallet-address swapping and iPhone exploit delivery. Read the full story in our guide.
Why AI builders produce it
Builders add analytics and widgets by pasting a snippet, and AI tools do the same when asked to “add tracking”. A Content-Security-Policy is a hosting header that generated projects rarely set, and when one is added it often lists only script-src, which decides what may load, not where loaded code may send data.
What we see
A synthetic example for app.example.com, shortened. Not taken from any real site.
<!-- index.html -->
<script src="https://cdn.vendor-a.com/snippet.js"></script>
<script src="https://www.googletagmanager.com/gtm.js?id=GTM-XXXX"></script>
# response headers: no content-security-policy, or one without connect-src / img-src / default-src
Check it yourself
List the scripts your page loads from other sites, then look at the policy:
# scripts in the HTML (tag managers add more at runtime: check DevTools → Network → JS too)
curl -s https://your-app.com | grep -oiE '<script[^>]+src=[^>]+>'
# the policy: you want connect-src and img-src (or default-src) with named hosts, not * or https:
curl -sI https://your-app.com | grep -i content-security-policy
The fix
Add a policy that names the servers your page really talks to. Start in report-only mode for a few days so you can see what you missed without breaking anything, then switch to the enforcing header.
Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.vendor-a.com; connect-src 'self' https://YOUR-PROJECT.supabase.co wss://YOUR-PROJECT.supabase.co https://api.vendor-a.com; img-src 'self' data: https://YOUR-PROJECT.supabase.co; frame-ancestors 'self'
We tested this in Chrome on 22 Nov 2026 with a script that sent a fake card number four ways (fetch, an image, a beacon and a WebSocket). With no policy, all four reached the other server. With only a script-src allow-list, all four still did. With default-src 'self', none did. A policy narrows the exits but does not close every one (a script can still navigate the page or submit a form), so also keep third-party tags off sign-in and payment pages, and take card details in your payment provider’s hosted fields.
Vercel
{
"headers": [
{
"source": "/(.*)",
"headers": [
{ "key": "Content-Security-Policy", "value": "default-src 'self'; script-src 'self' https://cdn.vendor-a.com; connect-src 'self' https://YOUR-PROJECT.supabase.co wss://YOUR-PROJECT.supabase.co; img-src 'self' data:" }
]
}
]
}
Put vercel.json at the root of the project and redeploy. If the file already has a headers array, add the object to it rather than starting a second one.
Netlify
# public/_headers (Vite copies public/ into the publish folder)
/*
Content-Security-Policy: default-src 'self'; script-src 'self' https://cdn.vendor-a.com; connect-src 'self' https://YOUR-PROJECT.supabase.co wss://YOUR-PROJECT.supabase.co; img-src 'self' data:
The file must end up in your publish directory (dist for Vite). Bolt projects deployed to Netlify use this file too. The same rule can live in netlify.toml under [[headers]] if you prefer one config file.
Cloudflare
For a site proxied through Cloudflare (orange cloud), add a Response Header Transform Rule (Rules → Transform Rules in the dashboard): match all incoming requests to your hostname, then Set static header Content-Security-Policy to:
default-src 'self'; script-src 'self' https://cdn.vendor-a.com; connect-src 'self' https://YOUR-PROJECT.supabase.co wss://YOUR-PROJECT.supabase.co; img-src 'self' data:
On Cloudflare Pages or Workers static assets, a _headers file in your build output works the same way as on Netlify.
Lovable
A meta tag in index.html works on any host, including Lovable hosting. It covers connect-src and img-src (it can’t set frame-ancestors; see PL-031):
<!-- index.html, first thing inside <head> -->
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' https://cdn.vendor-a.com; connect-src 'self' https://YOUR-PROJECT.supabase.co wss://YOUR-PROJECT.supabase.co; img-src 'self' data:">
Live posture findings come with the header or setting to change. PatchLabs never changes your hosting or your repo.
Ask your AI builder to fix it
Built with Lovable, Bolt, Replit or Cursor? Paste this into the chat. It asks for this one fix and nothing else, and to see the change before it’s applied. Read the change, or have your engineer read it, before you accept.
My page loads scripts from other sites (analytics, widgets) and has no Content-Security-Policy limiting where scripts can send data. List every outside host the app loads scripts from and talks to (fetch, WebSocket, images), then add a Content-Security-Policy with default-src 'self' and script-src, connect-src and img-src naming only those hosts, using my host's headers config or a meta tag in index.html. Ship it first as Content-Security-Policy-Report-Only, then enforce it. Keep third-party tags off sign-in and payment pages. Show me the exact change before you apply it, and don't change anything else.
Then check again with the free headers check, or run the full free check on your repo.
How PatchLabs finds it
[LOAD] https://app.example.com/ → 200 scripts from 2 other sites: cdn.vendor-a.com, www.googletagmanager.com connect-src / img-src not limited FLAG
Live posture reads the <script src> tags in your home page’s HTML and counts those on another site (a CDN on your own domain, such as static.your-app.com, doesn’t count). It passes if the header or meta policy limits both connect-src and img-src, directly or through default-src, without * or a bare scheme like https:. Scripts that a tag manager adds later aren’t visible to one page load. If a host had a public compromise in the last 90 days, the finding names it and rises to medium.
When the pattern is intended
A page with no forms and no signed-in users carries less risk, though a hijacked script can still redirect visitors or serve them malware.
Why it’s rated low
Low: it needs one of your vendors to be compromised first, which is rare but, as 16 November showed, hits many sites at once. Medium when a script host on your page had a public compromise in the last 90 days. Low costs 5 points in the Live posture grade, medium 15.
Related findings
No Content-Security-Policy
Your page sends no Content-Security-Policy, so any script that gets onto it can run and send data anywhere.
PL-034Page loads scripts or styles over plain HTTP
Your HTTPS page pulls a script or stylesheet from an http:// address, which anyone on the network can replace.
PL-031Any site can frame the page
Neither frame-ancestors nor X-Frame-Options is set, so another site can load your app invisibly inside its own.
Guides
Free check
Does your site have PL-040?
Type your site’s address. The free headers check loads your public home page once, like any visitor, and grades HTTPS, the certificate, security headers, cookie flags and mixed content. No sign-up, and the result isn’t stored.
Last reviewed 10 Nov 2026. Finding IDs are stable: link to them freely. Spotted a mistake? Tell us.