Skip to content

Commit 7c61fdb

Browse files
committed
fix: update Content Security Policy to include additional domains for connect-src and script-src
1 parent 49b745e commit 7c61fdb

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

.documentation/SECURITY.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,20 @@ The application implements CSP headers to prevent XSS attacks and unauthorized r
3737
```
3838
Content-Security-Policy:
3939
default-src 'self';
40-
connect-src 'self' https://markhazleton.com https://*.markhazleton.com https://cdnjs.cloudflare.com https://v2.jokeapi.dev https://api.openweathermap.org wss://webspark.markhazleton.com ws://localhost:* http://localhost:*;
41-
script-src 'self' 'unsafe-inline' 'unsafe-eval';
40+
connect-src 'self' https://markhazleton.com https://*.markhazleton.com https://cdnjs.cloudflare.com https://v2.jokeapi.dev https://api.openweathermap.org wss://webspark.markhazleton.com ws://localhost:* http://localhost:* https://cloudflareinsights.com https://stats.g.doubleclick.net https://www.google.com;
41+
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://static.cloudflareinsights.com;
4242
style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com;
4343
img-src 'self' data: https: http: blob:;
4444
font-src 'self' data: https:;
4545
media-src 'self' https: http:;
46-
frame-src 'none';
46+
frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com;
4747
worker-src 'self' blob:;
4848
```
4949

5050
**Key Points**:
5151

5252
- `connect-src` includes wildcard for markhazleton.com subdomains to support service worker fetches
53+
- `connect-src` also allows the Google analytics endpoints used by Cloudflare Zaraz
5354
- `img-src`, `font-src`, `media-src` use protocol-level wildcards for flexibility with external resources
5455
- Service workers (`worker-src`) can load from same origin and blob URLs
5556

staticwebapp.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"X-Content-Type-Options": "nosniff",
6161
"X-Frame-Options": "DENY",
6262
"X-XSS-Protection": "1; mode=block",
63-
"Content-Security-Policy": "default-src 'self'; connect-src 'self' https://markhazleton.com https://*.markhazleton.com https://cdnjs.cloudflare.com https://v2.jokeapi.dev https://api.openweathermap.org wss://webspark.markhazleton.com ws://localhost:* http://localhost:* https://cloudflareinsights.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; img-src 'self' data: https: http: blob:; font-src 'self' data: https:; media-src 'self' https: http:; frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com; worker-src 'self' blob:;",
63+
"Content-Security-Policy": "default-src 'self'; connect-src 'self' https://markhazleton.com https://*.markhazleton.com https://cdnjs.cloudflare.com https://v2.jokeapi.dev https://api.openweathermap.org wss://webspark.markhazleton.com ws://localhost:* http://localhost:* https://cloudflareinsights.com https://stats.g.doubleclick.net https://www.google.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; img-src 'self' data: https: http: blob:; font-src 'self' data: https:; media-src 'self' https: http:; frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com; worker-src 'self' blob:;",
6464
"_CSP_WARNING": "DO NOT TIGHTEN THIS CSP! Site fetches all images/data from markhazleton.com. See .github/copilot-instructions.md @csp rule before changing.",
6565
"Access-Control-Allow-Origin": "*",
6666
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default defineConfig({
9090
// DO NOT TIGHTEN - Site pulls all images/data from markhazleton.com
9191
// See .github/copilot-instructions.md @csp rule for details
9292
"Content-Security-Policy":
93-
"default-src 'self'; connect-src 'self' https://markhazleton.com https://*.markhazleton.com https://cdnjs.cloudflare.com https://v2.jokeapi.dev https://api.openweathermap.org wss://webspark.markhazleton.com ws://localhost:* http://localhost:* https://cloudflareinsights.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; img-src 'self' data: https: http: blob:; font-src 'self' data: https:; media-src 'self' https: http:; frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com; worker-src 'self' blob:;",
93+
"default-src 'self'; connect-src 'self' https://markhazleton.com https://*.markhazleton.com https://cdnjs.cloudflare.com https://v2.jokeapi.dev https://api.openweathermap.org wss://webspark.markhazleton.com ws://localhost:* http://localhost:* https://cloudflareinsights.com https://stats.g.doubleclick.net https://www.google.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com; img-src 'self' data: https: http: blob:; font-src 'self' data: https:; media-src 'self' https: http:; frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com; worker-src 'self' blob:;",
9494
},
9595
proxy: {
9696
"/rss-feed": {

0 commit comments

Comments
 (0)