CWE-434: Unrestricted file upload | Causes and Fixes Skip to content

Security weaknessCWE Top 25 · #12

CWE-434 Unrestricted file upload

Your site accepts uploaded files without proper checks, so an attacker can upload a file the server will run.

  • Senior security engineers
  • 540+ projects delivered
  • Reply within one business day

Quick answer

What is CWE-434?

Unrestricted Upload of File with Dangerous Type: The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.

Business impact

What CWE-434 could cost your business

MITRE documents what this weakness can do. Here is what that means for a website, store or app.

Confidentiality

Private data exposed

Customer records, credentials, orders or internal files can be read by people who should never see them.

  • Execute Unauthorized Code or Commands

Integrity

Data, pages or code changed

Prices, orders, content or the code your site runs can be altered without your approval.

  • Execute Unauthorized Code or Commands

Availability

Downtime and lost sales

Crashes, slowdowns or exhausted resources can take your site, store or app offline.

  • Execute Unauthorized Code or Commands

In plain English

What Unrestricted file upload means for your business

  • 540+projects delivered
  • 9+years in business
  • 23+certified experts
Get a free security check

A senior engineer replies within one business day.

Many sites let people upload files: profile photos, product images, resumes, support attachments. Unrestricted file upload means the site does not properly limit what kind of file is accepted or where it ends up. If someone uploads a file containing server code, such as a PHP script, and the server stores it in a public folder, requesting that file’s address can cause the server to run it.

Once an attacker can run their own file on your server, they can do almost anything your website can do. That includes reading the database, changing pages, sending spam and installing a backdoor for later. Other dangerous uploads include HTML or SVG files that carry scripts aimed at your visitors, and oversized files that fill your storage. A simple contact form attachment can become the entry point for a full site compromise.

Where it shows up

  • WordPress plugins for contact forms, galleries, imports and profile pictures that save uploads into a public folder without checking the file type on the server.
  • Store features that accept customer files, such as custom print artwork, return photos or review images, and keep the original file name.
  • Job application, support ticket and document portals that accept any attachment and serve it back from the same domain as the application.
  • API endpoints and mobile app backends that accept file uploads and trust the content type or extension reported by the client.

Free security check

Is CWE-434 hiding in your site?

A senior engineer checks your site, store or app for this weakness and the rest of the CWE Top 25, then sends a prioritized fix plan within one business day. No obligation.

Official definition

How MITRE defines CWE-434

Unrestricted Upload of File with Dangerous Type

The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.

Also known as: Unrestricted File Upload

Weakness ID
CWE-434
Type
Base
Status
Draft
Likelihood of exploit
Medium
Applies to
ASP.NET, PHP, Web Server, AI/ML
Introduced during
Implementation, Architecture and Design
2025 CWE Top 25
Rank 12

Fix it

How to fix Unrestricted file upload

Practical steps in priority order. Share them with your developer or agency.

  1. Allowlist file types on the server

    Accept only the extensions you need, such as jpg, png and pdf. Check the extension case-insensitively, reject double extensions, and verify the actual content with a server-side type check. Do not trust the client’s reported content type.

  2. Rename files on the server

    Discard the user-supplied file name. Generate a random name and append an extension from your allowlist. This removes path tricks, hidden extensions and overwrites of existing files in a single step.

  3. Store uploads outside the web root

    Save files in a directory the web server cannot serve directly, or in object storage on a separate domain. Deliver them through a handler that sets a safe content type and a download disposition.

  4. Disable execution in upload folders

    Configure the web server so nothing in the uploads location is ever run as code. Turn off script handlers there in Apache or Nginx, and remove execute permissions. This is a critical safety net.

  5. Limit, scan and re-encode

    Set size and rate limits, and require authentication where the feature allows. Scan uploads for malware. Re-encode images with an image library, which strips embedded content, and treat SVG and HTML as unsafe by default.

Signs you may be affected

  • Upload fields accept files with any extension when you test them.
  • Files with script extensions, such as .php, exist inside your uploads directory.
  • File type checks happen only in the browser, in JavaScript or the form’s accept attribute.

Questions to ask your developer

  • Which features on our site accept file uploads, including plugins and APIs?
  • Can the server execute scripts placed inside our uploads folder?
  • Do we validate file types on the server and rename every upload?

Prevention

What MITRE recommends, phase by phase

Every mitigation from the CWE entry, in the order a project runs: plan, build, test, operate.

  1. 01

    Architecture and Design

    • Generate a new, unique filename for an uploaded file instead of using the user-supplied filename, so that no external input is used at all.[REF-422] [REF-423]
    • When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
    • Consider storing the uploaded files outside of the web document root entirely. Then, use other mechanisms to deliver the files dynamically. [REF-423]
    Show 2 more recommendations
    • Define a very limited set of allowable extensions and only generate filenames that end in these extensions. Consider the possibility of XSS (CWE-79) before allowing .html or .htm file types.
    • For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the.
  2. 02

    Implementation

    • Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of.
    • Ensure that only one extension is used in the filename. Some web servers, including some versions of Apache, may process files based on inner extensions so that "filename.php.gif" is fed to the PHP interpreter.[REF-422] [REF-423]
    • When running on a web server that supports case-insensitive filenames, perform case-insensitive evaluations of the extensions that are provided.
    Show 2 more recommendations
    • Do not rely exclusively on sanity checks of file contents to ensure that the file is of the expected type and size. It may be possible for an attacker to hide code in some file segments that will still be executed by the server. For example, GIF images may contain a free-form comments field.
    • Do not rely exclusively on the MIME content type or filename attribute when determining how to render a file. Validating the MIME content type and ensuring that it matches the extension is only a partial solution.

Detection and evidence

How CWE-434 is found, and where it has hit

The testing methods MITRE recommends, and real vulnerabilities this weakness has caused.

How it is detected

  • Dynamic Analysis with Automated Results InterpretationAccording to SOAR [REF-1479], the following detection techniques may be useful: Web Application Scanner Web Services Scanner Database Scanners
  • Dynamic Analysis with Manual Results InterpretationAccording to SOAR [REF-1479], the following detection techniques may be useful: Fuzz Tester Framework-based Fuzzer
  • Manual Static Analysis – Source CodeAccording to SOAR [REF-1479], the following detection techniques may be useful: Focused Manual Spotcheck – Focused manual analysis of source Manual Source Code Review (not inspections)
  • Automated Static Analysis – Source CodeAccording to SOAR [REF-1479], the following detection techniques may be useful: Source code Weakness Analyzer Context-configured Source Code Weakness Analyzer
  • Architecture or Design ReviewAccording to SOAR [REF-1479], the following detection techniques may be useful: Formal Methods / Correct-By-Construction Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)

Real vulnerabilities it caused

How we fix it

From finding to fixed: how Codefreex closes CWE-434

  1. Scan and confirm

    We test your site, store or app for this weakness and the rest of the CWE Top 25 with automated scanning and manual review, and confirm what is actually exploitable.

  2. Fix at the source

    We change the code, configuration or dependency that causes it, not just the symptom, and plan the changes to avoid downtime.

  3. Verify the fix

    We retest every finding, check that nothing else broke and hand you a short report you can share with your team, client or auditor.

  4. Keep it fixed

    Updates, monitoring and maintenance so the weakness does not return with the next plugin, theme, app or code change.

FAQ

CWE-434: FAQs

Short answers for owners and developers. Not sure whether your site is affected? Ask us to check.

How serious is an unrestricted file upload flaw?

It is among the most serious web weaknesses, because it can give an attacker a direct way to run code on your server. From there they can reach your files and database and stay hidden. MITRE rates the likelihood of exploitation as medium. Even when code cannot run, unsafe uploads can be used against your visitors.

Is checking the file extension enough?

No. An extension check is necessary but not sufficient. File names can carry double extensions or unusual capitalization, and the content may not match the name. Combine an extension allowlist with content verification, server-generated names, storage outside the web root and a server rule that blocks execution in upload folders. Each layer covers gaps in the others.

How do I prevent dangerous file uploads?

Accept only the file types you need and verify them on the server. Rename every file. Store uploads where the server will not execute them, ideally outside the web root or on separate storage. Limit size and frequency, scan for malware, and re-encode images. Review every plugin that adds an upload field to your site.

What is CWE-434?

CWE-434, “Unrestricted Upload of File with Dangerous Type”, is a software weakness catalogued by MITRE in the Common Weakness Enumeration. The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.

How serious is CWE-434?

MITRE rates the likelihood of exploit as Medium. It can affect integrity, confidentiality, availability, with impacts such as execute unauthorized code or commands. It ranks number 12 on the 2025 CWE Top 25 Most Dangerous Software Weaknesses. The real risk depends on where the weakness sits and what data or functions it exposes.

How do you prevent CWE-434?

Generate a new, unique filename for an uploaded file instead of using the user-supplied filename, so that no external input is used at all.[REF-422] [REF-423] When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject.

Can Codefreex check my site for CWE-434?

Yes. A senior engineer reviews your site, store or app for CWE-434 and the rest of the CWE Top 25, confirms what is exploitable and sends a prioritized fix plan within one business day. Start with the free security check form on this page.

Free security check

Find out if CWE-434 affects your site

Send your URL. A senior engineer checks for this weakness and the rest of the CWE Top 25, and replies within one business day with what to fix first.

  • A senior strategist reviews your request, not a sales bot
  • Clear scope, timeline and estimate within one business day
  • Free 30-minute discovery call, no obligation
  • NDA available on request

Weakness data from the Common Weakness Enumeration (CWE®) version 5.0, Copyright © 2006–2026, The MITRE Corporation. CWE is free to use by any organization or individual for any research, development, and/or commercial purposes under the CWE Terms of Use. CWE is a registered trademark of The MITRE Corporation. The business impact, risk profile and plain-English guidance on this page are written by Codefreex and are general information, not a security assessment of your system.