Repository navigation
fix(media): keep script-capable sources out of links and frames - #148
pratikbuilds wants to merge 1 commit into
Conversation
|
All contributors have signed the CLA. |
e46130d to
ddce89f
Compare
TheGreatAxios
left a comment
There was a problem hiding this comment.
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) —ddce89fincluded finding 4 (src/hooks/use-media-viewer.tsandsrc/hooks/use-media-viewer.test.ts), and0f4a976(fix(media): leave the shrinking-list close for its own change) reverted those files rather than amendingddce89f. Both commits also have body lines exceeding 72 characters (0f4a976is 80 chars;ddce89fhas 73–74 char lines and still describes item 4 in its body). PerCONTRIBUTING.md:36-40, squash into a single commit whose message describes only findings 2 and 3 with body lines<= 72characters.- PR
#148body (reviewer) — The PR summary and verification section still claim finding 4 (shrinking listsanduse-media-viewer.test.ts), which causescorbits-triageto fail (Focused: mixes unrelated changes). Update the PR body to reflect only themedia-srcandmedia-viewerchanges.
Should-fix
None.
Informational
None.
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.
0f4a976 to
94f51d1
Compare
TheGreatAxios
left a comment
There was a problem hiding this comment.
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.
|
Triage: Pass No changes needed from you. A maintainer will review this pull request. |
Nothing triage asked to change still fails, so this request no longer stands.
Summary
Keeps script-capable sources out of links and frames in
MediaViewer(findings 2 and 3).data:image/svg+xmlthrough. That is safe in an<img>, but as atarget="_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 onlyhttp:,https:andblob:. Adata:image still shows; it just gets no Download link.<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 checkbun run dep-guardmedia-src.test.tsandmedia-viewer.test.tsxCloses #142