False negative: missing os.exec* APIs with `sh -c` as sink in py/code-injection.
- Vorherrschende Sprache
- CodeQL
- Sterne
- 10.1k
- Forks
- 2.1k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 141
Beschreibung
**Description of the issue**
py/code-injection flags command injection when the code uses os.system(...) or subprocess.run(..., shell=True), but it does not flag the same tainted command when it is executed through Python os.exec* APIs with sh -c.
A minimal example:
```python
files = request.args.get("files", "")
os.execl("/bin/sh", "sh", "-c", "ls " + files)
```
I also tested equivalent variants (os.execlp, os.execve, and subprocess.run(["sh","-c", ...])) and they were not reported either, while the os.system and shell=True controls were reported.
Sink pattern example in the wild:
https://github.com/ziyan/ssh-otp/blob/ad23edded03ee7d198417d99457d3cfa3df814d1/ssh-otp#L90
There are also code using `python -c
https://github.com/davidfraser/dbghelper/blob/f12b91b468bb640f1cb9d19733afef7696eee9fa/dbg.py#L47
Beitragsleitfaden
Rechercherichtung
Beginne mit der Abfrage py/code-injection und vergleiche deren bestehende Behandlung der Senken os.system und subprocess.run(shell=True) mit dem gemeldeten Beispiel os.execl. Führe das minimale Beispiel und entsprechende Varianten aus und überprüfe anschließend, dass verdächtige Befehle, die über sh -c übergeben werden, gemeldet werden, während die bestehenden Kontrollen weiterhin abgedeckt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- security
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 55/100