How the attack works
An attacker plants content on a web page, in a document, or in a data source that the AI agent will read as part of its task, such as summarizing a page or answering questions about it. The content contains XSS techniques: onerror or onload event handlers, IMG or SCRIPT tags, HTML-entity-encoded links, javascript: URIs, or String.fromCharCode-encoded strings meant to slip past simple filters. The agent fetches this content and either renders it directly or relays it to a downstream user interface. If the rendering surface executes HTML/JS, the payload runs.
Why it matters
If the agent's output is displayed in a browser or any HTML-rendering surface, this can lead to script execution, session hijacking, or delivery of further malicious content to whoever views the agent's output.
What you can do
- Sanitise and strip HTML/JS from any web content before it reaches a rendering surface, regardless of source trust.
- Treat agent-fetched web content as untrusted input and never render it as raw HTML without escaping.
- Apply a strict Content Security Policy to any interface that displays agent output.
- Log and review cases where agents relay content containing event handlers, script tags, or encoded payloads, but expect some false positives from security education or code-sample content.
Known benign look-alikes
- Security education content discussing web injection techniques
- Web development code samples containing sanitised HTML examples
- CTF or penetration testing reports with example payloads