Flag logging/printing of likely sensitive information
Nobody has claimed this yet.
- #1386 by @someone — closed without merging
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
No source file, test, or entry point is identified. Start by reviewing existing issue-tracker discussions for “sensitive” and the scope of logging or printing calls, including variable names such as password and API-key names and APIs such as keyring.get_password(...). Done would require an agreed, tested detection rule with acceptable false-positive behavior.
Written by the indexing model from the issue text.
Description
Is your feature request related to a problem? Please describe.
It is impossible to flag sensitive information leaks to console logs in the general case (e.g. the debugging call in #201 is just a generic kwargs printer, with no information available at static analysis time to indicate it might be exposed to sensitive information like basic auth passwords or API keys).
However, some information leaks are blatant enough that they do show up under static analysis, as in something like logging.debug("Password: %s", password).
Describe the solution you'd like
A call alert that flags situations where a logging or printing call appears to be directly referencing sensitive information (whether by accessing variables with names like password, credentials, api_key, private_key, etc, or by calling secret retrieval APIs like keyring.get_password(...)).
Describe alternatives you've considered
Brute force regex searches for suspicious looking patterns (this may actually be one of those cases where the additional structure of an AST makes pattern detection for problematic cases harder to formulate)
Additional context
My actual assumption is that this idea has previously been considered and discarded as being far too prone to false positives to be feasible to implement as a general rule outside a specific application or organisational context. I didn't see anything obvious along those lines when searching the issue tracker for "sensitive" though, in which case even a closed issue may serve as a searchable record of the reasoning for not including such a check.
Love this idea? Give it a 👍. We prioritize fulfilling features with the most 👍.
- Dominant language
- Python
- Stars
- 8.4k
- Forks
- 893
- Avg merge
- 6h 52m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyCQA/bandit
-
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Turn off progress bar in CIPossibly taken @silvatechf claimed this 28 days ago. Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
`bandit -ii -ll -ii -ll` raises an `IndexError`Possibly taken @botbikamordehai2-sketch claimed this 181 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
intersystems/ipm#1338 ·
Maintainers usually reply within 1 day
-
separate_packages splits imports from the same explicitly configured packagePossibly taken @rahul05ranjan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOpenv1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day