github / github/codeql

py/HardcodedCredentials misses common credential patterns and flags usernames.

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

説明

Some patterns are missing, for example:
```python
api_key = "sk-1234567890" # Missed: API key
db_url = "postgres://user:pass@host/db" # Missed: URL credentials
```

Second, I am not sure if the username is seen as a credential in a usual project, but this rule will flag the username.
This is beyond the definition in CWE-798 (
The product contains hard-coded credentials, such as a password or cryptographic key.)

```python
USERNAME = "admin" # Flagged
```

I also found that the rule will lose the taint in the following case:
```python
USERNAME = "road_runner"
PASSWORD = "insecure_pwd"
options = {"password": PASSWORD}

conn = client.connect(username=USERNAME, password=PASSWORD) # Flagged
log.debug("Options: %s", options) # Missing
conn = client.connect(options=options) # Still Missing
```

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

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

調査の方向性

Start with the py/HardcodedCredentials rule and reproduce the API-key, URL-credential, username, and options examples from the issue. Read how the rule models credential patterns and propagates taint through the options dictionary. Done means the missing credential cases are detected without treating ordinary usernames as credentials, with coverage for the reported examples.

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

評価

技術スタック
python
領域
security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

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

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