github / github/codeql

JavaScript: Functions flowing through arrays

オープン
#18,180 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
question
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、提供された JavaScript 再現コードを CommandLineFileNameConfiguration で実行し、直接呼び出しと、map、ループ、インデックス付き、インライン配列による呼び出しを比較します。DataFlow::Node と hasFlow が使用する JavaScript の DataFlow および TaintTracking のエントリポイントを読み、関連する issue #5177 をコンテキストとして参照します。これらの配列パターンを通る期待されるフローがクエリによって報告されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript
領域
security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。