$npx skillfedfor your agent

xss-prevention

This skill equips developers with practical techniques to defend against cross-site scripting (XSS) vulnerabilities through input sanitization and secure output encoding. Master the core defensive patterns needed to protect web applications from malicious script injection and ensure safe handling of untrusted data across your codebase.

xss-prevention teaches you to defend against cross-site scripting by combining multiple defensive layers. The primary approach is implementing sanitization to remove malicious code from user input, paired with output encoding that escapes special characters based on context (HTML, attributes, URLs, or JavaScript). For dynamic content, use allowlist-based filtering to permit only safe HTML tags and attributes. Additionally, configure Content Security Policy (CSP) headers to block inline script execution and restrict script sources, creating a robust barrier against script injection attacks.

AI-generated summary based on this skill's SKILL.md

196 29 MITupdated by secondsky

Decision gist · record as of 2026-07-25

xss-prevention teaches you to defend against cross-site scripting by combining multiple defensive layers. The primary approach is implementing sanitization to remove malicious code from user input, paired with output encoding that escapes special characters based on context (HTML, attributes, URLs, or JavaScript). For dynamic content, use allowlist-based filtering to permit only safe HTML tags and attributes. Additionally, configure Content Security Policy (CSP) headers to block inline script execution and restrict script sources, creating a robust barrier against script injection attacks.

manual: git clone https://github.com/secondsky/claude-skills → cp -r claude-skills/plugins/xss-prevention/skills/xss-prevention ~/.claude/skills/xss-prevention
plugins/xss-prevention/skills/xss-prevention/SKILL.md · version 72191727

Use it when

  • xss-prevention emphasizes that sanitization must be context-aware and combined with output encoding.
  • xss-prevention equips you with practical techniques across the full attack surface.

Verify before relying

Read SKILL.md below before installing (3 files). Open directory: indexed for reading, not audited.

Same gist for agents: .md · .json

Install

secondsky/claude-skills/xss-prevention · repository language: TypeScript

Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I prevent XSS attacks in web apps?

xss-prevention teaches you to defend against cross-site scripting by combining multiple defensive layers. The primary approach is implementing sanitization to remove malicious code from user input, paired with output encoding that escapes special characters based on context (HTML, attributes, URLs, or JavaScript). For dynamic content, use allowlist-based filtering to permit only safe HTML tags and attributes. Additionally, configure Content Security Policy (CSP) headers to block inline script execution and restrict script sources, creating a robust barrier against script injection attacks.

What are XSS prevention sanitization best practices?

xss-prevention emphasizes that sanitization must be context-aware and combined with output encoding. Best practices include: using established libraries like DOMPurify for allowlist-based HTML filtering rather than blacklists; applying context-specific encoding (HTML entities for text content, URL encoding for links, JavaScript escaping for event handlers); avoiding dangerous DOM APIs like innerHTML in favor of safer alternatives such as textContent or createElement; and validating input on both client and server sides. Never rely on sanitization alone—layer it with CSP headers and secure coding patterns to create defense in depth.

How can xss-prevention help me stop cross-site scripting vulnerabilities?

xss-prevention equips you with practical techniques across the full attack surface. Learn to identify and eliminate vulnerable patterns like direct innerHTML assignment, eval() usage, and unsafe event handler binding. Master safe DOM manipulation by using APIs that treat content as text rather than markup. Implement allowlist-based filtering for user-generated content in rich text editors. Configure CSP headers with appropriate nonce values to prevent inline script execution. The skill covers both reflected and stored XSS prevention, ensuring you can secure data at every stage—from input validation through storage and final rendering.

What is the relationship between DOMPurify sanitization and preventing user input attacks?

xss-prevention teaches that DOMPurify is an allowlist-based sanitization library that removes dangerous HTML and JavaScript while preserving safe markup. When handling user-generated content—especially in rich text editors or comment systems—DOMPurify filters input against a whitelist of permitted tags and attributes, stripping any script tags, event handlers, or protocol-based URLs that could execute malicious code. This sanitization step is essential for securing user-generated content, but xss-prevention emphasizes it must be paired with output encoding and CSP headers for complete protection against injection attacks.

How do I set up Content Security Policy headers to block malicious script execution?

xss-prevention covers CSP configuration as a critical defense layer that blocks inline scripts and restricts script sources at the browser level. Configure headers like `Content-Security-Policy: script-src 'self'` to allow scripts only from your domain, or use nonce-based CSP (`script-src 'nonce-{random}'`) to permit only inline scripts with a matching nonce attribute, preventing attackers from injecting arbitrary scripts. You can also add `default-src 'self'` to restrict all resource loading. xss-prevention teaches you to implement CSP progressively, starting in report-only mode to identify legitimate script usage before enforcing strict policies that block malicious script execution.

What safe DOM APIs should I use instead of innerHTML to prevent DOM-based XSS attacks?

xss-prevention teaches that innerHTML parses and executes any script tags in the input, making it vulnerable to DOM-based XSS. Safe alternatives include textContent for plain text content (which treats all input as literal text), createElement() and appendChild() for programmatic DOM construction, and template literals with proper encoding. For dynamic HTML that must be rendered, combine these safe APIs with sanitization libraries like DOMPurify. The skill emphasizes learning secure DOM manipulation patterns so you avoid vulnerable APIs entirely, reducing your attack surface and ensuring that user-controlled data cannot be interpreted as executable code.

SKILL.md

Rendered from the published skill. Quoted content, verbatim.

XSS Prevention

Overview

Implement comprehensive Cross-Site Scripting attack prevention through input sanitization, output encoding, Content Security Policy headers, and secure coding practices.

When to Use

  • User-generated content display
  • Rich text editors
  • Comment systems
  • Search functionality
  • Dynamic HTML generation
  • Template rendering scenarios

XSS Attack Types

| Type | Vector | Defense

(truncated - see the full file via the links below)

File tree — 3 files
plugins/xss-prevention/skills/xss-prevention/SKILL.md
plugins/xss-prevention/skills/xss-prevention/references/nodejs-advanced.md
plugins/xss-prevention/skills/xss-prevention/references/python-sanitization.md

Let your AI agent find skills like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.

wish › “Prevent XSS attacks by implementing sanitization and output encoding techniques”

Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →

Related skills

Typescript Security
by jim60105 · jim60105/copilot-prompt

This skill helps developers uncover and patch security weaknesses in TypeScript applications. Receive targeted recommendations to harden your codebase against common attack vectors and best-practice violations.

GFDL-1.3updated Jul 2026
★ 21repo stars
security-scanner
by AIDotNet · AIDotNet/MoYuCode

This skill scans your code for security vulnerabilities and provides actionable remediation guidance. It helps development teams quickly identify and address potential risks before they reach production, streamlining the security review process.

MITupdated Jan 2026
★ 84repo stars
cloudflare-workers-security
by secondsky · secondsky/claude-skills

Cloudflare Workers Security delivers production patterns for protecting APIs and Workers through authentication verification, request rate limiting, input validation, and security headers. It covers JWT and API key validation, CORS configuration, and defends against common vulnerabilities like injection, XSS, and unauthorized access.

MITupdated Jul 2026
★ 196repo stars
Security Engineer
by daffy0208 · daffy0208/ai-dev-standards

Security Engineer provides a comprehensive framework for implementing authentication and authorization in web applications. Leverage AI-assisted development standards to design secure access controls, manage user credentials, and enforce permission policies across your platform.

MITupdated Dec 2025
★ 32repo stars
internationalization-i18n
by secondsky · secondsky/claude-skills

Build globally accessible applications by implementing language switching, translation workflows, and locale-specific formatting. This skill covers i18next setup for React, pluralization rules, date and number formatting using the Intl API, and right-to-left language support with CSS logical properties. Includes best practices for string extraction, pseudo-localization testing, and production translation workflows.

MITupdated Jul 2026
★ 196repo stars
impeccable
by theexperiencecompany · theexperiencecompany/gaia-ui

Impeccable handles frontend design work across websites, dashboards, apps, and component systems. It covers visual hierarchy, accessibility, responsive behavior, theming, typography, layout, motion, and design systems—moving from initial critique through live iteration to polished, production-ready code.

MITupdated May 2026
★ 210repo stars
Tags
attack-mitigationinput-defensebrowser-securitypayload-filteringhtml-escapingpolicy-enforcementvulnerability-patchingsecure-rendering