CodeQL miss to detect a vulnerability because of irrelvant code?
- Linguagem predominante
- CodeQL
- Estrelas
- 10.1k
- Forks
- 2.1k
- Merge médio
- 2d 15h
- PRs com merge (30d)
- 141
Descrição
The problem is when I scan these files of code:
./main.js:
```javascript
(() => {})(), // this line makes the codeql neglect the vulnerability?
(() => {
let fe = require('./source.js').s;
let e = fe();
window.location.href = e;
})();
```
./source.js:
```javascript
module.exports.s = function() {
let e = window.location.href.split("#")[1];
return decodeURIComponent(e);
};
```
CodeQL doesn't report any vulnerability but if I comment the first line of main.js, like:
```javascript
// (() => {})(),
(() => {
let fe = require('./source.js').s;
let e = fe();
window.location.href = e;
})();
```
It detected one, which is:
```csv
"Client-side URL redirect","Client-side URL redirection based on unvalidated user input may cause redirection to malicious web sites.","error","Untrusted URL redirection depends on a [[""user-provided value""|""relative:///source.js:2:11:2:30""]].
Untrusted URL redirection depends on a [[""user-provided value""|""relative:///source.js:2:11:2:25""]].","/main.js","5","26","5","26"
```
Is there an issue? Since the part of code `(() => {})()` which seems irrelevant to the vulnerability to me affects the query result.
The version of the codeql that I use:
```bash
CodeQL command-line toolchain release 2.18.3.
Copyright (C) 2019-2024 GitHub, Inc.
Unpacked in: ...
Analysis results depend critically on separately distributed query and
extractor modules. To list modules that are visible to the toolchain,
use 'codeql resolve qlpacks' and 'codeql resolve languages'.
```
And here is the command I use:
```bash
codeql database create --language=javascript codeql-database --source-root="./sourcecode"
codeql database analyze ./codeql-database/ $CODE_QL/codeql-repo/javascript/ql/src/Security/CWE-601/ClientSideUrlRedirect.ql --format=csv --output="result.csv" --threads=10
cat result.csv | grep redirect
```
Guia de contribuição
Direção de pesquisa
Reproduce the scan with main.js and source.js using the provided database creation and ClientSideUrlRedirect.ql command, comparing results with and without the first IIFE. Inspect the reported locations and query output to determine why the unrelated statement changes the result; done means the behavior is explained and the relevant CodeQL analysis issue is addressed.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript
- Domínio
- security, tooling
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100