False negative: B501 misses `verify=False` on `requests.Session` / `httpx.Client` instance methods
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 836
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
Describe the bug
B501 currently detects verify=False for module-level calls like requests.get(...) and httpx.get(...), but misses equivalent insecure calls on client/session instances (for example session.get(..., verify=False)).
This creates false negatives for common usage patterns and leaves CWE-295 cases undetected.
Reproduction steps
import httpx
import requests
session = requests.Session()
session.get("https://gmail.com", timeout=30, verify=False)
session.post("https://gmail.com", timeout=30, verify=False)
with requests.Session() as scoped_session:
scoped_session.put("https://gmail.com", timeout=30, verify=False)
scoped_session.delete("https://gmail.com", timeout=30, verify=False)
client = httpx.Client(timeout=30)
client.get("https://gmail.com", timeout=30, verify=False)
client.post("https://gmail.com", timeout=30, verify=False)
Run:
bandit -q -r <repro_file.py> -t B501 -f json
Actual result: no B501 findings for the above calls.
Expected behavior
Six alarms should be generated.
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 by reproducing the B501 case with the provided requests.Session and httpx.Client examples, then trace the B501 check that handles module-level calls. Confirm the change by running the shown bandit command and verify that six B501 alarms are reported for the instance-method calls.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- security, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100