github / github/codeql

False negative: missing os.exec* APIs with `sh -c` as sink in py/code-injection.

Aberta
#21,735 0 comentários 0 reações 0 responsáveis Ver no GitHub
question
Linguagem predominante
CodeQL
Estrelas
10.1k
Forks
2.1k
Merge médio
2d 15h
PRs com merge (30d)
141

Descrição

**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

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Start with the py/code-injection query and compare its existing os.system and subprocess.run(shell=True) sink handling with the reported os.execl example. Run the minimal example and equivalent variants, then verify that tainted commands passed through sh -c are reported while the existing controls remain covered.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
security
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
55/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.