github / github/codeql

CodeQL analysis does not detect expected command injection vulnerability

オープン
#19,811 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
question
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 15時間
マージ済み PR(30日)
141

説明

**Hello CodeQL team**,

I'm currently integrating CodeQL into our CI workflow for an end-to-end security test of our backend system.

Here's the procedure I followed:

Setup:
**Downloaded the CLI:**
wget https://github.com/github/codeql-cli-binaries/releases/latest/download/codeql-linux64.zip
unzip codeql-linux64.zip
sudo mv codeql /usr/local/bin/

**Cloned the CodeQL repository with Python libraries:**
git clone https://github.com/github/codeql.git

**Inside the backend directory, created the database:**
codeql database create db-python --language=python --source-root=.

**Ran the analysis:**
codeql database analyze db-python codeql/python/ql/src/codeql-suites/python-lgtm-full.qls --format=sarifv2.1.0 --output=python-code-scanning-sec-all.sarif

**Checked the results:**
jq '.runs[].results[] | {message: .message.text, severity: .level, location: .locations[0].physicalLocation.artifactLocation.uri}' python-code-scanning-sec-all.sarif

**Problem**
Before running the scan, I added the following code snippet to the backend intentionally to trigger a command injection warning:

```
import os
user_input = input("Enter command: ")
os.system(user_input) # ⚠️ This should trigger a CodeQL rule: command injection
```
However, the scan results do not include any findings related to this vulnerable code.

**Question**
Am I missing something in the setup or the suite configuration?
Is there a different CodeQL query or suite that should be used to detect this specific type of vulnerability (e.g., command injection via os.system) in Python?

Any help or guidance would be much appreciated!

Best regards,
Anton

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Reproduce the report with the shown Python snippet, the db-python database, and codeql/python/ql/src/codeql-suites/python-lgtm-full.qls. Inspect the generated python-code-scanning-sec-all.sarif results and the suite configuration to determine why no finding appears. Done means identifying the cause and documenting the required query or setup for detecting this case.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。