Skip to content

Conversation

@piyushsinghgaur1
Copy link
Collaborator

@piyushsinghgaur1 piyushsinghgaur1 commented May 14, 2025


Description:

This PR enhances the security of the React frontend by implementing a robust Content Security Policy (CSP) using react-helmet-async.

Key Changes:

  • Integrated react-helmet-async to manage CSP via React components
  • Defined a strict CSP (default-src 'self') to block untrusted sources
  • Removed <meta http-equiv="Content-Security-Policy"> from index.html
  • Whitelisted trusted domains for scripts, styles, fonts, and images
  • Validated implementation with browser dev tools — no CSP violations
  • Enabled support for resolving nested environment variables using env: placeholders

Why This Matters:

A strong CSP helps protect against XSS, clickjacking, and code injection attacks by limiting which sources are allowed to load content in the app.


@piyushsinghgaur1 piyushsinghgaur1 changed the title Implement strict Content Security Policy using react-helmet-async* Implement strict Content Security Policy using react-helmet-async May 14, 2025
@piyushsinghgaur1 piyushsinghgaur1 added the enhancement New feature or request label May 14, 2025
@piyushsinghgaur1 piyushsinghgaur1 self-assigned this May 14, 2025
feat(security): implement CSP via react-helmet-async in React frontend
@piyushsinghgaur1 piyushsinghgaur1 marked this pull request as ready for review May 27, 2025 06:41
… configuration

Add CSP directives and client config to environment files

Updates example environment files to include Content Security Policy
(CSP) directives with secure defaults and client configuration keys.

Introduces logic to dynamically expand environment variables within
CSP directives, validates critical directives, and ensures secure
defaults where missing. Enhances security and configurability.

Relates to: feat(config)
@sonarqubecloud
Copy link

@rohit-sourcefuse
Copy link

No longer required, as we've implemented a generic CSP package for both React and Angular boilerplates. See: https://github.com/sourcefuse/arc-spa-csp

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 this pull request may close these issues.

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

4 participants