Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe9aa24

Browse files
committed
add qhelp
1 parent 4d1920e commit fe9aa24

3 files changed

Lines changed: 30 additions & 9 deletions

File tree

javascript/ql/src/Security/CWE-829/InsecureDownload.qhelp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,35 @@
44
<qhelp>
55
<overview>
66
<p>
7-
Placeholder
7+
Downloading executeables or other sensitive files over an unencrypted connection
8+
can leave a server open to man-in-the-middle attacks (MITM).
9+
Such a man-in-the-middle attack can allow an attacker to insert arbitary content
10+
into the downloaded file, and in the worst case allow the attacker to execute
11+
arbitary code on the vulnerable system.
812
</p>
9-
1013
</overview>
1114
<recommendation>
12-
1315
<p>
14-
Placeholder
16+
Use an transfer protocol that includes encryption when downloading executeables or other sensitive files.
1517
</p>
16-
1718
</recommendation>
1819
<example>
19-
2020
<p>
21-
Placeholder
21+
In this example a server downloads a shell script from a remote URL using the <code>node-fetch</code>
22+
library, and then executes this shell script.
2223
</p>
23-
24+
<sample src="examples/insecure-download.js" />
25+
<p>
26+
The HTTP protocol is vulnerable to MITM, and thus an attacker could potentially replace the downloaded
27+
shell script with arbitary code, which allows the attacker complete control over the attacked system.
28+
</p>
29+
<p>
30+
The issue has been fixed in the below example by replacing the HTTP protocol with the HTTPS protocol.
31+
</p>
32+
<sample src="examples/insecure-download.js" />
2433
</example>
2534

2635
<references>
36+
<li>OWASP: <a href="https://owasp.org/www-community/attacks/Man-in-the-middle_attack">Man-in-the-middle attack</a>.</li>
2737
</references>
28-
2938
</qhelp>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const fetch = require("node-fetch");
2+
const cp = require("child_process");
3+
4+
fetch('http://mydownload.example.org/myscript.sh')
5+
.then(res => res.text())
6+
.then(script => cp.execSync(script));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const fetch = require("node-fetch");
2+
const cp = require("child_process");
3+
4+
fetch('https://mydownload.example.org/myscript.sh')
5+
.then(res => res.text())
6+
.then(script => cp.execSync(script));

0 commit comments

Comments
 (0)