github / github/codeql

JavaScript: Functions flowing through arrays

Ouverte
#18,180 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
question
Langage dominant
CodeQL
Étoiles
10.1k
Forks
2.1k
Merge moyen
2 j 15 h
PR mergées (30 j)
141

Description

Taint analysis seems to not work for arrays:
```js
const fs = require('fs')

function readFileHelper(p) {
fs.readFile(p) // <- detected
}

function readFileHelper2(p) {
fs.readFile(p) // <- not detected
}

const reads = [
readFileHelper2
]

const v = process.argv[2];

readFileHelper(v) // work
const res = reads.map(d => d(v)); // not working
for (let d of reads) {
d(v); // not working
}
reads[0](v); // not working
[readFileHelper2].map(d => d(v)); // not working
```
```ql
import javascript

class CommandLineFileNameConfiguration extends TaintTracking::Configuration {
CommandLineFileNameConfiguration() { this = "CommandLineFileNameConfiguration" }

override predicate isSource(DataFlow::Node source) {
DataFlow::globalVarRef("process").getAPropertyRead("argv").getAPropertyRead() = source
}

override predicate isSink(DataFlow::Node sink) {
DataFlow::moduleMember("fs", "readFile").getACall().getArgument(0) = sink
}
}

from CommandLineFileNameConfiguration cfg, DataFlow::Node source, DataFlow::Node sink
where cfg.hasFlow(source, sink)
select source, sink
```
It found `readFileHelper` but not `readFileHelper2`.

There is related issue https://github.com/github/codeql/issues/5177

Pinging gently @erik-krogh

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Start by running the supplied JavaScript reproducer with CommandLineFileNameConfiguration and compare the direct call with map, loop, indexed, and inline-array calls. Read the JavaScript DataFlow and TaintTracking entry points used by DataFlow::Node and hasFlow, with related issue #5177 as context. Done means the query reports the expected flows through these array patterns.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript
Domaine
security
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.