Bandit does not identify hard coded password for DB connection variable
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.3k
- Forks
- 835
- Avg merge
- 5d 3h
- Merged PRs (30d)
- 1
Description
Describe the bug
I added the following line to a blank test.py file and did run bandit test.py and it was not detected any vulnerability.
Possible hardcoded password: iP0F3@s&9H_l12@XvGhj
connection = ("DATABASE=TEST;HOSTNAME=127.0.0.0;PORT=50000;UID=login;PWD=iP0F3@s&9H_l12@XvGhj", "", "")
Results from bandit:

Reproduction steps
1.Create a test.py file
2.Add the following line of code
# Possible hardcoded password: iP0F3@s&9H_l12@XvGhj
connection = ("DATABASE=TEST;HOSTNAME=127.0.0.0;PORT=50000;UID=login;PWD=iP0F3@s&9H_l12@XvGhj", "", "")
3.Save the file
4.Run **bandit test.py**
...
Expected behavior
As per what I expected, bandit should have identified PWD=iP0F3@s&9H_l12@XvGhj inside the line of code as a potential vulnerability
Bandit version
1.7.4 (Default)
Python version
3.8
Additional context
python3 -m bandit --version ─╯
main.py 1.7.4
python version = 3.8.2 (default, Apr 8 2021, 23:19:18) [Clang 12.0.5 (clang-1205.0.22.9)]
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 report with the shown test.py content and the Bandit command, using the reported Python and Bandit versions. Trace the hardcoded-password detection behavior for the PWD= value inside the database connection string. Done means the sample is reported as a potential vulnerability and a regression test covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100