JS: `js/command-line-injection` misses `child_process` argument arrays when the `shell` option is set
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 18/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- express, javascript, nodejs
- Bereich
- security
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.2k
- Forks
- 2.1k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 153
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus github/codeql
-
false-positive javascript
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
github/codeql#22632 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)Evtl. vergeben @cnuss hat das vor 199 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
github/codeql#21637 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
false-positive
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
github/codeql#21076 · 3 Kommentare · 3 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug Swift
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 15/100
github/codeql#22803 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Actions: `uses: $/…` self-repository references are not resolved to local reusable workflows or composite actions (false positives and downgraded severity)Evtl. vergeben @WilliamBerryiii hat das vor 9 Tagen übernommen. OffenActions
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 62/100
github/codeql#22755 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
hierynomus/sshj#1070 ·
-
needs-human
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
melodic-software/claude-code-plugins#8405 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
comp/cli P3 type/security
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
NousResearch/hermes-agent#141420 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
CKV_GCP_18 (GKEPublicControlPlane) passes when master_authorized_networks_config is absent, control plane is internet-reachableEvtl. vergeben @Varshith-Kali hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
bridgecrewio/checkov#7753 ·
Maintainer antworten meist innerhalb von 1 Tag
-
e2e-failure ready-to-code
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
redhat-developer/rhdh-plugin-export-overlays#4435 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag