-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathImageLookup.js
More file actions
36 lines (24 loc) · 1019 Bytes
/
ImageLookup.js
File metadata and controls
36 lines (24 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const fs = require("fs");
const { logger } = require("../Logger");
class ImageLookup {
get(req, res) {
/* File Traversal exploit */
/* Can read any file in the server by passing the filename (image) in the query params */
/* ex: http GET http://localhost:8089/api/v1/image-lookup image=="package.json" */
const fileContent = fs.readFileSync(req.query.image).toString();
// **************************************************
// ************************************************** Vulnerable Code Block *****
logger.debug(fileContent);
res.send(fileContent);
// ************************************************** Remediated Code Block *****
// string sanitizedStr = sanitizeString(fileContent)
// fileContent = sanitizedStr;
// logger.debug(sanitizedStr);
// res.send(sanitizedStr);
}
// function sanitizeString(str){
// str = str.replace(/[^a-z0-9áéíóúñü \.,_-]/gim,"");
// return str.trim();
// }
}
module.exports = ImageLookup;