Skip to content

Commit a616059

Browse files
Fix example in JavaScript query
1 parent 882caf4 commit a616059

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

javascript/ql/src/Security/CWE-843/examples/TypeConfusionThroughParameterTampering.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ var app = require("express")(),
44
app.get("/user-files", function(req, res) {
55
var file = req.param("file");
66
if (file.indexOf("..") !== -1) {
7-
// BAD
8-
// forbid paths outside the /public directory
7+
// BAD: we forbid relative paths that contain ..
8+
// as these could leave the public directory
99
res.status(400).send("Bad request");
1010
} else {
1111
var absolute = path.resolve("/public/" + file);

javascript/ql/src/Security/CWE-843/examples/TypeConfusionThroughParameterTampering_fixed.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ var app = require("express")(),
33

44
app.get("/user-files", function(req, res) {
55
var file = req.param("file");
6-
if (typeof path !== 'string' || file.indexOf("..") !== -1) {
7-
// BAD
8-
// forbid paths outside the /public directory
6+
if (typeof file !== 'string' || file.indexOf("..") !== -1) {
7+
// BAD: we forbid relative paths that contain ..
8+
// as these could leave the public directory
99
res.status(400).send("Bad request");
1010
} else {
1111
var absolute = path.resolve("/public/" + file);

0 commit comments

Comments
 (0)