Skip to content

fix(media): keep script-capable sources out of links and frames - #148

Open
pratikbuilds wants to merge 1 commit into
corbitsdev:mainfrom
pratikbuilds:claude/i142-media-viewer-af93aa
Open

pratikbuilds wants to merge 1 commit into
corbitsdev:mainfrom
pratikbuilds:claude/i142-media-viewer-af93aa

Conversation

@pratikbuilds

@pratikbuilds pratikbuilds commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Keeps script-capable sources out of links and frames in MediaViewer (findings 2 and 3).

  • Download link: the link reused the media-element allowlist, which lets data:image/svg+xml through. That is safe in an <img>, but as a target="_blank" href it opens an SVG document that can run script. The link now uses a "link" sink (the internal "frame" sink, renamed) that accepts only http:, https: and blob:. A data: image still shows; it just gets no Download link.
  • PDF preview removed: PDFs rendered in an unsandboxed <iframe>, so a URL labelled as a PDF that serves HTML ran script. Chrome refuses its PDF viewer in any sandboxed frame, and checking the bytes would mean fetching the URL, so a PDF now shows "No preview for this file." with its Download link. In Chrome, Download opens the native PDF viewer in a new tab.

Behaviour change: PDFs no longer preview inline. The README row and the component docs say so.

Verification

  • bun run check
  • bun run dep-guard
  • Updated tests in media-src.test.ts and media-viewer.test.tsx

Closes #142

@corbits-triage corbits-triage Bot left a comment •

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.

Triage requests changes:

  • Focused: mixes unrelated changes

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA.
Posted by the CLA Assistant Lite bot.

@corbits-triage corbits-triage Bot left a comment •

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.

Triage requests changes:

  • CI green: required checks are failing
  • No ai attribution: a commit message contains "Co-Authored-By:"; remove it

@cursor
cursor Bot force-pushed the claude/i142-media-viewer-af93aa branch from e46130d to ddce89f Compare October 30, 2026 12:10

@corbits-triage corbits-triage Bot left a comment •

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.

Triage requests changes:

  • Focused: mixes unrelated changes

@TheGreatAxios TheGreatAxios left a comment

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.

Review · Request changes

Summary

The safeMediaSrc "link" sink and PDF <iframe> removal across src/lib/media-src.ts, src/ui/media-viewer.tsx, README.md, and unit tests are clean and pass bun run check and bun run dep-guard, but the commit history and PR description still include the backed-out use-media-viewer shrinking-list change (ddce89f + revert commit 0f4a976).

Blockers

  • git log main..HEAD (ddce89f, 0f4a976) (reviewer) — ddce89f included finding 4 (src/hooks/use-media-viewer.ts and src/hooks/use-media-viewer.test.ts), and 0f4a976 (fix(media): leave the shrinking-list close for its own change) reverted those files rather than amending ddce89f. Both commits also have body lines exceeding 72 characters (0f4a976 is 80 chars; ddce89f has 73–74 char lines and still describes item 4 in its body). Per CONTRIBUTING.md:36-40, squash into a single commit whose message describes only findings 2 and 3 with body lines <= 72 characters.
  • PR #148 body (reviewer) — The PR summary and verification section still claim finding 4 (shrinking lists and use-media-viewer.test.ts), which causes corbits-triage to fail (Focused: mixes unrelated changes). Update the PR body to reflect only the media-src and media-viewer changes.

Should-fix

None.

Informational

None.

@corbits-triage
corbits-triage Bot dismissed stale reviews from themself October 30, 2026 17:11

Nothing triage asked to change still fails, so this request no longer stands.

The Download link reused the media-element allowlist, which lets a
data:image/svg+xml through. That is safe in an <img>, but as a
target="_blank" href it opens an SVG document that can run script. The
link now uses a "link" sink (the old "frame" sink, renamed now that no
frame uses it) that takes only http:, https: and blob:. A data: image
still shows; it is just not offered for download.

PDFs rendered in an unsandboxed <iframe>, so a URL labelled as a PDF
that serves HTML ran script and could navigate the top page. Chrome
refuses its PDF viewer in any sandboxed frame, and proving the bytes
are a PDF would mean fetching the URL, which the package does not do.
A PDF now gets the "No preview for this file." state with its Download
link, which in Chrome opens the native viewer in a new tab.
@pratikbuilds
pratikbuilds force-pushed the claude/i142-media-viewer-af93aa branch from 0f4a976 to 94f51d1 Compare November 2, 2026 17:10

@corbits-triage corbits-triage Bot left a comment •

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.

Triage requests changes:

  • CI green: required checks are failing
    • policy-check

@TheGreatAxios TheGreatAxios left a comment

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.

Approving. The download link only accepts http, https, and blob, so a data SVG can still render and cannot be opened as a document. PDF preview is gone; there is no iframe.

The history is one commit and the body no longer mentions the shrinking-list change.

@corbits-triage

corbits-triage Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

@corbits-triage
corbits-triage Bot dismissed their stale review November 4, 2026 07:14

Nothing triage asked to change still fails, so this request no longer stands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-ups from the conversation PR review

2 participants