improvement(files): harden untrusted document preview and parsing - #6420
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview DOCX preview turns off OOXML zip guard adds a per-entry declared uncompressed ceiling (default 64 MiB) on every central-directory entry—not only Reviewed by Cursor Bugbot for commit b4bcd00. Configure here. |
Greptile SummaryThe PR hardens untrusted Office-document handling in both browser previews and server-side parsing.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/docx-preview.tsx | Disables altChunk rendering and applies the new embedded-element cleanup after DOCX rendering; no eligible follow-up defect was established. |
| apps/sim/lib/core/security/url-safety.ts | Adds a focused DOM cleanup utility that removes iframe, object, and embed elements from untrusted rendered content. |
| apps/sim/lib/file-parsers/zip-guard.ts | Adds a per-entry expanded-size ceiling, lowers the aggregate ceiling, and applies the entry limit uniformly across archive parts. |
| apps/sim/lib/file-parsers/zip-guard.test.ts | Covers aggregate and per-entry rejection, non-XML part handling, default limits, and ordinary-document acceptance. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
Upload[Untrusted Office document] --> Preview[DOCX browser preview]
Upload --> Parse[OOXML parser path]
Preview --> Options[Disable altChunk rendering]
Options --> Render[Render document body]
Render --> Sanitize[Sanitize links and remove frames/plugins]
Sanitize --> Display[Display preview]
Parse --> Inspect[Inspect ZIP central directory]
Inspect --> EntryCap{Any entry over 64 MiB?}
Inspect --> TotalCap{Total over 150 MiB?}
EntryCap -->|Yes| Reject[Reject archive]
TotalCap -->|Yes| Reject
EntryCap -->|No| Validate[Validate compression and declared sizes]
TotalCap -->|No| Validate
Validate --> Parser[Run document parser]
Reviews (3): Last reviewed commit: "fix(files): apply the per-entry OOXML ca..." | Re-trigger Greptile
|
@cursor review |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b4bcd00. Configure here.
Summary
docx-previewso it only renders the document body, and drop embedded frames/plugin elements from rendered contentType of Change
Testing
Unit tests for the sanitizer pass and the archive guard (per-entry cap, total cap, media-part scoping); measured against crafted inputs locally. Type-check and lint clean.
Checklist