You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
python false positive Clear-text logging of sensitive information #13538
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
defmain():
user_creds= ... //sensitiveinformationherereturnwrite_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,
}
}
}
})
defwrite_access_log(resp):
if"statusCode"inresp:
dry_run= (
str(resp["body"]["dry_run"])
ifresp.get("body", {}).get("dry_run") isnotNoneelse"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 loggedlogger.info(msg)
returnresp
Thanks for reporting. It looks like you're right. It may be that the analysis is not precise enough and simply assumes that reading an attribute of an object that contains some sensitive data will return the sensitive information. I'll ask the team to have a look, hopefully the analysis can be made more precise.
I just got flagged with Clear-text logging of sensitive information because I pulled down some json from the web, copied a field into a var and logged the var. It was a "stream_id", not a password, not sensitive at all.
I would love to know how to appease the bot. I'm a bit dismayed that there weren't instructions beyond "only log literals", which doesn't make sense. Would scanning the var with a regex make it happy? Is there some way to mark things as not sensitive? I can't imagine the intent is that no one log things they got from web interfaces.
I fear overzealous false positives will result in people muting the scan, rather than improving code.
This seems to flag printing/logging any variable with "secret" in the name, and any variable set from a variable with "secret" in the name. I have code to work with AWS secrets manager and have lots of variables with "secret" in the name but never actually print the secret value. It's just a lot of false positives.
Activity
aibaars commentedon Jun 23, 2023
Thanks for reporting. It looks like you're right. It may be that the analysis is not precise enough and simply assumes that reading an attribute of an object that contains some sensitive data will return the sensitive information. I'll ask the team to have a look, hopefully the analysis can be made more precise.
yoff commentedon Jun 23, 2023
Indeed this is something we are slowly getting to a position where we can improve the precision.
dmartin-isp commentedon Jul 1, 2025
I just got flagged with
Clear-text logging of sensitive informationbecause I pulled down some json from the web, copied a field into a var and logged the var. It was a "stream_id", not a password, not sensitive at all.I would love to know how to appease the bot. I'm a bit dismayed that there weren't instructions beyond "only log literals", which doesn't make sense. Would scanning the var with a regex make it happy? Is there some way to mark things as not sensitive? I can't imagine the intent is that no one log things they got from web interfaces.
I fear overzealous false positives will result in people muting the scan, rather than improving code.
Thank you!
rinerb commentedon Aug 5, 2025
This seems to flag printing/logging any variable with "secret" in the name, and any variable set from a variable with "secret" in the name. I have code to work with AWS secrets manager and have lots of variables with "secret" in the name but never actually print the secret value. It's just a lot of false positives.
fix(security): add codeql inline suppression and fix ruff formatting
feat(manifest-config-source): derive test config from manifest.yaml (#…