Cyber Posture

OWASP ASVS 5.0 · All chapters

V5 File Handling

13 verification requirement(s) in this chapter.

← V4 V6 →

V5.1 File Handling Documentation

IDVerify that…Level
V5.1.1 Verify that the documentation defines the permitted file types, expected file extensions, and maximum size (including unpacked size) for each upload feature. Additionally, ensure that the documentation specifies how files are made safe for end-users to download and process, such as how the application behaves when a malicious file is detected. L2

V5.2 File Upload and Content

IDVerify that…Level
V5.2.1 Verify that the application will only accept files of a size which it can process without causing a loss of performance or a denial of service attack. L1
V5.2.2 Verify that when the application accepts a file, either on its own or within an archive such as a zip file, it checks if the file extension matches an expected file extension and validates that the contents correspond to the type represented by the extension. This includes, but is not limited to, checking the initial 'magic bytes', performing image re-writing, and using specialized libraries for file content validation. For L1, this can focus just on files which are used to make specific business or security decisions. For L2 and up, this must apply to all files being accepted. L1
V5.2.3 Verify that the application checks compressed files (e.g., zip, gz, docx, odt) against maximum allowed uncompressed size and against maximum number of files before uncompressing the file. L2
V5.2.4 Verify that a file size quota and maximum number of files per user are enforced to ensure that a single user cannot fill up the storage with too many files, or excessively large files. L3
V5.2.5 Verify that the application does not allow uploading compressed files containing symlinks unless this is specifically required (in which case it will be necessary to enforce an allowlist of the files that can be symlinked to). L3
V5.2.6 Verify that the application rejects uploaded images with a pixel size larger than the maximum allowed, to prevent pixel flood attacks. L3

V5.3 File Storage

IDVerify that…Level
V5.3.1 Verify that files uploaded or generated by untrusted input and stored in a public folder, are not executed as server-side program code when accessed directly with an HTTP request. L1
V5.3.2 Verify that when the application creates file paths for file operations, instead of user-submitted filenames, it uses internally generated or trusted data, or if user-submitted filenames or file metadata must be used, strict validation and sanitization must be applied. This is to protect against path traversal, local or remote file inclusion (LFI, RFI), and server-side request forgery (SSRF) attacks. L1
V5.3.3 Verify that server-side file processing, such as file decompression, ignores user-provided path information to prevent vulnerabilities such as zip slip. L3

V5.4 File Download

IDVerify that…Level
V5.4.1 Verify that the application validates or ignores user-submitted filenames, including in a JSON, JSONP, or URL parameter and specifies a filename in the Content-Disposition header field in the response. L2
V5.4.2 Verify that file names served (e.g., in HTTP response header fields or email attachments) are encoded or sanitized (e.g., following RFC 6266) to preserve document structure and prevent injection attacks. L2
V5.4.3 Verify that files obtained from untrusted sources are scanned by antivirus scanners to prevent serving of known malicious content. L2
← V4 V6 →

Source: OWASP ASVS 5.0.0 · Licensed under CC BY-SA 4.0 · CWE / NIST 800-53 cross-references are a separate (Phase B) LLM-authored mapping, not yet rendered here.