Back to skills
SKILL.md
Security
ASecuritySecurity practices for React (XSS, Auth, Dependencies).
- 8 stars
- 0 votes
- 0 copies
- 3 views
- Added September 8, 2026
Works with
Security analysis
100/100Pro scans all 2 files and shows the line behind each finding
npx -y skills add ngxtm/devkit --skill security --agent claude-codeAre you the author of Security?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ngxtm-security-0e8c3ed6)---
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
```tsx
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>;
```
Files in this skill
- SKILL.md
- references/REFERENCE.md
Attribution
Comments
Loading comments…