CodeQL unable to find out sources of a chosen dataflow node in Javascript
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 25/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript
研究方向
首先重現 JavaScript 程式碼片段和提供的 CodeQL 查詢,然後閱讀提到的 DataFlow::Node API:getASuccessor*、getAPredecessor*、getALocalSource* 和 getALocalUse。完成的標準是:一個簡單查詢能夠識別出流入 s + c 的五個預期節點:表達式、c、""、s 和 window.location。
由索引模型根據 Issue 內容生成。
描述
Hi, for the following snippet i'm interested in finding out what nodes flow to s + c node.
function main() {
let s = window.location;
let c = "";
let input = s + c;
eval(input);
}
By looking at the snippet, the answer clearly consists of five dataflow nodes. s + c itself, c , "" , s , window.location.
The followings are methods i tried so far.
CodeQL query for locating s + c explicitly by providing location
import javascript
class SinkNode extends DataFlow::Node {
SinkNode() {
exists(DataFlow::Node node |
node.hasLocationInfo("filepath to the snippet",
4, 15, 4, 19) and
this = node
)
}
}
class TestSucessor extends DataFlow::Node {
TestSucessor() {
exists(DataFlow::Node node |
node instanceof Sink and
exists(DataFlow::Node source |
source.getASuccessor*() = node and
this = source
)
)
}
}
This would only mark s + c as a predecessor.
class TestPredecessor extends DataFlow::Node {
TestPredecessor() {
exists(DataFlow::Node node |
node instanceof Sink and
this = node.getAPredecessor*()
)
}
}
This would only mark s + c as a predecessor.
class TestLocalSource extends DataFlow::Node {
TestLocalSource() {
exists(DataFlow::Node node |
this = node.getALocalSource*() and
node instanceof Sink
)
}
}
class TestLocalUse extends DataFlow::SourceNode {
TestLocalUse() {
exists(DataFlow::SourceNode src |
exists(DataFlow::Node node |
node instanceof Sink and
src.getALocalUse() = node and
this = src
)
)
}
}
Neither mark anything out.
I would see that an overkill for this issue is simply using tainted analysis. Mark s+c as sink and use any() for the source. However, i want to keep it simple. Any idea how to do it simply?
Many thanks.
- 主要語言
- CodeQL
- 星號
- 10.1k
- 分支
- 2.1k
- 平均合併
- 2 天 10 小時
- 30 天內合併 PR
- 134
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/codeql 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
-
難度 2/5 1-3 小時 新手友好度 82/100
-
難度 2/5 1-3 小時 新手友好度 78/100
-
false-positive
難度 2/5 1-3 小時 新手友好度 70/100
-
false-positive
難度 3/5 1-2 天 新手友好度 68/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
-
難度 1/5 1 小時以內 新手友好度 92/100
-
難度 1/5 1-3 小時 新手友好度 86/100
DavidAnson/markdownlint-cli2#940 ·
-
難度 1/5 1 小時以內 新手友好度 72/100
EclipseFdn/open-vsx.org#13385 · 1 則留言 ·
-
bug ci good first issue
難度 2/5 1-3 小時 新手友好度 88/100