Skip to content

[Security] Implement Content Security Policy (CSP) via react-helmet-async (React Frontend) #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
piyushsinghgaur1 opened this issue May 14, 2025 · 0 comments · May be fixed by #79
Open
Assignees
Labels
enhancement New feature or request

Comments

@piyushsinghgaur1
Copy link
Collaborator

Description:

To enhance frontend security, implement a strong Content Security Policy (CSP) using react-helmet-async in the React frontend.

This protects the app against XSS, clickjacking, and code injection attacks by restricting trusted sources.


Tasks:

  • Integrate react-helmet-async to manage document head and CSP headers
  • Define a strict CSP policy (e.g., 'default-src': ["'self'"])
  • Avoid 'unsafe-inline' unless absolutely required (and document it if used)
  • Remove <meta http-equiv="Content-Security-Policy"> from client app
  • Add whitelisted external domains (e.g., fonts, analytics, CDNs, etc.)
  • Ensure CSP configuration is environment-agnostic (dev/prod/stage)
  • Test application with CSP enabled in all environments
  • Validate via browser console: no CSP violations
  • Document the CSP configuration and update steps in the project README

Acceptance Criteria:

  • react-helmet-async is applied and CSP meta tags are set correctly
  • Application loads successfully with no CSP violations in browser console
  • All third-party resources are explicitly whitelisted in the CSP
  • Inline scripts and styles are avoided where possible
  • CSP policy is clearly documented and easy to update

@piyushsinghgaur1 piyushsinghgaur1 self-assigned this May 14, 2025
@piyushsinghgaur1 piyushsinghgaur1 added the enhancement New feature or request label May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant