CWE•Base•Draft•20 recent CVEs
CWE-434Unrestricted Upload of File with Dangerous Type
Description
The product allows the upload or transfer of dangerous file types that are automatically processed within its environment.
Common consequences
- Integrity,Confidentiality,Availability→Execute Unauthorized Code or CommandsArbitrary code execution is possible if an uploaded file is interpreted and executed as code by the recipient. This is especially true for web-server extensions such as .asp and .php because these file types are often treated as automatical
Potential mitigations
- Architecture and DesignGenerate 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]
- Architecture and DesignWhen 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.
- Architecture and DesignConsider storing the uploaded files outside of the web document root entirely. Then, use other mechanisms to deliver the files dynamically. [REF-423]
- Implementation[object Object]
- Architecture and DesignDefine 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.
- ImplementationEnsure 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]
- ImplementationWhen running on a web server that supports case-insensitive filenames, perform case-insensitive evaluations of the extensions that are provided.
- Architecture and DesignFor 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 server.
- ImplementationDo 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.
- ImplementationDo 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.
Related CWEs
Recent CVEs classified under this CWE
CVE-2024-583499.82026-06-08CVE-2024-583489.82026-06-08CVE-2026-114747.32026-06-08CVE-2026-75377.22026-06-06CVE-2026-464002026-06-05CVE-2026-114192026-06-05CVE-2026-54118.82026-06-05CVE-2026-463928.72026-06-05CVE-2026-113447.32026-06-05CVE-2026-113336.32026-06-05CVE-2026-425386.32026-06-04CVE-2026-108076.32026-06-04CVE-2026-108066.32026-06-04CVE-2026-405482026-06-01CVE-2026-102056.32026-06-01CVE-2026-101726.32026-05-31CVE-2018-254098.82026-05-30CVE-2018-253888.82026-05-29CVE-2026-392927.32026-05-29CVE-2026-100727.22026-05-29