nextjs-react
This skill should be used when the user asks about "Next.js security", "React security", "Server Components", "Server Actions", "Route Handlers", "RSC vulnerabilities", "SSR security", or needs comprehensive Next.js/React security analysis during whitebox security review.
Best use case
nextjs-react is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
This skill should be used when the user asks about "Next.js security", "React security", "Server Components", "Server Actions", "Route Handlers", "RSC vulnerabilities", "SSR security", or needs comprehensive Next.js/React security analysis during whitebox security review.
Teams using nextjs-react should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/nextjs-react/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How nextjs-react Compares
| Feature / Agent | nextjs-react | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
This skill should be used when the user asks about "Next.js security", "React security", "Server Components", "Server Actions", "Route Handlers", "RSC vulnerabilities", "SSR security", or needs comprehensive Next.js/React security analysis during whitebox security review.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Next.js/React Security Analysis
Comprehensive security patterns for Next.js and React applications, covering both client-side and server-side attack surfaces.
## Architecture Overview
```
┌─────────────────────────────────────────────────────────────┐
│ Next.js Application │
├─────────────────────────────────────────────────────────────┤
│ │
│ Client-Side (Browser) Server-Side (Node.js) │
│ ┌──────────────────┐ ┌──────────────────────┐ │
│ │ React Components │ │ Server Components │ │
│ │ Client Actions │◄────────►│ Server Actions │ │
│ │ useEffect/State │ │ Route Handlers │ │
│ └──────────────────┘ │ Middleware │ │
│ │ getServerSideProps │ │
│ └──────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────┘
```
## Attack Surface Categories
### 1. Server Actions (`"use server"`)
- SSRF via redirect() with Host header manipulation
- Insecure direct object references
- Missing authentication/authorization
- SQL injection in database operations
### 2. Route Handlers (`app/api/**/route.ts`)
- Unauthenticated API endpoints
- Mass assignment vulnerabilities
- Rate limiting bypass
- CORS misconfiguration
### 3. Server Components
- Data exposure in serialized props
- Sensitive data in `__NEXT_DATA__`
- Server-side XSS in rendered content
### 4. Middleware
- Path-based bypass (normalization)
- Authentication bypass
- Header injection
### 5. Client Components
- XSS via unsanitized rendering
- Prototype pollution
- Open redirects
## Detection Workflow
### Step 1: Map the Application
```bash
# Find all Server Actions
grep -rn '"use server"' --include="*.ts" --include="*.tsx"
# Find all Route Handlers
find . -path "*/app/api/*" \( -name "route.ts" -o -name "route.js" \)
# Find middleware
find . -name "middleware.ts" -o -name "middleware.js"
# Find page components
find ./app -name "page.tsx" -o -name "page.js"
```
### Step 2: Identify Entry Points
```bash
# Server Actions called from forms
grep -rn "action=" --include="*.tsx" | grep -v node_modules
# Server Actions called programmatically
grep -rn "startTransition\|useTransition" --include="*.tsx"
# Route Handler methods
grep -rn "export.*function\s\+\(GET\|POST\|PUT\|DELETE\|PATCH\)" --include="route.ts"
```
### Step 3: Check Authentication
```bash
# Find auth patterns
grep -rn "getServerSession\|getSession\|auth\(\)" --include="*.ts" --include="*.tsx"
# Find unprotected handlers (no auth import)
for f in $(find . -path "*/app/api/*" -name "route.ts"); do
if ! grep -q "getServerSession\|auth\|verify" "$f"; then
echo "Potentially unprotected: $f"
fi
done
```
### Step 4: Trace Data Flow
```bash
# Find request data access
grep -rn "request\.json\|request\.formData\|request\.text" --include="*.ts"
# Find database operations
grep -rn "prisma\.\|db\.\|sql\`\|query\(" --include="*.ts"
# Find external API calls
grep -rn "fetch\(\|axios\.\|got\(" --include="*.ts"
```
## Key Patterns
### SSRF via Server Action Redirect
See `framework-patterns/nextjs-patterns.md` for detailed pattern.
### Unprotected Route Handler
```typescript
// VULNERABLE: No auth check
export async function DELETE(req: Request) {
const { id } = await req.json();
await db.user.delete({ where: { id } }); // Anyone can delete!
return Response.json({ success: true });
}
```
### Server Component Data Leak
```typescript
// VULNERABLE: Sensitive data exposed
async function UserProfile({ userId }: { userId: string }) {
const user = await db.user.findUnique({ where: { id: userId } });
// Full user object including password hash goes to client!
return <ClientProfile user={user} />;
}
```
### Middleware Bypass
```typescript
// VULNERABLE: Case-sensitive matching
export const config = {
matcher: '/admin/:path*' // /Admin/secret bypasses!
}
```
## Integration with Chain Detection
Next.js vulnerabilities often enable chains:
| Next.js Vulnerability | Chains To |
|----------------------|-----------|
| Server Action SSRF | Internal Flask/Django SSTI |
| Server Action SSRF | Cloud metadata (169.254.169.254) |
| Route Handler SQLi | Data exfiltration, auth bypass |
| Middleware Bypass | Admin panel access |
| Data Leak | Credential theft, session hijacking |
## Remediation Checklist
- [ ] All Server Actions validate authentication
- [ ] All Route Handlers check authorization
- [ ] Middleware uses case-insensitive matching
- [ ] Server Components filter sensitive fields before passing to client
- [ ] redirect() calls validate Host header or use absolute URLs
- [ ] Database queries use parameterized statements
- [ ] File operations validate pathsRelated Skills
Workspace Discovery
This skill should be used when the user asks to "detect workspaces", "find packages", "list monorepo packages", "workspace structure", "monorepo analysis", or needs to identify workspace/package boundaries in a codebase for focused security analysis.
vulnerability-chains
This skill should be used when the user asks about "vulnerability chains", "chained exploits", "multi-step attacks", "SSRF to RCE", "pivot attacks", or needs to identify how vulnerabilities in different components can be combined during whitebox security review.
Vulnerability Patterns
This skill should be used when the user asks about "vulnerability patterns", "how to find SQL injection", "XSS patterns", "command injection techniques", "OWASP vulnerabilities", "common web vulnerabilities", "exploitation patterns", or needs to understand how specific vulnerability classes work during whitebox security review.
Threat Modeling
This skill should be used when the user asks about "threat model", "STRIDE", "data flow diagram", "attack surface", "threat analysis", "security architecture", "component threats", "trust boundaries", "technology decomposition", or needs systematic threat identification during whitebox security review.
verify-finding
Drive a single finding through CPG verification and false-positive triage.
start-audit
Guided first-run security audit: doctor, scope, threats, scan, verify, report.
scope-repo
Decide audit boundaries for large or monorepo targets and write audit-plan.md.
review-pr
Diff-aware PR security review with verified findings and PR comment payload.
package-evidence
Bundle findings, reports, audit plan, and ledger into one evidence zip.
Sensitive Data Leakage
Detect ANY credential/secret flowing to ANY output sink. Use when asked about "credential leakage", "secret logging", "sensitive data exposure", "CWE-532", "password in logs", "token exposure", or security logging issues.
Security Misconfiguration
This skill should be used when the user asks about "security misconfiguration", "default credentials", "debug mode", "security headers", "exposed endpoints", "TLS configuration", or needs to find configuration-related vulnerabilities during whitebox security review.
Secret Scanning
This skill should be used when the user asks about "secret scanning", "find secrets", "hardcoded credentials", "leaked API keys", "git history secrets", "credential scanning", "detect passwords in code", or needs to identify secrets and credentials in source code or git history during whitebox security review.