Logo vun Frontend Security

Frontend Security

Communautéit
MiladJoodi
frontend-security

Secure-by-default guidance for writing, reviewing, and fixing frontend code in React and Next.js (App Router) - XSS and unsafe HTML, dangerouslySetInnerHTML, DOMPurify, URL and redirect validation, Content Security Policy with nonces, security headers (HSTS, nosniff, frame-ancestors, Referrer-Policy, Permissions-Policy), CORS, cookies and token storage, CSRF, Server Action and Route Handler hardening, third-party scripts and SRI, npm supply-chain risk, form and input validation, file uploads, payment verification and webhooks, and OTP/SMS login. Use this skill whenever the user mentions XSS, CSP, CSRF, CORS, cookies, JWT or token storage, sanitizing HTML, security headers, secure login, payment callbacks, uploads, or asks for a security review or audit of frontend code. Also use it when writing code that renders user-controlled content, handles sessions or auth, or accepts payments, even if the user never says "security".

Iwwersiicht

EditeurMiladJoodi
Repositoryskills
Skill-Nummfrontend-security
Stären
24
Forks
1
Matgeliwwert Fichieren
8
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 8 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum MiladJoodi op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Frontend Security an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/MiladJoodi/skills/tree/main/skills/frontend-security
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/MiladJoodi/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/frontend-security .claude/skills/frontend-security
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Frontend Security an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Frontend Security automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Frontend Security net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Frontend Security (React / Next.js)

Rules for writing, reviewing, and fixing frontend code so it is secure by default. Prefer small, targeted changes that preserve existing behavior. Concrete fixes over theory.

Last reviewed: October 2026. Version-sensitive details (Next.js APIs, header values) change; see "Verify before asserting" below.

How to work

  1. Inspect first. Read package.json (Next.js and React versions), the router in use (App Router or Pages), the auth model (cookie session or bearer token), and where headers are set today (proxy.ts / middleware.ts, next.config, reverse proxy, hosting platform). Do not add a protection that already exists or conflicts with one that does.
  2. Trace untrusted data from source (user input, URL, API, CMS, uploads, third parties) to sink (DOM, URL, cookie, DB, redirect, file path). Security bugs live at the sinks.
  3. Pick the mode: implementing, fixing, or auditing. For audits, report each finding with severity, file and line, evidence, and a concrete fix. Do not pad the report with generic advice.
  4. Make the smallest secure change. Do not rewrite an auth or deployment architecture when a targeted fix works.
  5. Verify, then report. Say what you checked and what you could not. Never claim something is fixed because a config line exists; confirm the effective behavior (response headers, rendered HTML, test results).

Ask the user only what changes the answer: cookie session vs bearer token, Next.js version, where headers are configured, whether user-supplied HTML is a real requirement. Never ask for real secrets, production tokens, or session cookies.

Non-negotiable rules

  1. The browser is untrusted. Client-side validation, hidden buttons, disabled controls, route guards, and TypeScript types are UX, not security. Enforce every security decision on the server.
  2. Render untrusted data as text. Any HTML sink (dangerouslySetInnerHTML, innerHTML, and similar) needs a maintained sanitizer with a restrictive allowlist, applied at the render boundary. Never use regex to sanitize.
  3. URLs from data are untrusted. Allowlist protocols (http:, https:, optionally mailto:) before putting them in href or src. Validate redirect targets against relative paths or an explicit host allowlist.
  4. Keep credentials out of JavaScript. Session and refresh tokens belong in HttpOnly; Secure; SameSite cookies, not localStorage, sessionStorage, URLs, or logs.
  5. Cookie-authenticated mutations need CSRF defense and authorization. SameSite helps but does not cover everything. Never change state on GET.
  6. Treat every Server Action and Route Handler as a public HTTP endpoint. Authenticate, authorize against the specific resource (ownership, tenant), and validate input with a schema, every time.
  7. Use a nonce-based CSP with 'strict-dynamic', rolled out via Report-Only first. Do not add 'unsafe-inline' or 'unsafe-eval' to scripts just to silence errors. Nonces require dynamic rendering.
  8. Secrets stay on the server. Anything in the client bundle or in NEXT_PUBLIC_* is public.
  9. Money flows are verified server-to-server. Never trust a redirect, query string, or client-reported amount. Compute amounts on the server, verify with the provider, make fulfillment idempotent.
  10. OTP and login endpoints are attack surface. Rate-limit, cap attempts, expire and hash codes, return generic responses (no account enumeration).
  11. Uploads are hostile. Validate content (not just extension or client MIME type), generate storage keys server-side, keep storage private, treat SVG and HTML as active content.
  12. Dependencies are code you run. Commit the lockfile, install from it in CI, audit, and review new packages (especially in auth and payment paths).
  13. Do not log secrets or personal data: passwords, OTPs, tokens, cookies, Authorization headers, card data, government IDs.

Where to read next

Read only the reference that matches the task:

Task touchesRead
HTML rendering, Markdown, rich text, links, redirects, iframes, postMessage, JSON-LDreferences/xss-and-urls.md
CSP, nonces, security headers, CORS, proxy.ts / middleware.tsreferences/csp-headers-cors.md
Sessions, cookies, tokens, CSRF, Server Actions, Route Handlers, authorizationreferences/auth-cookies-csrf.md
Forms, schemas, request limits, file uploads, object storagereferences/input-validation-uploads.md
Payment callbacks, webhooks, OTP / SMS loginreferences/payments-and-otp.md
Third-party scripts, SRI, npm dependencies, supply chainreferences/third-party-and-supply-chain.md
Finishing a change or running an auditreferences/review-checklist.md

For a full audit, read the checklist first, then the references for each area found in the code.

Verify before asserting

  • Next.js naming: current Next.js docs use proxy.ts exporting proxy for the nonce pattern; older versions use middleware.ts exporting middleware. Check the installed version and the official docs before choosing.
  • Header values and directives: if unsure about a directive or value, check MDN or the framework docs instead of guessing.
  • Provider APIs (payments, SMS, storage): use the provider's current official documentation. Do not invent response codes, field names, or amount units.
  • Placeholders: never ship placeholder SRI hashes, fake keys, or invented configuration as if they were real.
  • If something cannot be verified in this session, say so explicitly in the final message.

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Frontend Security?

Secure-by-default guidance for writing, reviewing, and fixing frontend code in React and Next.js (App Router) - XSS and unsafe HTML, dangerouslySetInnerHTML, DOMPurify, URL and redirect validation, Content Security Policy with nonces, security headers (HSTS, nosniff, frame-ancestors, Referrer-Policy, Permissions-Policy), CORS, cookies and token storage, CSRF, Server Action and Route Handler hardening, third-party scripts and SRI, npm supply-chain risk, form and input validation, file uploads, payment verification and webhooks, and OTP/SMS login. Use this skill whenever the user mentions XSS...

Firwat Frontend Security op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Frontend Security besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Frontend Security an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/MiladJoodi/skills/tree/main/skills/frontend-security an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Frontend Security benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Frontend Security benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Frontend Security domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Frontend Security gratis?

Jo. De Skill gëtt vum MiladJoodi ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇