github / github/codeql

python false positive Clear-text logging of sensitive information

未关闭
#13,538 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
false-positive
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

**Description of the false positive**

I have a python aws lambda that returns a json payload with correctly identified sensitive information (along with metadata like status code, etc.). I have a 'log response' function that specifically logs metadata and no sensitive data, but codeql is reporting that sensitive non-metadata fields are being logged.

**Code samples or links to source code**

```python
def main():
user_creds = ... // sensitive information here
return write_access_log({
"statusCode": 200,
"body": {
"dry_run": False,
# actual sensitive information here
"credentials": {
"db": {
"username": user_creds.username,
"privatekey": user_creds.encrypted_private_key,
"passphrase": user_creds.private_key_passphrase,
}
}
}
})

def write_access_log(resp):
if "statusCode" in resp:
dry_run = (
str(resp["body"]["dry_run"])
if resp.get("body", {}).get("dry_run") is not None
else "unknown"
)
payload = {"statusCode": int(resp["statusCode"]), "dry_run": dry_run}
msg = json.dumps(payload)
# Flagged as 'clear-text logging of sensitive information', showing a path that includes
# "passphrase" from resp which is not logged
logger.info(msg)

return resp
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。