Skip to content

fix: prevent image-based data exfiltration in chat markdown#42

Merged
yuma2024 merged 2 commits intomainfrom
fix/prevent-image-exfiltration
Mar 12, 2026
Merged

fix: prevent image-based data exfiltration in chat markdown#42
yuma2024 merged 2 commits intomainfrom
fix/prevent-image-exfiltration

Conversation

@yuma2024
Copy link
Copy Markdown
Contributor

Why

react-markdown renders markdown image syntax (alt) as tags, which automatically fire HTTP requests on render. If an AI is manipulated via prompt injection to output a
malicious image URL, sensitive data visible on screen could be exfiltrated to an external server without any user interaction.

What

Convert tag rendering to tags in the MarkdownContent component to prevent automatic HTTP requests.

How

  • Add a custom img component that renders as an tag instead
  • Image information (alt text, URL) is preserved as a clickable link
  • No HTTP request is made unless the user explicitly clicks the link

Replace <img> rendering with <a> tag to prevent automatic HTTP requests
from AI-generated markdown image syntax. This mitigates prompt injection
attacks that could exfiltrate sensitive data via image URLs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
{children}
</td>
),
img: ({ src, alt }) => (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

document the reason for this please with a comment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@yuma2024 yuma2024 merged commit cd1b4dd into main Mar 12, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants