style-attribute-sanitization

Sanitize CSS in HTML style attributes by whitelisting safe properties.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill addresses the security risks associated with CSS injection and malicious styling within HTML style attributes, ensuring safer rendering of web content.

Core Features & Use Cases

  • CSS Sanitization: Parses and cleans CSS properties and values within style attributes.
  • Selective Removal/Preservation: Offers options to either completely remove style attributes or sanitize them to keep only safe styling.
  • Use Case: When processing user-generated HTML content, this skill can prevent the execution of dangerous CSS like expression() or javascript: URLs, while preserving essential styles like color or font-size.

Quick Start

Sanitize the style attributes in the provided HTML content, removing any potentially dangerous CSS.

Frequently Asked Questions about style-attribute-sanitization

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

FAQPage Schema
How do I sanitize CSS in HTML style attributes to prevent injection?

Sanitizing CSS in style attributes involves parsing the properties and values to whitelist safe styles like color while blocking dangerous inputs like expression() and javascript: URLs to prevent injection.

What dangerous CSS properties and values should I block in style attributes?

Dangerous CSS values to block in style attributes include expression(), behavior, and javascript: URLs, which can execute malicious scripts. Safely sanitizing style attributes ensures these injection vectors are removed from user-generated HTML content.

Can I preserve safe CSS styling like color and font-size while removing malicious code?

Yes, you can preserve safe CSS styling like color and font-size while removing malicious code. This selective sanitization parses style attributes to block dangerous properties and values, keeping only the whitelisted safe styles intact for secure rendering.

What's the best way to handle CSS injection risks in user-generated HTML content?

The best way to handle CSS injection risks in user-generated HTML is to sanitize the style attributes by parsing CSS properties. This process removes dangerous vectors like expression() and javascript: URLs while retaining only safe, whitelisted styling properties.

Does HTML style attribute sanitization remove the entire attribute or just clean the CSS?

HTML style attribute sanitization can do both. It offers options to either completely remove the style attributes or selectively sanitize them, cleaning the CSS to keep only safe styling properties while stripping out any potentially dangerous values.