react-security | Skill Performance & Reviews | TopRankSkills

TopRank Skills

Home / Skills / tools / react-security

react-security

maintained by HoangNguyen0403

star 143 account_tree 48 verified_user MIT License
bolt View GitHub

name: React Security description: Security practices for React (XSS, Auth, Dependencies). metadata: labels: [react, security, xss, auth] triggers: files: ['/*.tsx', '/*.jsx'] keywords: [dangerouslySetInnerHTML, token, auth, xss]

React Security

Priority: P0 (CRITICAL)

Preventing vulnerabilities in client-side apps.

Implementation Guidelines

  • XSS: Avoid dangerouslySetInnerHTML. Sanitize via DOMPurify if needed.
  • URLs: Validate javascript: protocols in user links.
  • Auth: Store tokens in HttpOnly cookies. Avoid localStorage.
  • Deps: Run npm audit. Pin versions.
  • Secrets: Server-side only. No .env secrets in build.
  • CSP: Strict Content-Security-Policy headers.

Anti-Patterns

  • No eval(): RCE risk.
  • No Serialized State: Don't inject JSON into DOM without escaping.
  • No Client Logic for Permissions: Backend must validate.

Code

import DOMPurify from 'dompurify';

// Safe HTML Injection
function SafeHtml({ content }) {
  const clean = DOMPurify.sanitize(content);
  return <div dangerouslySetInnerHTML={{ __html: clean }} />;
}

// Bad Link Prevention
const safeUrl = url.startsWith('javascript:') ? '#' : url;
<a href={safeUrl}>Link</a>;

Related Topics

common/security-standards | typescript/security | component-patterns

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!

Skill Details

GitHub Stars 143
GitHub Forks 48
Created Jan 2026
Last Updated il y a 8 mois
tools tools full stack

Related Skills

ui-ux-pro-max
chevron_right
nestjs-expert
chevron_right
ui-ux-pro-max
chevron_right
performance-optimization
chevron_right
deployment
chevron_right

Build your own?

Join 12,000+ developers contributing to the Claude ecosystem.