From 05a59d2a94d1424c6c0ecb8708efa6bd9eee8c61 Mon Sep 17 00:00:00 2001
From: erik-krogh
Paths that are naively constructed from data controlled by a user may be absolute paths or contain -unexpected special characters, such as "..". Such a path may potentially point anywhere on the file system.
+Paths that are naively constructed from data controlled by a user may be absolute paths, or may contain +unexpected special characters such as "..". Such a path could point anywhere on the file system.
Validate user input before using it to construct a file path.
Common validation methods include checking that the normalized path is relative and does not contain -any ".." components, or that the path is contained within a safe folder. The validation method to use depends -on how the path is used in the application and whether the path is supposed to be a single path component. -
+any ".." components, or checking that the path is contained within a safe folder. The method you should use depends +on how the path is used in the application, and whether the path should be a single path component. -If the path is supposed to be a single path component (such as a file name) you can check for the existence -of any path separators ("/" or "\") or ".." sequences in the input, and reject the input if any are found. +
If the path should be a single path component (such as a file name), you can check for the existence +of any path separators ("/" or "\"), or ".." sequences in the input, and reject the input if any are found.
@@ -43,14 +42,13 @@ such as "/etc/passwd" or "../../../etc/passwd".
-If the input is just supposed to be a file name, you can check that it doesn't contain any path separators -or ".." sequences. +If the input should only be a file name, you can check that it doesn't contain any path separators or ".." sequences.
-If the input is supposed to be found within a specific directory, you can check that the resolved path +If the input should be within a specific directory, you can check that the resolved path is still contained within that directory.