Skip to content

fix(security): 2 improvements across 2 files#574

Open
tomaioo wants to merge 2 commits intoambuda-org:mainfrom
tomaioo:fix/security/unescaped-html-rendered-with-safe-in-htm
Open

fix(security): 2 improvements across 2 files#574
tomaioo wants to merge 2 commits intoambuda-org:mainfrom
tomaioo:fix/security/unescaped-html-rendered-with-safe-in-htm

Conversation

@tomaioo
Copy link
Copy Markdown

@tomaioo tomaioo commented Apr 15, 2026

Summary

fix(security): 2 improvements across 2 files

Problem

Severity: High | File: ambuda/templates/htmx/parsed-tokens.html:L1

The template renders aligned directly with |safe, which disables Jinja auto-escaping. If aligned can contain user-controlled or externally sourced content (directly or indirectly), attackers can inject arbitrary HTML/JS and execute script in users' browsers.

Solution

Avoid |safe for untrusted content. Sanitize HTML server-side with a strict allowlist (e.g., Bleach) before rendering, or render as escaped text. If rich formatting is required, define a minimal allowed tag/attribute set and strip scripts/event handlers/unsafe URLs.

Changes

  • ambuda/templates/htmx/parsed-tokens.html (modified)
  • ambuda/templates/htmx/text-block.html (modified)

tomaioo added 2 commits April 14, 2026 23:18
- Security: Unescaped HTML rendered with `|safe` in HTMX partial can enable XSS
- Security: Unsafe HTML injection and malformed attribute in text block template

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
- Security: Unescaped HTML rendered with `|safe` in HTMX partial can enable XSS
- Security: Unsafe HTML injection and malformed attribute in text block template

Signed-off-by: tomaioo <203048277+tomaioo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant