|
1 | 1 | ### github/codeql |
2 | 2 |
|
3 | | -[javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L5-L5) |
| 3 | +[javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L5) |
4 | 4 |
|
5 | 5 | <pre><code class="javascript">function cleanupTemp() { |
6 | 6 | let cmd = "rm -rf " + path.join(__dirname, "temp"); |
7 | 7 | cp.execSync(<strong>cmd</strong>); // BAD |
8 | 8 | } |
9 | 9 | </code></pre> |
10 | 10 |
|
11 | | -*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4).* |
| 11 | +*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4).* |
12 | 12 |
|
13 | 13 | #### Paths |
14 | 14 |
|
15 | 15 | <details> |
16 | 16 | <summary>Path with 5 steps</summary> |
17 | 17 |
|
18 | | -1. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4) |
| 18 | +1. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4) |
19 | 19 | <pre><code class="javascript"> path = require("path"); |
20 | 20 | function cleanupTemp() { |
21 | 21 | let cmd = "rm -rf " + path.join(<strong>__dirname</strong>, "temp"); |
22 | 22 | cp.execSync(cmd); // BAD |
23 | 23 | } |
24 | 24 | </code></pre> |
25 | 25 |
|
26 | | -2. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4) |
| 26 | +2. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4) |
27 | 27 | <pre><code class="javascript"> path = require("path"); |
28 | 28 | function cleanupTemp() { |
29 | 29 | let cmd = "rm -rf " + <strong>path.join(__dirname, "temp")</strong>; |
30 | 30 | cp.execSync(cmd); // BAD |
31 | 31 | } |
32 | 32 | </code></pre> |
33 | 33 |
|
34 | | -3. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4) |
| 34 | +3. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4) |
35 | 35 | <pre><code class="javascript"> path = require("path"); |
36 | 36 | function cleanupTemp() { |
37 | 37 | let cmd = <strong>"rm -rf " + path.join(__dirname, "temp")</strong>; |
38 | 38 | cp.execSync(cmd); // BAD |
39 | 39 | } |
40 | 40 | </code></pre> |
41 | 41 |
|
42 | | -4. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4-L4) |
| 42 | +4. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L4) |
43 | 43 | <pre><code class="javascript"> path = require("path"); |
44 | 44 | function cleanupTemp() { |
45 | 45 | let <strong>cmd = "rm -rf " + path.join(__dirname, "temp")</strong>; |
46 | 46 | cp.execSync(cmd); // BAD |
47 | 47 | } |
48 | 48 | </code></pre> |
49 | 49 |
|
50 | | -5. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L5-L5) |
| 50 | +5. [javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/src/Security/CWE-078/examples/shell-command-injection-from-environment.js#L5) |
51 | 51 | <pre><code class="javascript">function cleanupTemp() { |
52 | 52 | let cmd = "rm -rf " + path.join(__dirname, "temp"); |
53 | 53 | cp.execSync(<strong>cmd</strong>); // BAD |
|
58 | 58 |
|
59 | 59 | ---------------------------------------- |
60 | 60 |
|
61 | | -[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6) |
| 61 | +[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6) |
62 | 62 |
|
63 | 63 | <pre><code class="javascript">(function() { |
64 | 64 | cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
|
67 | 67 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
68 | 68 | </code></pre> |
69 | 69 |
|
70 | | -*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6).* |
| 70 | +*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6).* |
71 | 71 |
|
72 | 72 | #### Paths |
73 | 73 |
|
74 | 74 | <details> |
75 | 75 | <summary>Path with 3 steps</summary> |
76 | 76 |
|
77 | | -1. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6) |
| 77 | +1. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6) |
78 | 78 | <pre><code class="javascript">(function() { |
79 | 79 | cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
80 | 80 | cp.execSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // BAD |
81 | 81 |
|
82 | 82 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
83 | 83 | </code></pre> |
84 | 84 |
|
85 | | -2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6) |
| 85 | +2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6) |
86 | 86 | <pre><code class="javascript">(function() { |
87 | 87 | cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
88 | 88 | cp.execSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // BAD |
89 | 89 |
|
90 | 90 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
91 | 91 | </code></pre> |
92 | 92 |
|
93 | | -3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6-L6) |
| 93 | +3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L6) |
94 | 94 | <pre><code class="javascript">(function() { |
95 | 95 | cp.execFileSync('rm', ['-rf', path.join(__dirname, "temp")]); // GOOD |
96 | 96 | cp.execSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // BAD |
|
102 | 102 |
|
103 | 103 | ---------------------------------------- |
104 | 104 |
|
105 | | -[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8) |
| 105 | +[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8) |
106 | 106 |
|
107 | 107 | <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
108 | 108 |
|
|
111 | 111 |
|
112 | 112 | </code></pre> |
113 | 113 |
|
114 | | -*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8).* |
| 114 | +*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8).* |
115 | 115 |
|
116 | 116 | #### Paths |
117 | 117 |
|
118 | 118 | <details> |
119 | 119 | <summary>Path with 3 steps</summary> |
120 | 120 |
|
121 | | -1. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8) |
| 121 | +1. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8) |
122 | 122 | <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
123 | 123 |
|
124 | 124 | execa.shell('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK |
125 | 125 | execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
126 | 126 |
|
127 | 127 | </code></pre> |
128 | 128 |
|
129 | | -2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8) |
| 129 | +2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8) |
130 | 130 | <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
131 | 131 |
|
132 | 132 | execa.shell('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK |
133 | 133 | execa.shellSync('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
134 | 134 |
|
135 | 135 | </code></pre> |
136 | 136 |
|
137 | | -3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8-L8) |
| 137 | +3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L8) |
138 | 138 | <pre><code class="javascript"> cp.execSync('rm -rf ' + path.join(__dirname, "temp")); // BAD |
139 | 139 |
|
140 | 140 | execa.shell(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK |
|
146 | 146 |
|
147 | 147 | ---------------------------------------- |
148 | 148 |
|
149 | | -[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9) |
| 149 | +[javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9) |
150 | 150 |
|
151 | 151 | <pre><code class="javascript"> |
152 | 152 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
|
155 | 155 | const safe = "\"" + path.join(__dirname, "temp") + "\""; |
156 | 156 | </code></pre> |
157 | 157 |
|
158 | | -*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9).* |
| 158 | +*This shell command depends on an uncontrolled [absolute path](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9).* |
159 | 159 |
|
160 | 160 | #### Paths |
161 | 161 |
|
162 | 162 | <details> |
163 | 163 | <summary>Path with 3 steps</summary> |
164 | 164 |
|
165 | | -1. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9) |
| 165 | +1. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9) |
166 | 166 | <pre><code class="javascript"> |
167 | 167 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
168 | 168 | execa.shellSync('rm -rf ' + path.join(<strong>__dirname</strong>, "temp")); // NOT OK |
169 | 169 |
|
170 | 170 | const safe = "\"" + path.join(__dirname, "temp") + "\""; |
171 | 171 | </code></pre> |
172 | 172 |
|
173 | | -2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9) |
| 173 | +2. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9) |
174 | 174 | <pre><code class="javascript"> |
175 | 175 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
176 | 176 | execa.shellSync('rm -rf ' + <strong>path.join(__dirname, "temp")</strong>); // NOT OK |
177 | 177 |
|
178 | 178 | const safe = "\"" + path.join(__dirname, "temp") + "\""; |
179 | 179 | </code></pre> |
180 | 180 |
|
181 | | -3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9-L9) |
| 181 | +3. [javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js](https://github.com/github/codeql/blob/48015e5a2e6202131f2d1062cc066dc33ed69a9b/javascript/ql/test/query-tests/Security/CWE-078/tst_shell-command-injection-from-environment.js#L9) |
182 | 182 | <pre><code class="javascript"> |
183 | 183 | execa.shell('rm -rf ' + path.join(__dirname, "temp")); // NOT OK |
184 | 184 | execa.shellSync(<strong>'rm -rf ' + path.join(__dirname, "temp")</strong>); // NOT OK |
|
0 commit comments