Skip to content

Commit 6bb54f0

Browse files
atorralbasubatoi
andauthored
Apply suggestions from code review
Co-authored-by: Ben Ahmady <[email protected]>
1 parent e222807 commit 6bb54f0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

swift/ql/src/queries/Security/CWE-022/PathInjection.qhelp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
<qhelp>
55

66
<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>
108

119
<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>
1311
</overview>
1412

1513
<recommendation>
1614

1715
<p>Validate user input before using it to construct a file path. Ideally, follow these rules:</p>
1816

1917
<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
2321
".../...//" 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>
2523
</ul>
2624

2725
</recommendation>

0 commit comments

Comments
 (0)