JS: `js/command-line-injection` misses `child_process` argument arrays when the `shell` option is set
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 18/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- express, javascript, nodejs
- Área
- security
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- CodeQL
- Estrellas
- 10.2k
- Forks
- 2.1k
- Merge medio
- 2 d 15 h
- PR fusionados (30 d)
- 153
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de github/codeql
-
false-positive javascript
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
github/codeql#22632 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add AlertSuppression.ql for Rust (inline // codeql[...] suppression)Posiblemente ocupada @cnuss la tomó hace 197 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
github/codeql#21637 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
false-positive
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
github/codeql#21076 · 3 comentarios · 3 reacciones ·
Los mantenedores suelen responder en 1 día
-
bug Swift
Dificultad 4/5 3-5 días Aptitud para principiantes 15/100
github/codeql#22803 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Actions: `uses: $/…` self-repository references are not resolved to local reusable workflows or composite actions (false positives and downgraded severity)Posiblemente ocupada @WilliamBerryiii la tomó hace 7 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 62/100
github/codeql#22755 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de github/codeql
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
ci-cd from-review-extraction severity:nit
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
LearningCircuit/local-deep-research#7479 ·
Los mantenedores suelen responder en 2 días
-
auth type: bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
googleapis/google-cloud-swift#1469 ·
Los mantenedores suelen responder en 1 día
-
Add a SECURITY.mdPosiblemente ocupada @islarmeeyah-cyber la tomó hoy. Abiertodocumentation good first issue Stellar Wave
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
OlaGreat/starbound-realms#109 · 1 comentario ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día