Skip to content

Commit b428246

Browse files
committed
add qhelp for js/exposure-of-private-files
1 parent 345283f commit b428246

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

javascript/ql/src/Security/CWE-200/PrivateFileExposure.qhelp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,33 @@
55

66
<overview>
77
<p>
8-
Placeholder
8+
Libraries like <code>express</code> provide easy methods for serving entire
9+
directories of static files from a web server.
10+
However, using these can sometimes lead to accidential information exposure.
11+
If for example the <code>node_modules</code> folder is served, then an attacker
12+
can access the <code>_where</code> field from a <code>package.json</code> file,
13+
which gives the attacker access to the absolute path of the file.
914
</p>
1015
</overview>
1116

1217
<recommendation>
1318
<p>
14-
Placeholder
19+
Limit which folders of static files are served from a web server.
1520
</p>
1621
</recommendation>
1722

1823
<example>
1924
<p>
20-
Placeholder
25+
In the example below all the files from the <code>node_modules</code> are served.
26+
This allows clients easy access to all files inside that folder, but also allows
27+
access to potentially private information inside <code>package.json</code> files.
2128
</p>
29+
<sample src="examples/FileAccessToHttp.js"/>
30+
<p>
31+
The issue has been fixed in the below by only serving specific folders within the
32+
<code>node_modules</code> folder.
33+
</p>
34+
<sample src="examples/FileAccessToHttpFixed.js"/>
2235
</example>
2336

2437
<references>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
var express = require('express');
3+
4+
var app = express();
5+
6+
app.use('/node_modules', express.static(path.resolve(__dirname, '../node_modules')));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
var express = require('express');
3+
4+
var app = express();
5+
6+
app.use("jquery", express.static('./node_modules/jquery/dist'));
7+
app.use("bootstrap", express.static('./node_modules/bootstrap/dist'));

0 commit comments

Comments
 (0)