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

Skip to content

Commit 6f29a87

Browse files
committed
move logInjection out of experimental
1 parent f6c3588 commit 6f29a87

7 files changed

Lines changed: 25 additions & 121 deletions

File tree

javascript/ql/src/experimental/Security/CWE-117/LogInjection.help renamed to javascript/ql/src/Security/CWE-117/LogInjection.qhelp

File renamed without changes.

javascript/ql/src/experimental/Security/CWE-117/LogInjection.ql renamed to javascript/ql/src/Security/CWE-117/LogInjection.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* insertion of forged log entries by a malicious user.
55
* @kind path-problem
66
* @problem.severity error
7-
* @precision high
7+
* @precision medium
88
* @id js/log-injection
99
* @tags security
1010
* external/cwe/cwe-117
1111
*/
1212

1313
import javascript
1414
import DataFlow::PathGraph
15-
import LogInjection::LogInjection
15+
import semmle.javascript.security.dataflow.LogInjection::LogInjection
1616

1717
from LogInjectionConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink
1818
where config.hasFlowPath(source, sink)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const http = require('http');
2+
const url = require('url');
3+
4+
const server = http.createServer((req, res) => {
5+
let q = url.parse(req.url, true);
6+
7+
console.info(`[INFO] User: ${q.query.username}`); // BAD: User input logged as-is
8+
})
9+
10+
server.listen(3000, '127.0.0.1', () => {});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const http = require('http');
2+
const url = require('url');
3+
4+
const server = http.createServer((req, res) => {
5+
let q = url.parse(req.url, true);
6+
7+
// GOOD: remove newlines from user controlled input before logging
8+
let username = q.query.username.replace(/\n|\r/g, "");
9+
10+
console.info(`[INFO] User: ${username}`);
11+
});
12+
13+
server.listen(3000, '127.0.0.1', () => {});

javascript/ql/src/experimental/Security/CWE-117/examples/logInjectionBad.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

javascript/ql/src/experimental/Security/CWE-117/examples/logInjectionGood.js

Lines changed: 0 additions & 51 deletions
This file was deleted.

javascript/ql/src/experimental/Security/CWE-117/LogInjection.qll renamed to javascript/ql/src/semmle/javascript/security/dataflow/LogInjection.qll

File renamed without changes.

0 commit comments

Comments
 (0)