xss

Encode output by context and implement CSP to mitigate XSS vulnerabilities.

Updated Jun 5, 2026
One-click install
npx skills add https://github.com/hung-phan/system-skills --skill xss-hung-phan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: xss
Source: https://github.com/hung-phan/system-skills/tree/main/skills/system-review/references/security/xss
Command: npx skills add https://github.com/hung-phan/system-skills --skill xss-hung-phan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill provides comprehensive defenses against Cross-Site Scripting (XSS), addressing stored, reflected, and DOM-based XSS vulnerabilities with a focus on output encoding by context, Content Security Policy, and other strategies.

Core Features & Use Cases

  • Output Encoding by Context: Offers functions to encode user input for different HTML, JavaScript, URL, and CSS contexts to prevent context confusion attacks.
  • Content Security Policy (CSP): Provides implementation strategies and best practices for using CSP to restrict content sources and block malicious scripts.
  • HTML Sanitization: Recommends and demonstrates the use of HTML sanitizers to safely handle user-generated content.
  • Use Case: Utilize the Skill when you are developing a web application and need to ensure user input is handled securely to prevent XSS attacks.

Quick Start

Use the xss skill to sanitize the HTML output from the user's comment.

Frequently Asked Questions about xss

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent XSS vulnerabilities when displaying user-generated HTML content?

Preventing XSS vulnerabilities requires applying context-aware output encoding and HTML sanitization to user-generated content before rendering it in the browser. This ensures malicious scripts embedded in user input are neutralized and safely displayed as text.

What is context-aware output encoding for XSS prevention?

Context-aware output encoding for XSS prevention is the practice of encoding untrusted data differently depending on where it is placed in the document, such as within HTML, JavaScript, URL, or CSS contexts. This stops context confusion attacks by ensuring data is treated strictly as content.

How do I implement a Content Security Policy to block malicious scripts?

You can implement a Content Security Policy (CSP) to block malicious scripts by configuring your web application to restrict content sources and explicitly define approved script origins. This mitigation strategy restricts resource loading and prevents unauthorized inline script execution.

What is the best way to sanitize HTML input for stored and reflected XSS attacks?

The best way to sanitize HTML input against stored and reflected XSS attacks is using dedicated HTML sanitization techniques to safely process user-generated content. Sanitizers strip dangerous tags and attributes while preserving safe formatting before the data reaches the DOM.

Does HTML encoding alone protect against DOM-based XSS vulnerabilities?

HTML encoding alone does not fully protect against DOM-based XSS vulnerabilities, because DOM-based attacks occur when user input is executed directly within the client-side Document Object Model. You must combine context-aware encoding, HTML sanitization, and Content Security Policy for comprehensive defense.