blacklist getattr calls
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 836
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
Is your feature request related to a problem? Please describe.
One of use cases for bandit is a backdoor detection. It doesn't fit it well though, since for proper backdoor detection intermodule and runtime interactions must be addressed, i.e. with taint analysis (and the fact that using bandit for backdoor detection can be easily bypassed must be clearly stated in bold big red font).
It can detect very crude backdoors with explicit eval. But it is easy to mask them, by just obfuscating the string eval and getting the function using getattr.
Also getattr is a bad smell by itself, since it is often dangerously misused. I.e.
class A:
b = lambda b: b
function_id = "string from the net"
getattr(A, function_id)(*args_from_the_net)
Instead a collection should be used and A[function_id], which will only allow calling an explicitly defined set of functions.
Describe the solution you'd like
getattr should be blacklisted.
Contributor 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.
Research direction
Start by locating Bandit's existing blacklist checks and their tests, then review how a getattr call is represented in the issue's Python examples. Done should include a blacklist finding for getattr while accounting for the stated security-scanning scope and documenting the behavior in tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- security
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100