SQL Injection flagged when concatenating strings
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
It seems that when concatenating strings in a cur.execute() call, it flags up sql injection possibilities, even though all the string arguments are being passed into the execute() call. So, this looks safe to me.
Reproduction steps
See the # noqa: S608 lines in this file: https://github.com/aio-libs/aiohttp-session/blob/master/examples/postgres_storage.py#L68-L72
Expected behavior
No errors from concatenating string literals.
Bandit version
1.7.0 (Default)
Python version
3.7
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 with the S608 warnings reproduced at examples/postgres_storage.py lines 68-72 and inspect how the cur.execute() call with concatenated string literals is classified. Confirm the change by rerunning Bandit on that example and verifying those lines no longer report SQL injection while unsafe cases remain detected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python, sql
- Domain
- security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100