Secure file uploads in web apps: a business checklist

Secure file uploads in a web application require more than an “Add attachment” button. A file should first pass server-side checks in an isolated area and only then become available to an authorised user. For a business portal, a sensible starting point is private storage, a narrow list of allowed formats, explicit limits and a “pending checks” status. Neither a filename extension nor a successful transfer means an attachment is safe.

A business owner does not have to choose an antivirus engine. They do need to know what to ask a supplier for and how to accept the finished feature. This guide covers receiving service photos and documents in a portal, not public file hosting or automated AI analysis of their contents.

First decide which attachments the business actually needs

When planning a business application with Webiant, start with the process: who uploads the file, which record it belongs to, who may open it and when it should be deleted. If a service team needs a photo of a fault and a PDF report, there is no reason to allow archives, executables or arbitrary office documents by default.

OWASP recommends allowing only extensions required for the business function, limiting file size, replacing filenames with application-generated names and checking upload authorisation. These measures complement one another; none is sufficient on its own.

Decision Recommended requirement Trade-off
Formats Allow only specific types that are needed Less convenience for unusual documents
Limits Set limits for file size, attachment count and storage per customer Large submissions need a separate procedure
Availability Release files only after successful checks Users may have to wait briefly
Retention Assign an owner and a deletion rule The rule must cover temporary copies too

Example: a service portal with photos and a report

Illustrative example, not a real customer result: a company receives equipment warranty claims. A customer can add up to five JPEG, PNG or PDF attachments to one request, each no larger than 10 MB. These are proposed product rules, not a universal security standard.

After transfer, the portal displays “Attachment received; checks pending”. A technician cannot download it yet, and it is not sent as an email attachment. Once checks succeed, its status changes to “Available”. A rejection explains the specific problem, such as an unsupported format, and offers another attempt.

If the checking service does not respond, the file remains unavailable. The portal must not treat a failed check as a successful one. The operator needs an alert and an agreed way to investigate stuck attachments without bypassing protection across the board.

What the server must check, not just the browser

The file picker helps the user, but it is not a security boundary. The MDN documentation for the accept attribute explicitly states that it does not validate file types and that requirements must be validated server-side. Test uploads made outside the normal form as well.

The server should check whether the user may attach a file to that particular request, whether the extension and size are allowed, and whether appropriate content checks confirm the expected type. Do not blindly trust the client-supplied Content-Type header: OWASP warns that it can be spoofed. Matching the type and extension still does not prove that the whole document is harmless.

Keep the original filename as display metadata, not as a storage path. Have the application generate its own identifier and display the original name safely. This separates the user-facing label from the technical location. A file with the same name must not accidentally replace an attachment belonging to another request.

Quarantine: a received file is not yet an approved attachment

Define separate states for “uploading”, “pending checks”, “available”, “rejected” and “check failed”. Here, quarantine means a private area from which ordinary users and connected processes cannot read the file. It is not merely a coloured label in an administration screen.

OWASP recommends antivirus or sandbox checks where available and, for suitable formats, additional processing to remove risky elements. Ask the supplier to propose the combination based on the formats and risks. A clean antivirus result is not a safety guarantee. Type checks, authorisation, isolation and safe processing remain necessary.

The same principle applies to previews: do not create them by processing unverified content without restrictions. Define processing limits, isolation and failure behaviour. Until the attachment is approved, downstream automation must not consume it and notifications must not distribute it.

Private downloads and the pitfalls of signed links

OWASP recommends a separate server or storage outside the public web root. For private business attachments, require storage without anonymous access. On every download request, the application should check current permission for that specific attachment; knowing its identifier is not enough.

One option is a short-lived signed link issued after that check. The Amazon S3 documentation confirms time-limited access, but also states that a presigned URL can be used repeatedly until it expires. Do not automatically describe it as single-use. Anyone who obtains it can use it within its permissions and validity period.

Keep signed URLs out of analytics, public pages and routine support records. If revoking access must take effect on every subsequent download, route downloads through the application with a fresh permission check instead of relying only on the expiry of a previously issued link. For presigned S3 uploads, using an existing object key also replaces that object; design unique keys and a controlled upload-completion step.

How to introduce the feature without an oversized project

  1. Write down the rules. Prepare a matrix of users, attachment types, limits and retention. Include technicians and administrators.
  2. Choose the transfer route. Uploading through the application centralises checks; direct-to-storage uploads require separate handling of permission, limits and verification of the received object.
  3. Implement quarantine and state transitions. Release a file only after all mandatory checks, not after an “upload complete” response.
  4. Connect downstream processes. In a custom software workflow, notifications and processing should react to an available attachment, not merely to a newly created record. The Webiant technical guides provide related reading when preparing your specification.
  5. Test failures and cleanup. Define what happens when checks are unavailable, uploads are incomplete or storage is exhausted. Verify deletion of the file and its temporary derived copies.

Start with the required formats and one process. Supporting archives, multimedia or public links is an additional requirement with its own risks, not a free extension of the same button. A wider scope can mean more checking and operational work; without knowing volume and requirements, no specific price or saving can be promised.

Acceptance checklist before launch

  • An unsupported type is rejected even after its extension is renamed and when the server is called directly.
  • Oversized files and excessive attachment counts produce understandable errors.
  • Customer A cannot obtain customer B’s attachment by changing an identifier or opening a preview.
  • An anonymous visitor cannot open an object through its direct storage address.
  • Pending or rejected files cannot be downloaded or passed to another process.
  • A checking outage does not create an “available” status and is visible to the operator.
  • A repeated upload does not overwrite an approved file; an expired signed link no longer works.
  • Deletion removes the required copies under the agreed rule and is verified by a test.

A common mistake is testing only a valid PDF. Another is treating an unguessable filename as a substitute for authorisation. A third is allowing downloads while antivirus checks are pending so users “do not have to wait”. These shortcuts undo an important part of the intended protection.

Frequently asked questions

Is allowing only PDF files enough?

No. A narrow allowlist reduces the range of supported formats, but it does not replace server-side checks, safe processing or download permissions. An allowed format is still untrusted input.

Does every attachment need an antivirus check?

The checks should be designed around risk and file formats. For a portal receiving external business documents, requiring a checking layer and a clear failure policy is sensible. If the specification makes that check mandatory, an outage must not automatically approve the file.

Is a signed link single-use?

Not automatically. In the cited S3 documentation, it is reusable until expiry. Genuine single-use access needs a separate application-level control; a time limit alone does not provide it.

Can security be added after launch?

Improvements are possible, but private storage, the state model and access checks should be designed before the first real attachments arrive. Retrofitting them may require moving old files and checking that their original URLs no longer expose them.

Prepare a specification around your process

If you are planning a customer or internal portal, list the attachments, user groups and situations in which a file must not be released. Use the Webiant contact page to share that description and discuss the scope of the application design. Do not send sensitive real documents at the outset; anonymised samples are enough to explain the process.

Sources

Choose which cookies to allow. You can change your choice at any time using the footer link or cookie button.

Privacy policy and cookie details