Document security ยท File upload

Secure file upload requirements: validation, scanning, storage, access, and recovery

File upload accepts untrusted content into an application. Safe design requires layered controls across request authorization, validation, processing, storage, retrieval, monitoring, and lifecycle - not one extension check.

Published August 18, 2026 · 20 - 25 minute guide

What this guide helps you decide

This guide gives product owners and development teams a practical requirements framework for business document uploads. It is educational and should be adapted through project-specific security and privacy review.

A file can have a misleading extension, dangerous active content, excessive size, crafted metadata, duplicate name, embedded malware, or sensitive information. Processing libraries and previews can also create attack surface.

Key principle: treat every uploaded file as untrusted, minimize what is accepted, isolate processing and storage, and authorize every later access.

Threat-model the upload workflow

Identify submitters, authentication, file purpose, sensitivity, accepted formats, volume, size, processing, viewers, downstream systems, public exposure, and consequence of malicious or misdirected content.

Consider unauthorized upload, path manipulation, content-type mismatch, parser exploit, malware, denial of service, overwrite, cross-account access, unsafe preview, public URL leakage, and retention failure.

Practical checks

  • List assets and threat actors
  • Map processing components
  • Classify file sensitivity
  • Prioritize controls by impact

Authorize the request

Verify that the user or invitation may upload to the specific account, matter, request, or record. Do not trust a client-supplied owner identifier without backend authorization.

Use expiry, revocation, rate limits, anti-automation controls where appropriate, and clear session handling. Record the authorized relationship at upload time.

Practical checks

  • Check object-level authorization
  • Expire temporary upload access
  • Limit rate and total volume
  • Audit authorization context

Validate content server-side

Use an allowlist of necessary file types, validate size and count, inspect content signatures where appropriate, reject ambiguous or unsupported formats, and normalize metadata.

Extensions and browser-provided MIME types are not sufficient. Keep validation libraries current and avoid complex transformations unless the business needs them.

Practical checks

  • Allow only required types
  • Check content and declared type
  • Set size and count limits
  • Reject malformed inputs safely

Generate safe identifiers and paths

Create server-side storage identifiers rather than using an original filename as a path. Preserve the display name as encoded metadata only where needed.

Prevent overwrite, traversal, reserved names, dangerous characters, and predictable public locations. Associate files with immutable request and tenant identifiers.

Practical checks

  • Generate unique storage keys
  • Keep original names out of paths
  • Prevent overwrite and traversal
  • Preserve tenant association

Scan and isolate processing

Quarantine new files until validation and malware controls complete. Run parsers, converters, OCR, thumbnails, or previews in constrained environments with limited permissions and resources.

Define scan failure, timeout, unavailable scanner, positive detection, rescan, and administrator response. Do not release a file simply because the scanning service failed open.

Practical checks

  • Use quarantine state
  • Constrain processing resources
  • Fail safely on scanner outage
  • Track detection and remediation

Protect storage and retrieval

Use controlled private storage, encryption where appropriate, least-privilege service access, tenant boundaries, backups, and monitored administrative access.

Authorize every download or preview request. Use short-lived access mechanisms where suitable and safe content disposition to reduce inline execution risk.

Practical checks

  • Keep storage non-public by default
  • Authorize each retrieval
  • Use limited-duration access
  • Control download and preview behaviour

Log, monitor, and respond

Record upload actor, request, time, metadata, validation result, scan result, storage identifier, access, review status, deletion, and security events without placing sensitive contents in logs.

Monitor unusual volume, repeated rejection, cross-account attempts, scanner failure, processing errors, and public-access changes. Maintain an incident and containment procedure.

Practical checks

  • Use privacy-conscious audit logs
  • Alert on abnormal patterns
  • Protect log integrity
  • Test incident response

Retain, delete, and test

Assign retention from business purpose, status, legal hold, and applicable obligations. Include derived previews, exports, downstream copies, backups, and temporary processing files.

Test malicious and malformed samples safely, authorization boundaries, large uploads, concurrency, interrupted transfer, duplicate submission, scan outage, storage recovery, expiry, and deletion.

Practical checks

  • Define lifecycle for every copy
  • Remove temporary processing files
  • Test tenant isolation
  • Verify recovery and deletion

Questions to bring to discovery

  • Why is each accepted file type necessary?
  • Is authorization checked against the target record on the server?
  • What happens when scanning or preview processing fails?
  • Can one customer ever retrieve another customer's file?
  • Which copies remain after retention expires?

Next step

Use layered controls and verify them through security testing and operational monitoring. Reassess the design whenever formats, processing, storage, or downstream integrations change.

Design secure file upload scanning as a stateful pipeline

An upload should not become available merely because transport completed. Record it first in a restricted quarantine state, assign an application-generated identifier, enforce the user and target-record authorization, and validate size, extension, detected content type, file signature, filename rules, and archive limits on the server. Client-supplied Content-Type is useful context but not proof of content.

Send the quarantined object to malware scanning and any required content-disarm, preview, or extraction service through an isolated worker. Give processing a time and resource limit. A clean result can promote the object to controlled storage; a malicious, malformed, unsupported, encrypted, or inconclusive result should remain unavailable with an explicit reason and owned resolution path.

StateUser-visible meaningRequired control
ReceivedTransport completed but the file is not availableAuthorization, request limits, safe identifier, and quarantine storage
ScanningSecurity processing is still in progressIsolated worker, timeout, resource limits, and traceable job status
AcceptedThe file passed the defined checksControlled storage, object-level access, safe download headers, and audit history
RejectedThe file cannot enter the workflowSafe reason, no execution or preview, retention rule, and support path
Review requiredAutomated processing could not make a final decisionRestricted access, trained reviewer, recorded disposition, and no silent bypass

Monitor scan failures, queue age, unsupported formats, repeated rejection, storage errors, and attempts to cross a customer or tenant boundary. Simor Soft can adapt the live document-upload workflow with business-specific folders, approval, rejection, messaging, permissions, retention, and integrations while keeping the security decision separate from the business review decision.

File upload validation must agree with the business workflow

A technically clean file can still be attached to the wrong matter, customer, employee, or transaction. For that reason, the upload endpoint should authorize both the person and the target record before accepting content. The same check must run again when someone previews, downloads, replaces, approves, rejects, or deletes the object. Hiding a button in the interface does not establish object-level authorization.

Validation rules should start with what the workflow genuinely needs. An immigration practice may accept passports, signed PDF forms, and supporting images, while an accounting workflow may require statements and spreadsheets. A short allowlist is easier to test than a broad denylist. Extension, detected media type, file signature, filename, size, page count, archive depth, and encryption status each answer a different question; none should be treated as the sole proof that a file is safe.

Compressed files need a separate risk decision

ZIP and other archive formats can hide prohibited content, nested archives, path traversal attempts, and files that expand far beyond their uploaded size. If the business does not need archives, the clearest control is not to accept them. If archives are required, extract them only in an isolated workspace with limits for nesting, file count, expanded size, processing time, and path construction. Every extracted object should pass the same validation and scanning rules as a direct upload.

Plan for scanner outages without silently weakening security

Malware scanning is an external dependency even when the scanner runs inside the same environment. It can be unavailable, slow, overloaded, or unable to classify a particular format. The application therefore needs an explicit failure policy. A fail-open design publishes an unverified file and transfers the risk to every later user. A controlled design keeps the object quarantined, reports a processing delay, retries within defined limits, alerts an owner when the age threshold is exceeded, and never changes the result to accepted merely because a timeout occurred.

Operational teams should be able to distinguish a malicious result from a service failure, an unsupported format, and an inconclusive scan. Those outcomes require different user messages and different retention rules. Security logs should record the object identifier, workflow record, tenant, uploader, scanner version, rule result, timestamps, final disposition, and the staff action used to resolve an exception. Sensitive filenames or document contents do not need to be copied into every log entry.

Test recovery, not only the successful upload

  • Interrupt a scan after the object reaches quarantine and confirm that retry does not create duplicate records.
  • Restore a database and object store to a known point and reconcile files whose metadata and binary state no longer agree.
  • Attempt a download using another customer's identifier and verify that the server denies access without revealing whether the object exists.
  • Expire temporary access while an upload is in progress and define whether the partial object is removed or retained for investigation.
  • Verify that retention deletion covers quarantine, accepted storage, generated previews, temporary extraction folders, backups, and search indexes according to policy.

Measure the secure upload workflow after release

Security controls are easier to sustain when they also expose operational friction. Track accepted and rejected uploads by reason, median and high-percentile scan time, quarantine backlog, retry count, unsupported formats, abandoned requests, cross-tenant denials, storage failures, and manual review age. A sudden rise in rejection can indicate an attack, but it can also reveal that a client process changed and the documented requirements are now incomplete.

Simor Soft can connect these controls to the document workflow that users actually see: requested folders, required-document status, messages, approval and rejection reasons, reminders, role-based access, and an audit history for each case. The goal is not a generic upload box. It is a controlled path from request to verified completion in which the business team can see what is missing while unverified content remains isolated from normal use.

Related document workflow guides

Apply the guidance

Discuss your software requirements with Simor Soft

Bring the current workflow, difficult exceptions, data, systems, users, and measurable outcome. We can help identify a practical next step.