Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Review and harden security for htmx and server-driven web apps. Use when handling user-supplied HTML, escaping or sanitizing fragments, adding CSP, evaluating XSS risk, configuring CSRF or cookies, loading htmx from a CDN, using SRI hashes, accepting hx-* attributes from content, or reviewing htmx request headers and history caching.
.claude/skills/hashgraph-online-htmx-security/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-12 | ✗→✓ | ▲ Improved | 15% | 0% |
| case-24 | ✗→✓ | ▲ Improved | -7% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 12% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 31% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 3% | 0% |
Use this skill before shipping htmx features that render user content, accept rich HTML, add third-party scripts, change Content Security Policy, or expose new mutation endpoints.
htmx keeps rendering on the server, but unsafe HTML is still unsafe HTML. A fragment swap can insert scripts, event handlers, dangerous URLs, or htmx attributes that cause requests. Treat every fragment as executable browser surface unless it is escaped or sanitized.
hx-*, data-hx-*, hx-on, inline event handlers, script, dangerous URLs, and style features that the product does not explicitly allow.Choose one content policy:
| User content type | Policy | | --- | --- | | Plain text | Escape and render as text | | Markdown | Render through a sanitizer and allow only safe tags/attributes | | Rich HTML | Sanitize with a narrow allowlist and strip htmx/event/script capabilities | | Trusted admin HTML | Still sanitize unless the trust boundary is documented and access is tightly controlled |
Do not mark content safe merely because it was stored in the database earlier.
hx-get, hx-post, hx-put, hx-patch, hx-delete, or hx-trigger can create unintended requests.hx-on or inline handlers can execute JavaScript.hx-vals can smuggle unexpected parameters.Use hx-history="false" on sensitive pages or containers that should not be stored in htmx history cache.
Secure, HttpOnly, and SameSite cookie settings appropriate to the app.Prefer vendored static assets for reproducibility. If loading htmx or extensions from a CDN:
crossorigin when required by SRI;Design CSP around the actual frontend stack:
hx-on, Alpine default builds, and _hyperscript can require looser policies unless replaced with CSP-compatible patterns.hx-*, hx-on, event handlers, scripts, or dangerous URLs?_hyperscript, and htmx usage?hx-vals, or client-side state for authorization.Other measured skills in the registry, with their headline benchmark lift.