77can result in sensitive information being revealed or deleted, or an attacker being able to influence
88behavior by modifying unexpected files.</p >
99
10- <p >Paths that are naively constructed from data controlled by a user may be absolute paths or contain
11- unexpected special characters, such as "..". Such a path may potentially point anywhere on the file system.</p >
10+ <p >Paths that are naively constructed from data controlled by a user may be absolute paths, or may contain
11+ unexpected special characters such as "..". Such a path could point anywhere on the file system.</p >
1212
1313</overview >
1414<recommendation >
1515
1616<p >Validate user input before using it to construct a file path.</p >
1717
1818<p >Common validation methods include checking that the normalized path is relative and does not contain
19- any ".." components, or that the path is contained within a safe folder. The validation method to use depends
20- on how the path is used in the application and whether the path is supposed to be a single path component.
21- </p >
19+ any ".." components, or checking that the path is contained within a safe folder. The method you should use depends
20+ on how the path is used in the application, and whether the path should be a single path component.
2221
23- <p >If the path is supposed to be a single path component (such as a file name) you can check for the existence
24- of any path separators ("/" or "\") or ".." sequences in the input, and reject the input if any are found.
22+ <p >If the path should be a single path component (such as a file name), you can check for the existence
23+ of any path separators ("/" or "\"), or ".." sequences in the input, and reject the input if any are found.
2524</p >
2625
2726<p >
@@ -43,14 +42,13 @@ such as "/etc/passwd" or "../../../etc/passwd".</p>
4342<sample src =" examples/TaintedPath.java" />
4443
4544<p >
46- If the input is just supposed to be a file name, you can check that it doesn't contain any path separators
47- or ".." sequences.
45+ If the input should only be a file name, you can check that it doesn't contain any path separators or ".." sequences.
4846</p >
4947
5048<sample src =" examples/TaintedPathGoodNormalize.java" />
5149
5250<p >
53- If the input is supposed to be found within a specific directory, you can check that the resolved path
51+ If the input should be within a specific directory, you can check that the resolved path
5452is still contained within that directory.
5553</p >
5654
0 commit comments