JS: `js/command-line-injection` misses `child_process` argument arrays when the `shell` option is set
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 一週以上
- 新手友好度
- 18/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- express, javascript, nodejs
- 領域
- security
研究方向
The gap is in the CodeQL JavaScript libraries, not in the issue's sample app: look at CommandInjection::SystemCommandExecutionSink and UnsafeShellCommandConstruction (executesArrayAsShell) to see how the shell option is treated. Run the three sample routes through the javascript-security-extended queries to reproduce the missed reports. Done means /b and /c are flagged by a command-injection query with tests covering shell: true and a string shell value.
由索引模型根據 Issue 內容生成。
描述
Description of the issue
js/command-line-injection does not report remote input that reaches the argument array of spawn/execFile when the shell option is set, although Node.js then runs the joined command line in a shell. Checked with the latest release, CodeQL 2.27.2 (codeql/javascript-queries 2.4.7).
const cp = require("child_process");
const app = require("express")();
app.get("/a", (req, res) => {
cp.exec("echo hello " + req.query.name); // reported
res.send("ok");
});
app.get("/b", (req, res) => {
cp.spawn("echo", ["hello", req.query.name], { shell: true }); // not reported
res.send("ok");
});
app.get("/c", (req, res) => {
cp.spawn("echo", ["hello", req.query.name], { shell: "/bin/sh" }); // not reported
res.send("ok");
});
Only /a is reported, by js/command-line-injection. For /b and /c, no query in javascript-security-extended.qls reports a command injection. At runtime both run /bin/sh -c "echo hello <name>" (Node.js joins [file, ...args] with spaces when shell is truthy; see the spawn documentation), so name = "x; touch /tmp/marker" creates the file (Node.js v24.18.0).
As far as I can tell, CommandInjection::SystemCommandExecutionSink only uses getACommandArgument(), which for spawn/execFile is the program name. The argument array is treated as shell-interpreted only in UnsafeShellCommandConstruction (executesArrayAsShell), i.e. for library inputs, and even there only for
shell: true: with a string-valued shell such as "/bin/sh", js/shell-command-constructed-from-input misses the call as well.
- 主要語言
- CodeQL
- 星號
- 10.2k
- 分支
- 2.1k
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 153
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
github/codeql 的其他 Issue
-
false-positive javascript
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)可能已有人在做 @cnuss 於 196 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
false-positive
難度 2/5 1-3 小時 新手友好度 70/100
github/codeql#21076 · 3 則留言 · 3 個 reaction ·
維護者通常 1 天內回覆
-
bug Swift
難度 4/5 3-5 天 新手友好度 15/100
維護者通常 1 天內回覆
-
Actions: `uses: $/…` self-repository references are not resolved to local reusable workflows or composite actions (false positives and downgraded severity)可能已有人在做 @WilliamBerryiii 於 6 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 62/100
github/codeql#22755 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
jbacalso24/mimry#291 ·
維護者通常 1 天內回覆
-
ci-cd from-review-extraction python security severity:suggested
難度 2/5 1-3 小時 新手友好度 72/100
LearningCircuit/local-deep-research#7454 ·
維護者通常 2 天內回覆
-
Change oauth client name?可能已有人在做 @nealrichardson 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 66/100
posit-dev/rsconnect-python#870 ·
維護者通常 1 天內回覆
-
feedback
難度 2/5 1-3 小時 新手友好度 62/100
useagenthq/useagent#153 ·
維護者通常 2 天內回覆
-
enhancement frontend good first issue
難度 2/5 1-3 小時 新手友好度 72/100
anujsharma8d/mockspire#7 · 1 則留言 ·