False negative: missing os.exec* APIs with `sh -c` as sink in py/code-injection.
- Ngôn ngữ chính
- CodeQL
- Star
- 10.1k
- Fork
- 2.1k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 141
Mô tả
**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
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với truy vấn py/code-injection và so sánh cách xử lý sink os.system và subprocess.run(shell=True) hiện có với ví dụ os.execl đã được báo cáo. Chạy ví dụ tối thiểu và các biến thể tương đương, sau đó xác minh rằng các lệnh bị nhiễm độc được truyền qua sh -c được báo cáo, trong khi các kiểm soát hiện có vẫn được bao phủ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- security
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 55/100