Skip to content

Commit 6675dda

Browse files
committed
add more libraries that serve static files to js/exposure-of-private-files
1 parent ac1a0d9 commit 6675dda

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ DataFlow::Node getAPrivateFolderPath(string description) {
105105
* Gest a call that serves the folder `path` to the public.
106106
*/
107107
DataFlow::CallNode servesAPrivateFolder(string description) {
108-
result = DataFlow::moduleMember("express", "static").getACall() and
108+
result = DataFlow::moduleMember(["express", "connect"], "static").getACall() and
109+
result.getArgument(0) = getAPrivateFolderPath(description)
110+
or
111+
result = DataFlow::moduleImport("serve-static").getACall() and
109112
result.getArgument(0) = getAPrivateFolderPath(description)
110113
}
111114

javascript/ql/test/query-tests/Security/CWE-200/PrivateFileExposure.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@
1414
| private-file-exposure.js:18:1:18:74 | app.use ... les"))) | Serves the folder "/node_modules", which can contain private information. |
1515
| private-file-exposure.js:19:1:19:88 | app.use ... lar/')) | Serves the folder "/node_modules/angular/", which can contain private information. |
1616
| private-file-exposure.js:22:1:22:58 | app.use ... lar/')) | Serves the folder "/node_modules/angular/", which can contain private information. |
17+
| private-file-exposure.js:40:1:40:88 | app.use ... lar/')) | Serves the folder "/node_modules/angular/", which can contain private information. |
18+
| private-file-exposure.js:41:1:41:97 | app.use ... lar/')) | Serves the folder "/node_modules/angular/", which can contain private information. |

javascript/ql/test/query-tests/Security/CWE-200/private-file-exposure.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@ app.use('/js/', express.static('node_modules/bootstrap/dist/js'))
3535
app.use('/css/', express.static('node_modules/font-awesome/css'));
3636
app.use('basedir', express.static(__dirname)); // GOOD, because there is no package.json in the same folder.
3737
app.use('/monthly', express.static(__dirname + '/')); // GOOD, because there is no package.json in the same folder.
38+
39+
const connect = require("connect");
40+
app.use('/angular', connect.static(path.join(__dirname, "/node_modules") + '/angular/')); // NOT OK
41+
app.use('/angular', require('serve-static')(path.join(__dirname, "/node_modules") + '/angular/')); // NOT OK

0 commit comments

Comments
 (0)