File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
swift/ql/src/queries/Security/CWE-022 Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff line change 4
4
<qhelp >
5
5
6
6
<overview >
7
- <p >Accessing paths controlled by users can allow an attacker to access unexpected resources. This
8
- can result in sensitive information being revealed or deleted, or an attacker being able to influence
9
- behavior by modifying unexpected files.</p >
7
+ <p >Accessing paths controlled by users can expose resources to attackers.</p >
10
8
11
9
<p >Paths that are naively constructed from data controlled by a user may contain unexpected special characters,
12
- such as ".." . Such a path may potentially point to any directory on the file system.</p >
10
+ such as < code >..</ code > . Such a path could point to any directory on the file system.</p >
13
11
</overview >
14
12
15
13
<recommendation >
16
14
17
15
<p >Validate user input before using it to construct a file path. Ideally, follow these rules:</p >
18
16
19
17
<ul >
20
- <li >Do not allow more than a single "." character.</li >
21
- <li >Do not allow directory separators such as "/" or "\" (depending on the file system).</li >
22
- <li >Do not rely on simply replacing problematic sequences such as " ../" . For example, after applying this filter to
18
+ <li >Do not allow more than a single < code >.</ code > character.</li >
19
+ <li >Do not allow directory separators such as < code >/</ code > or < code >\</ code > (depending on the file system).</li >
20
+ <li >Do not rely on simply replacing problematic sequences such as < code > ../</ code > . For example, after applying this filter to
23
21
".../...//" the resulting string would still be "../".</li >
24
- <li >Ideally use a whitelist of known good patterns.</li >
22
+ <li >Use a whitelist of known good patterns.</li >
25
23
</ul >
26
24
27
25
</recommendation >
You can’t perform that action at this time.
0 commit comments