
A document preview is a processing and delivery path for untrusted input. SVG can contain scripts and references, PDFs can contain actions and attachments, and Office files can contain macros, embedded objects, or external links. Storing the file as a business record does not make its contents safe to execute in the application’s browser context.
Design the preview path around separate decisions: whether the file may be stored, whether processing may begin, which rendition may be displayed, and whether the caller may retrieve the original. A clean malware result answers only part of that design.
Keep the original document and its provenance while giving ordinary reviewers the least active representation that supports their task. A page image or sanitized text view can be appropriate for routine review; an original download needs its own permission and handling. Connect every rendition to the exact source version, processing result, and release policy.
FormKiQ’s Anti-Malware / Antivirus module provides ClamAV scanning and scan-result metadata through document-event processing. Configure workflow ordering so a required scan finishes with an acceptable result before preview conversion or release. Scanning, converter isolation, rendition authorization, and browser delivery are distinct controls to verify in the chosen deployment; enabling a scanner does not automatically establish all four.
| Content | Boundary to consider | Conservative preview approach |
|---|---|---|
| SVG or HTML | Scripts, event handlers, embedded markup, and external resources in document-rendering contexts. | Rasterize or use a maintained, restrictive sanitization pipeline; isolate any browser-rendered document. |
| Parser defects, actions, forms, links, attachments, and hidden content. | Generate page renditions or use a maintained viewer with deliberately restricted features and delivery. | |
| Office files | Macros, external templates, linked data, embedded objects, and conversion behavior. | Convert in isolation without executing macros or fetching external resources; verify the generated output. |
| Unknown, encrypted, or failed input | Content cannot be inspected or converted with the approved processing path. | Return an explicit unavailable or review state. Preserve the original under policy without automatically opening it inline. |
SVG behavior depends on how it is embedded. The W3C’s SVG security notes distinguish image use, where scripts are disabled, from document embedding. A thumbnail rendered through an image element does not establish that the same uploaded SVG is safe when opened directly or through a different viewer.
Allow the business formats the system supports, then compare the submitted name and content type with detected content and structural parsing. A file signature is one signal, not proof that every parser will interpret the file the same way. Handle mismatches and ambiguous formats explicitly rather than letting the browser choose how to execute them.
Apply size, page-count, image-dimension, archive-expansion, nesting, and processing-time limits. The OWASP File Upload Cheat Sheet recommends layered validation and scanning rather than reliance on a single check. Use safe generated storage identifiers and keep untrusted filenames from controlling paths or response headers.
Keep pending, rejected, and unscannable files out of ordinary previews, search thumbnails, and downstream conversion. A scan-completed event is not equivalent to a clean result. Check the result, permitted processing state, source version, and relevant policy before progressing. Define what happens when the scanner is unavailable, times out, or cannot inspect an encrypted file.
Bind the scan and converter input to the same captured bytes. If a user replaces the source, the earlier scan and rendition must not authorize the new version. Keep the source identifier, version or checksum, detected type, scan engine and definitions, timestamp, and result with the processing record.
A scan that finds no known malware does not certify that active document features are acceptable. A legitimate script, link, or macro may still violate the preview policy. Keep isolation and rendering restrictions in place for clean files.
A converter parses attacker-controlled structures before the browser sees a rendition. Run it with narrowly scoped access to the assigned input and output, no application session credentials, a restricted filesystem, bounded resources, timeouts, and disposable working storage. If a runtime requires an execution identity, scope it to the job instead of giving it broad document-administration privileges.
Block unnecessary outbound network access, including external document resources and access to internal services or instance metadata. Disable macros, remote templates, external entities, and linked-content retrieval where relevant. Enforce these restrictions at the runtime or network boundary as well as through converter options.
Record converter and configuration versions, patch the processing stack, and validate that outputs match the expected rendition format. Conversion failure should produce a controlled review state. It must not silently switch the preview to the original file or rerun the job with broader permissions.
Serve potentially active content away from the application’s privileged origin. Verify that the content host receives no application session cookies or bearer tokens; a sibling hostname is insufficient if cookies are scoped to a shared parent domain. Restrict cross-origin access to application APIs and preserve the normal server-side authorization and request-forgery controls. CORS is not a replacement for authorization.
Apply a restrictive Content Security Policy to the response that actually serves the untrusted document, not only to the parent application page. Configure permitted embedding parents and sandbox permissions for the selected viewer. Blocking all framing would also break an intentionally embedded preview, so test the policy with the intended delivery path.
The MDN iframe reference warns against combining allow-scripts and allow-same-origin for content served from the parent’s origin. Keep sandbox permissions minimal and test direct navigation as well as embedding. A viewer that requires additional capabilities needs an explicit isolation design rather than copied sandbox flags.
For SVG sanitization, use a maintained implementation with an explicit supported subset instead of string replacement. For PDFs and Office files, verify how the chosen tool handles actions, embedded files, links, and external resources. A conversion to PDF does not by itself establish that the output is inert.
Check the caller’s current access to the document, source version, and requested representation before issuing a retrieval grant. Preview permission need not include the original, embedded attachments, or bulk export. Apply the same rules to thumbnails, search results, sharing routes, and cached artifacts.
Use validated content types, suitable Content-Disposition, and X-Content-Type-Options: nosniff for the delivery path. Configure caching so one user’s authorized response cannot become another user’s accessible preview. Protect signed retrieval URLs from logs and referrer leakage, and define the remaining access window after a grant is withdrawn.
An attachment response is a delivery instruction, not a guarantee that the file is safe when opened on a recipient’s device. Keep original downloads explicit, with policy-appropriate handling and evidence. For redacted or restricted renditions, verify that alternate routes cannot expose the unredacted original or hidden content.
A supplier uploads an SVG containing script and external references. Capture version V-12 and its checksum. The malware scan reports no known malware; the file remains subject to the active-content policy.
An isolated worker processes the captured version with script execution disabled and external fetching blocked and produces an approved raster rendition. Record the converter version, result, and source-to-rendition mapping.
An authorized reviewer receives the generated image. A direct request for the original SVG is evaluated separately and cannot inherit the application’s browser privileges.
A later version fails validation or conversion. Keep it in a review state instead of serving the original inline or relabeling V-12’s rendition as a preview of the replacement.
Keep known-safe business files in the corpus too, including accessibility and rendering requirements. Monitor failed scans, converter crashes, blocked outbound requests, resource-limit violations, and outdated renditions. Reprocessing after an incident or tool update should preserve provenance and update the permitted delivery state.
Review FormKiQ’s Anti-Malware / Antivirus module, Security and Governance, and Integration Frameworks.
Talk to FormKiQ about scan ordering, isolated conversion, rendition access, and browser delivery for your supported document formats.
The open-source foundation — API-first, deployable into your own AWS account, and free to use. Right for architecture validation and early implementation.
Production-ready editions for departments and complex workflows. Start with a Proof-of-Value deployment or go straight to production.
For governance-heavy environments with residency, sovereignty, assurance, and multi-jurisdiction requirements. Talk to us about the right deployment model.