Repository navigation
Description
Summary
Typing HTML in a thread message, for example <details><summary>x</summary>hidden</details>, makes the sent message bubble render the HTML: a collapsed disclosure widget, bold text, a broken image. Before #4343, bb showed the same input as literal text. The sanitizer still strips event handlers, so this is not script execution. But a user who pastes a snippet that contains HTML, or asks the agent about a tag, sees their message changed. Content can also disappear: the hidden text sits inside a collapsed <details>.
Versions and environment
- bb 0.44.0 desktop app (fork build over upstream
mainatb23150d88ecc42bcd0e8f96386be0db23f0b1fe4). The code path is unchanged onmainat36aacc040ec0a2b092785d65dee7869d02cec08e. - macOS 26.6 (25G72), Apple Silicon.
- Rendered in the desktop app's web UI (
http://127.0.0.1:38886). I took the screenshot and read the DOM with Playwright's chrome-headless-shell 1223 over CDP. - Provider does not matter: this is the user's own bubble. I used Claude Code with Haiku 4.5.
Steps to reproduce
-
Save this prompt to a file:
cat > /tmp/html-prompt.md <<'EOF' HTML render test. Reply with exactly the word ok and nothing else, do not run any tools. <details><summary>x</summary>hidden</details> inline <b>bold</b> here <img src=x onerror=alert(1)> EOF
-
bb thread spawn --project <project-id> --prompt-file /tmp/html-prompt.md -
Open the thread in the app and look at the user message bubble.
Typing the same text into the prompt box gives the same result.
Expected vs actual
Expected: the bubble shows the text I typed, tags included, as it did before #4343:
<details><summary>x</summary>hidden</details>
inline <b>bold</b> here
<img src=x onerror=alert(1)>
Actual: the bubble contains real elements. From the live DOM:
<p>HTML render test. Reply with exactly the word ok and nothing else, do not run any tools.</p>
<details><summary>x</summary>hidden</details>
<p>inline <b>bold</b> here</p>
<img alt="Image" loading="lazy" data-markdown-image="" data-markdown-image-offset="162" src="x">On screen this is a "▶ x" disclosure (with "hidden" collapsed), the word bold in bold, and a broken-image icon. onerror is stripped: the <img> has no onerror attribute, a stubbed window.alert recorded no calls, and CDP reported no Page.javascriptDialogOpening event.
Screenshot: removed.
Evidence
User message bubbles render their text through CollapsibleMessageText, and #4343 added allowHtml to it:
bb/apps/app/src/components/thread/timeline/ConversationMessageContent.tsx
Lines 284 to 294 in 36aacc0
| ) : ( | |
| <MarkdownPreview | |
| allowHtml | |
| content={ | |
| collapsedPreview?.wasCapped === true | |
| ? closeUnterminatedMarkdownCodeSpan(body.text) | |
| : body.text | |
| } | |
| promptMentions={promptMentions} | |
| threadMentions={rawThreadMentions} | |
| linkRouting={linkRouting} |
(called from the user bubble at
bb/apps/app/src/components/thread/timeline/ConversationMessageContent.tsx
Lines 436 to 443 in 36aacc0
| <CollapsibleMessageText | |
| mentions={mentions} | |
| resolveMentionLink={resolveMentionLink} | |
| resolveSegmentLinkHref={resolveSegmentLinkHref} | |
| linkRouting={linkRouting} | |
| text={text} | |
| mutePrefixLength={mutePrefixLength || undefined} | |
| /> |
When the content contains <, allowHtml switches MarkdownPreview to the HTML pipeline:
| const rendersHtml = allowHtml && content.includes("<"); |
That pipeline is rehype-raw followed by rehype-sanitize with GitHub's defaultSchema plus video. It allows details, summary, b, img, and so on, and drops on* attributes:
bb/apps/app/src/components/ui/markdown-html.tsx
Lines 8 to 50 in 36aacc0
| const MARKDOWN_HTML_REHYPE_PLUGINS: MarkdownRehypePlugins = [ | |
| rehypeRaw, | |
| [ | |
| rehypeSanitize, | |
| { | |
| ...defaultSchema, | |
| tagNames: [ | |
| ...(defaultSchema.tagNames ?? []), | |
| "video", | |
| "bb-thread-mention", | |
| "bb-prompt-mention", | |
| "bb-message-directive", | |
| ], | |
| protocols: { ...defaultSchema.protocols, poster: ["http", "https"] }, | |
| attributes: { | |
| ...defaultSchema.attributes, | |
| source: [ | |
| ...(defaultSchema.attributes?.source ?? []), | |
| "src", | |
| "type", | |
| "media", | |
| ], | |
| video: [ | |
| "src", | |
| "controls", | |
| "playsInline", | |
| "preload", | |
| "poster", | |
| "width", | |
| "height", | |
| "title", | |
| "ariaLabel", | |
| ], | |
| "bb-thread-mention": [ | |
| "dataThreadId", | |
| "dataRawThreadId", | |
| "dataRawThreadInlineCode", | |
| ], | |
| "bb-prompt-mention": ["dataMentionIndex"], | |
| "bb-message-directive": ["dataDirectiveIndex"], | |
| }, | |
| }, | |
| ], |
History:
- Raw HTML was first added only for markdown file previews. That commit said "conversation/default markdown surfaces remain HTML-disabled": 1a32e41
- Fix byte ranges for thread-storage videos #4343 (c730a01) turned on
allowHtmlin five places so that agent-written<video>renders: both assistantMarkdownPreviews, bothGeneratedConversationMessageones, and the user bubble'sCollapsibleMessageText. The PR and Thread-storage file route ignores Range, so a stored video cannot seek and does not play in Safari #4339 only cover agent output. Nothing in them asks for HTML in user-authored text. - Without
allowHtml, react-markdown 10.1.0 turnsrawnodes into text nodes (lib/index.js:parent.children[index] = {type: 'text', value: node.value}). That is why user HTML showed literally before.
Suggested fix: remove allowHtml from CollapsibleMessageText. User text then renders as it did before #4343. Agent output keeps sanitized HTML and <video>.
What you ruled out
- Not script execution:
onerroris removed byrehype-sanitize, and no alert or dialog fired. I am filing this as a normal bug, not a security report. - Not fixed after
b23150d88: none of the 43 commits onmainup to36aacc040changeallowHtmlin the timeline. Defer Markdown parsing and reduce shared workspace JavaScript #4520 only moved the rehype plugins intomarkdown-html.tsx. - Not a duplicate. Searches for html, raw html, details tag, escape html, sanitize, XSS, markdown user message, html tags message, literal, rehype, allowHtml, and angle brackets found no issue about HTML in messages. The closest results are unrelated: Codex file-citation directives render as raw text: bb parses
:codex-file-citation{…}then discards the parsed attributes #2933 and Message directive embeds render as literal text when prose follows::name{…}on the same line #4409 (directives shown as literal text) and Relative markdown links in plugin-embedded ThreadChat open as broken URLs against the app origin #4438 (relative links in ThreadChat). - Whether assistant output should render HTML is a separate question. This report only covers user-authored messages.
Suggested priority and effort
Low to medium priority, small effort (one prop). It affects anyone who pastes HTML, XML-like, or JSX snippets as prose instead of in a code fence. The workaround is to wrap the text in backticks or a code fence. The tags themselves disappear from the displayed message (for example <Foo> in prose), and text inside <details> is collapsed out of view. The stored prompt is not changed.
AGENT GENERATED
Activity
Show typed HTML literally in user message bubbles (#4553)