From 05a59d2a94d1424c6c0ecb8708efa6bd9eee8c61 Mon Sep 17 00:00:00 2001 From: erik-krogh Date: Thu, 25 Jan 2024 11:20:46 +0100 Subject: [PATCH] apply suggestions from doc review --- .../src/Security/CWE/CWE-022/TaintedPath.qhelp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/java/ql/src/Security/CWE/CWE-022/TaintedPath.qhelp b/java/ql/src/Security/CWE/CWE-022/TaintedPath.qhelp index 0be037515850..0e854370425f 100644 --- a/java/ql/src/Security/CWE/CWE-022/TaintedPath.qhelp +++ b/java/ql/src/Security/CWE/CWE-022/TaintedPath.qhelp @@ -7,8 +7,8 @@ can result in sensitive information being revealed or deleted, or an attacker being able to influence behavior by modifying unexpected files.

-

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.

@@ -16,12 +16,11 @@ unexpected special characters, such as "..". Such a path may potentially point a

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.