Skip to content

Conversation

@Jtrust
Copy link
Member

@Jtrust Jtrust commented Jan 25, 2026

Updated Content-Security-Policy to simplify directives and enhance security.

Updated Content-Security-Policy to simplify directives and enhance security.
@netlify
Copy link

netlify bot commented Jan 25, 2026

Deploy Preview for skywalking-website-preview ready!

Name Link
🔨 Latest commit 775e7f9
🔍 Latest deploy log https://app.netlify.com/projects/skywalking-website-preview/deploys/6975c38323d18e00087f3b35
😎 Deploy Preview https://deploy-preview-811--skywalking-website-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Content-Security-Policy (CSP) in .htaccess by tightening the default policy while adding new security directives and modifying resource-specific policies. The changes aim to simplify and restructure the CSP configuration.

Changes:

  • Tightened default-src from 'self' https: data: 'unsafe-inline' to just 'self'
  • Changed several resource directives (style-src, img-src) from specific hcaptcha domains to broad https: wildcards
  • Added new security directives: font-src, media-src, base-uri, and form-action

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

img-src 'self' data: https://hcaptcha.com https://*.hcaptcha.com; \
frame-ancestors 'self'; \
frame-src 'self' https://www.youtube.com https://player.bilibili.com https://*.hcaptcha.com; \
style-src 'self' 'unsafe-inline' https:; \
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The style-src directive has been changed from specific hcaptcha domains to a broad https: wildcard, which allows loading stylesheets from any HTTPS source. This loosens security compared to the previous configuration.

While this may be intentional for flexibility, it reduces protection against potential attacks. If the application only needs styles from specific known domains, consider restricting this to those domains rather than allowing all HTTPS sources. For example, if you need styles from hcaptcha and specific CDNs, list them explicitly.

Suggested change
style-src 'self' 'unsafe-inline' https:; \
style-src 'self' 'unsafe-inline' https://js.hcaptcha.com https://*.hcaptcha.com; \

Copilot uses AI. Check for mistakes.
frame-ancestors 'self'; \
frame-src 'self' https://www.youtube.com https://player.bilibili.com https://*.hcaptcha.com; \
style-src 'self' 'unsafe-inline' https:; \
img-src 'self' data: https:; \
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The img-src directive has been changed from specific hcaptcha domains to a broad https: wildcard, which allows loading images from any HTTPS source. This loosens security compared to the previous configuration.

While this provides flexibility, it reduces protection against potential image-based attacks or data exfiltration. If the application only needs images from specific known domains, consider restricting this to those domains rather than allowing all HTTPS sources. This is particularly important for user-facing applications where malicious actors might exploit this to load tracking pixels or other unwanted content.

Suggested change
img-src 'self' data: https:; \
img-src 'self' data: https://js.hcaptcha.com https://*.hcaptcha.com; \

Copilot uses AI. Check for mistakes.
frame-src 'self' https://www.youtube.com https://player.bilibili.com https://*.hcaptcha.com; \
style-src 'self' 'unsafe-inline' https:; \
img-src 'self' data: https:; \
font-src 'self' data: https:; \
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added font-src directive allows fonts from any HTTPS source with the broad https: wildcard. This is quite permissive and could potentially be exploited.

If the application uses fonts from specific sources (like Google Fonts, Adobe Fonts, or specific CDNs), consider listing only those specific domains instead of allowing all HTTPS sources. If custom fonts are only served from your own domain, font-src 'self' data: would be more secure.

Suggested change
font-src 'self' data: https:; \
font-src 'self' data:; \

Copilot uses AI. Check for mistakes.
style-src 'self' 'unsafe-inline' https:; \
img-src 'self' data: https:; \
font-src 'self' data: https:; \
media-src 'self' https:; \
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added media-src directive allows media from any HTTPS source with the broad https: wildcard. This is quite permissive.

If the application serves media from specific sources (like your own domain or specific CDNs), consider listing only those specific domains instead of allowing all HTTPS sources. If media is only served from your own domain, media-src 'self' would be more secure. Note that video embeds from YouTube and Bilibili are already covered by frame-src, so media-src is for direct audio/video elements.

Suggested change
media-src 'self' https:; \
media-src 'self'; \

Copilot uses AI. Check for mistakes.
Comment on lines 4 to 16
Header always set Content-Security-Policy "default-src 'self'; \
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.algolianet.com https://*.algolia.net https://*.algolia.io https://api.github.com https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app https://js.hcaptcha.com https://*.hcaptcha.com; \
connect-src 'self' https://*.algolianet.com https://*.algolia.net https://*.algolia.io https://api.github.com https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app https://*.hcaptcha.com; \
style-src 'self' 'unsafe-inline' https://hcaptcha.com https://*.hcaptcha.com; \
img-src 'self' data: https://hcaptcha.com https://*.hcaptcha.com; \
frame-ancestors 'self'; \
frame-src 'self' https://www.youtube.com https://player.bilibili.com https://*.hcaptcha.com; \
style-src 'self' 'unsafe-inline' https:; \
img-src 'self' data: https:; \
font-src 'self' data: https:; \
media-src 'self' https:; \
object-src 'none'; \
frame-ancestors 'self'; \
base-uri 'self'; \
form-action 'self'; \
upgrade-insecure-requests;"
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description claims this update will "enhance security," but several directives have been loosened from specific domains to broad https: wildcards (style-src, img-src, font-src, media-src). This actually reduces security by allowing resources from any HTTPS source rather than specific trusted domains.

While the addition of base-uri and form-action directives does improve security in those specific areas, and tightening default-src is generally good, the overall net effect may not be a security enhancement due to the loosened resource directives. Please verify that this tradeoff is intentional and aligns with your security requirements.

Copilot uses AI. Check for mistakes.
Header always set Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline'; \
frame-src 'self' https://www.youtube.com https://player.bilibili.com https://hcaptcha.com https://*.hcaptcha.com; \
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.algolianet.com https://*.algolia.net https://*.algolia.io https://api.github.com https://kapa-widget-proxy-la7dkmplpq-uc.a.run.app https://hcaptcha.com https://*.hcaptcha.com; \
Header always set Content-Security-Policy "default-src 'self'; \
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default-src directive has been significantly tightened from 'self' https: data: 'unsafe-inline' to just 'self'. While this is generally more secure, it means that any resource types without explicit directives will now be restricted to same-origin only.

Missing explicit directives that may be needed:

  • worker-src - for web workers (if used)
  • manifest-src - for web app manifests (if used)
  • child-src - for workers and nested browsing contexts (deprecated but may be needed for compatibility)

Please verify that the application doesn't use any resource types that aren't covered by the explicit directives now defined (script-src, connect-src, frame-src, style-src, img-src, font-src, media-src, object-src). Without the broader default-src fallback, these resources will be blocked.

Copilot uses AI. Check for mistakes.
@Jtrust Jtrust merged commit 5835726 into master Jan 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant