PyCQA / PyCQA/bandit

Bandit does not identify hard coded password for DB connection variable

Open
#886 1 comment 0 reactions 0 assignees View on GitHub

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

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:
image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.