Security / Field note
A customer filename should not choose a server path
File validation, storage names and download permissions answer different questions. Customer documents need an application-owned identity throughout their lifecycle.
Imagine a hypothetical customer portal where distributors upload invoices and supporting documents. The original filename is useful to the people handling an order. It can be familiar, descriptive and entirely unsuitable as an instruction about where the server should put the file.
Our view is that a customer document needs an application-owned identity as soon as it enters the workflow. Its display name, physical storage location and permission to retrieve it are related pieces of information, but none should silently stand in for the others.
An accepted file is still outside input
OWASP recommends permitted file types, application-generated storage names, size limits and authorized upload access. It favors storage on a separate host or outside the webroot, with an application handler mapping public references to stored files where retrieval is needed. [1]
The browser's Content-Type declaration is supplied by the user, and OWASP warns against trusting it for security. File-signature checks are also only one layer, rather than a complete validation decision. [1]
In PHP, finfo_file() returns information about a file's contents, and the manual demonstrates MIME-type identification. The function can also return false on error. That describes a content-inspection capability; it does not make every returned type an application approval. [2]
PHP's move_uploaded_file() checks that its source arrived through PHP's HTTP POST upload mechanism before moving it. The destination is a separate argument, and the manual warns that an existing destination file will be overwritten. [3]
Those functions answer useful, bounded questions. One examines a file; another verifies upload provenance before a move. The application still owns the decision about acceptable content, the destination it chooses and the business record to which the document belongs.
A display name is not a storage address
Return to the hypothetical distributors. Two customers can both submit a document called invoice.pdf without either doing anything suspicious. Their documents still need separate identities, clear ownership and a deliberate replacement policy. An original filename is useful metadata, not a reliable uniqueness guarantee.
We would treat that distinction as a product decision as well as an implementation detail. Replacing an attachment, adding a revised invoice and submitting an unrelated document are different actions. The application should know which action is intended instead of letting a collision in storage decide the result.
An application-controlled reference can represent the document while the server chooses its actual location. The customer-facing name can remain available for display or download without becoming authority over the filesystem. This is our interpretation of the storage boundary, rather than a claim about a tested portal.
OWASP also recommends limiting filesystem permissions and keeping uploaded material away from the application's public serving area. Those controls help preserve the separation between customer-supplied data and the software handling it. [1]
Private storage still needs a permission decision
A generated identifier does not settle who may read the document. OWASP's direct-object-reference guidance says complex identifiers are an additional defense, while access checks remain essential whenever a user attempts to reach an object. [4]
For the hypothetical portal, knowing a document reference should therefore be different from being entitled to download it. A forwarded link, a bookmarked address or a reference appearing in another workflow should not become an accidental permission grant.
That is where upload handling meets the wider ownership model. The document's customer, order and permitted audience have meaning after the upload screen has closed. A download route needs the same business context as the screen that originally displayed the attachment.
An internal preview, a background conversion and a later export can extend that lifecycle. In our judgment, each handoff should preserve the intended document identity and access boundary. Merely finding the expected file in the expected folder leaves those later decisions unexplained.
Keep the responsibilities visible
For an application owner, a useful design discussion separates the decision to accept a document, the authority to place it in storage and the authority to release it again. That makes ownership clearer when upload handling, document processing and customer support belong to different teams.
A customer should still be able to submit a legitimate document and retrieve the right attachment. The purpose of these boundaries is to preserve that work while keeping a browser-supplied name from choosing a server location or an unintended audience. The filename can stay helpful to people without becoming a command to the application.
Sources + further reading
Source dates describe the original material. Publication above is the date this Zyel article went live.
- File Upload Cheat SheetOWASP Cheat Sheet Series · Checked Nov 11, 2026
- finfo_file: Return information about a filePHP Manual · Checked Nov 11, 2026
- move_uploaded_file: Move an uploaded filePHP Manual · Checked Nov 11, 2026
- Insecure Direct Object Reference Prevention Cheat SheetOWASP Cheat Sheet Series · Checked Nov 11, 2026
Reader discussion
What would you ask next?
Questions, useful corrections and thoughtful disagreement are welcome. Comments are reviewed before they appear.
No reader comments yet.