fix(ui): reject protocol-relative URLs in safeUrl - #84
Merged
helsome merged 1 commit intoSep 12, 2026
Conversation
helsome
previously requested changes
Sep 11, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
这条安全修复 scope 很小,方向也合理,不要求扩大实现。正式通过前请补齐当前统一测试报告最低字段:
- Bun 版本 + OS/平台;
- 实际执行
bun test packages/ui/src/components/chat/MarkdownContent.test.tsx的 pass/fail 数量; - rebase 最新 main 后跑基础 CI。
这是 UI 交互安全变化但没有可见样式变化,可以明确写“无可见 UI 变化”,无需为了这条专门做截图。
wcy12378
force-pushed
the
fix/harden-safeurl-protocol-relative
branch
from
September 12, 2026 01:49
fd58eea to
dfa2bdd
Compare
Contributor
Author
PR #84 测试报告(已 rebase 最新 main)环境
变更范围基础 CI
MarkdownContent.test.tsx 实测结果
说明
|
helsome
dismissed
their stale review
September 12, 2026 02:40
作者已补齐 Bun/OS、实际 5 pass / 0 fail、最新 main rebase,并明确无可见 UI 变化;原测试报告 blocker 已解决。
helsome
approved these changes
Sep 12, 2026
helsome
left a comment
Owner
There was a problem hiding this comment.
已补齐统一测试报告最低字段并 rebase 最新 main:Bun 1.4.2 / Windows 11,MarkdownContent focused test 5 pass / 0 fail,typecheck 通过。该变更是窄范围 URL 安全修复,无可见 UI 样式变化,不要求额外截图。
This was referenced Sep 12, 2026
lhy-dcf
pushed a commit
to lhy-dcf/folio
that referenced
this pull request
Sep 12, 2026
Co-authored-by: wcy12378 <kris@folio.local>
lhy-dcf
pushed a commit
to lhy-dcf/folio
that referenced
this pull request
Sep 12, 2026
Co-authored-by: wcy12378 <kris@folio.local>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes a link-injection gap in
MarkdownContent'ssafeUrl()(introduced by #44 / issue #28).A protocol-relative URL like
//evil.com/stealstarts with/, so the existing early-return branch treated it as a safe relative link and skipped the scheme allowlist. The browser then resolves it tohttps://evil.com/steal— an attacker-controlled host. That is exactly the link-injection vector tracked in #16 (prompt injection → malicious link).This PR hard-blocks
//protocol-relative URLs at the top ofsafeUrl()so every external link is forced through the allowlist, without touching the streaming renderer or the rest of #44.Changes
packages/ui/src/components/chat/MarkdownContent.tsx: reject//-prefixed URLs before the relative-path check.packages/ui/src/components/chat/MarkdownContent.test.tsx: add regression tests —//evil.comand//github.com/xare NOT rendered as clickablehrefs (label still shown), whilehttps://…and real relative paths keep working.Why a separate small PR (not reopening #57)
#57 was closed as
supersededbecause #44 already landed the streaming-hardening for #28. This fix is a narrow, independent security hardening on top of #44'ssafeUrl()— no reimplementation, no dual-maintenance. Per the maintainer's note on #57, independent security gaps should be split into small PRs.Test
bun test packages/ui/src/components/chat/MarkdownContent.test.tsxRefs
#28 (security acceptance), #16