Missing code injection TP in JavaScript rule
- Lenguaje dominante
- CodeQL
- Estrellas
- 10.1k
- Forks
- 2.1k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 141
Descripción
The thing is, if I have this code:
```javascript
JSON.parse = function(text, reviver) {
j = eval("(" + text + ")");
};
JSON.parse(window.location.href);
```
CodeQL reported an alert:
```csv
"Code injection","Interpreting unsanitized user input as code allows a malicious user arbitrary code execution.","error","This code execution depends on a [[""user-provided value""|""relative:///test.js:5:12:5:31""]].","/test.js","3","14","3","29"
```
But if I separate the file saying:
`./lib1.js`:
```javascript
JSON.parse = function(text, reviver) {
j = eval("(" + text + ")");
};
```
`./main.js`
```javascript
require("./lib1");
// JSON.parse = function(text, reviver) {
// j = eval("(" + text + ")");
// };
JSON.parse(window.location.href);
```
I can't get that alert anymore. Why did that happen?
I was using codeql and query pack version release 2.20.4.
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.