False negative: narrow argument-shape checks in B508/B509
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 835
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
Describe the bug
B508 and B509 currently rely on narrow argument-shape checks in bandit/plugins/snmp_security_check.py.
This causes:
- false negatives for insecure SNMP usage when arguments are omitted/positional
- false positives for secure
UsmUserDataconfigs passed via kwargs
Reproduction steps
# Orignal Test Cases:
# SHOULD FAIL
a = CommunityData('public', mpModel=0)
# SHOULD FAIL
insecure = UsmUserData("securityName")
# SHOULD FAIL
auth_no_priv = UsmUserData("securityName","authName")
# SHOULD PASS
less_insecure = UsmUserData("securityName","authName","privName")
---
# False negatives cases:
CommunityData("public") # default mpModel=1 (v2c)
CommunityData("public", 1) # positional mpModel
UsmUserData("securityName", "authName", None) # authNoPriv
---
# False positive (should pass)
UsmUserData(userName="user", authKey="auth", privKey="priv") # authPriv
Expected behavior
- B508 should treat omitted/positional/keyword mpModel consistently.
- B509 should evaluate privacy presence semantically (privKey / equivalent), not only positional arg count.
Bandit version
1.9.1 (Default)
Python version
3.14 (Default)
Additional context
No response
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 in bandit/plugins/snmp_security_check.py at the B508 and B509 checks, then compare their argument handling with each reproduction case in the issue. Use the omitted, positional, and keyword examples as regression cases; done means B508 consistently evaluates mpModel and B509 evaluates privacy semantically without the reported false negatives or false positive.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100