ammonia-sanitization

Sanitize HTML content with Ammonia crate whitelists and URL scheme validation.

836|66|Updated Feb 3, 2025
One-click install
npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill ammonia-sanitization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: ammonia-sanitization
Source: https://github.com/kreuzberg-dev/html-to-markdown/tree/main/.ai-rulez/domains/safety-sanitization/skills/ammonia-sanitization
Command: npx skills add https://github.com/kreuzberg-dev/html-to-markdown --skill ammonia-sanitization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the security risks associated with rendering untrusted HTML by sanitizing it to prevent cross-site scripting (XSS) attacks and other vulnerabilities.

Core Features & Use Cases

  • Secure HTML Sanitization: Uses the Ammonia crate to clean HTML content based on configurable whitelists for tags and attributes.
  • URL Validation: Ensures that links within the HTML use only safe schemes (http, https, mailto, ftp).
  • Use Case: When displaying user-generated comments or forum posts that may contain HTML, use this Skill to clean the input before rendering it to prevent malicious code execution.

Quick Start

Sanitize the provided HTML string using the ammonia-sanitization skill, allowing only 'p', 'div', 'strong', and 'em' tags.

Frequently Asked Questions about ammonia-sanitization

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

FAQPage Schema
How do I sanitize HTML to prevent XSS attacks in web applications?

HTML sanitization removes unsafe elements and attributes using whitelists to prevent XSS attacks. This Skill cleans user-generated content by enforcing security policies and validating URL schemes before rendering in web applications.

How do I clean user-generated HTML comments before rendering them?

Clean user-generated HTML comments by applying a sanitization filter that restricts content to safe tags like 'p', 'div', 'strong', and 'em'. This removes malicious code execution risks before the content is displayed.

Can I configure which HTML tags and attributes are allowed during sanitization?

Yes, you can configure HTML sanitization with specific whitelists for allowed tags and attributes. You can restrict content to safe elements like 'p', 'div', 'strong', and 'em' to enforce strict security policies.

Does HTML sanitization block malicious URL redirects and unsafe links?

Yes, HTML sanitization validates URL schemes to block malicious redirects and script execution. It ensures that links within the content use only safe schemes like http, https, mailto, and ftp.

What are the limitations of whitelist-based HTML sanitization for user content?

Whitelist-based HTML sanitization requires explicit configuration of allowed tags and attributes, meaning any valid but unlisted elements will be stripped. You must anticipate all safe formatting needs to avoid removing legitimate user content.