-
-
Notifications
You must be signed in to change notification settings - Fork 669
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
user-submitted filename metadata (V12.3) #1427
Comments
Oh, I have postponed to reorganize this section as I have some big tasks here opened already, but in this section are so many things which are incorrect or I just don't like (#1136 (comment)). For a starter:
Related requirements:
edit: update 2024-09-04. Requirement 5.3.9 is deleted as duplicate of 12.3.2, 12.3.3. |
I think this entire "#V12.3 File Execution" should be moved away from V12 - all other requirements in V12 are more related to handling user-uploaded or application generated files as content. V12.6.1 is already waiting to be moved away but there is no clear-good category yet (#1343). From V12.3:
|
@set-reminder 3 weeks @tghosth to look at this |
⏰ Reminder
|
My interpretation is that 12.3.1 is talking about path traversal leading to arbitrary file download and 12.3.2 is talking about using a the filename provided to upload functionality to control where a file is stored, e.g. leading to deleting a sensitive file or a webshell. This seems to be supported by the relevant CWE descriptions. Regardless I agree that the section needs rework. |
Category name for 12.3 is file execution - not file upload (which is separate category 12.1) or file download (which is separate category 12.5) 12.3.1 There are many ways how to reach to file download. For example access control problems - files stored in public folder or IDOR, but we don't duplicate V4 requirements in V12. The same way I think we should handle input validation / sanitization problem in V5 category. 12.3.2/12.3.3 as mentioning LFI and RFI are clear file execution requirements, which is impact. Base problem is still not validated path or url when resource is loaded. Abstractly the same problem as 12.3.1 - "arbitrary resource loading". Again there can be alternative ways how to reach to arbitrary resource loading - using again architecture problems, uploading PHP files (as LFI and RFI mostly are PHP related) to public folder - access it directly and effect is the same. Should we get in some file processing requirements like handling zip files and then see, how we need to change/create categories for them: |
History for 12.3.3:
(That last one is not 100% match) |
This was tagged as V5 but my inclination is to keep it as V12 as it is specific to files and V5 is a little overloaded :) |
This thread got out of hand. I want to address the original posters comments.
I think these comments are spot on and need to be addressed. Here are my thoughts on how to address the OP and how to fix these problems.
I think these are all necessary to ensure that this section (v12) is complete to help folks build secure file uploaded features. |
note that 12.3.5 is removed as duplicate of 5.3.8 My previous comment (#1427 (comment)):
Proposal from Jim is ok from wording perspective, but I question the need to have 3 separate requirements for the same problem in the program code with just having 3 different attack codes to test them.
Many situations in vulnerable program codes matches all 3 at the same time. |
Good call Elar. How about we merge these into one, something like:
|
Merged looks great, @elarlang to do some wording fine tuning |
To also have positive requirement, just some example for the direction:
|
I'd rather not suggest validation or sanitization (this is just too error prone with file operations) and instead just avoid user data for file operations all together. My suggestion: Verify that file operations do not use user-submitted filenames or file metadata when creating filepaths to protect against path traversal, local or remote file inclusion (LFI/RFI), and server-side request forgery (SSRF) attacks, by preventing manipulation of resource paths with data from untrusted sources. |
I don't think it is a realistic suggestion and it is against widespread reality how the application handling uploaded file names (for example). If you upload an attachment to be sent via email, you could suggest that the uploaded file does not have the same name you just uploaded? |
You can upload a file and use an internal trusted name (like an ID) and still preserve the filename for display only. You do not ever need to use the filename for actual file-IO. This is a very common secure dev practice. |
Explanation makes sense, but as one valid option how to do that. If there is validation and sanitization that gives defense, we can not say it is wrong. Let's say there is situation, that only letter and numbers are kept in the user input, with max length 50 symbols and stored as file name. Someone is watching ASVS requirement and points out that the application is not valid for ASVS... |
How about we suggest both?
Avoid using the user data OR validate/sanitize?
|
Yes, this is ok. |
How about this for 12.3.1 (and we eliminate 12.3.2 and 12.3.3) (and 12.3.4 and 12.3.5 are already removed from v12) Verify that file operations do not use user-submitted filenames or file metadata when creating filepaths to protect against path traversal, local or remote file inclusion (LFI/RFI), and server-side request forgery (SSRF) attacks, by preventing manipulation of resource paths with data from untrusted sources. If user-submitted filenames or file metadata must be used in file operations then use strict validation and sanitization. |
@elarlang to confirm on this |
@elarlang ping :) |
Sorry for delay. At the moment the proposed requirement covers all the points but is focused on what not to do, instead of what to do. |
How about: Verify that file operations avoid using user-submitted filenames or file metadata when creating filepaths to protect against path traversal, local/remote file inclusion (LFI/RFI), and server-side request forgery (SSRF) attacks. Instead, use internal, trusted data for file I/O. If user-submitted filenames or file metadata must be used, apply strict validation and sanitization. |
With few changes:
If it looks ok, I'll handle the PR and related modification tags. |
👍🏼
|
Updated:
|
ASVS/0x20-V12-Files-Resources.md at master · OWASP/ASVS · GitHub
I think "filename metadata" is incorrect here. It would be information about the filename, not the filename itself.
I think "filename metadata" should be either "filename" or "file metadata". I would prefer "file metadata", as that would include both the filename and content-type, and any other file information sent by the client.
The text was updated successfully, but these errors were encountered: