Skip to content

Suppress false positive SQL injection warning in users.py#15

Merged
studentsca023-rgb merged 1 commit into
masterfrom
semgrep-autofix/1773740129
Mar 17, 2026
Merged

Suppress false positive SQL injection warning in users.py#15
studentsca023-rgb merged 1 commit into
masterfrom
semgrep-autofix/1773740129

Conversation

@semgrep-code-studentsca023-rgb

Copy link
Copy Markdown

Suppress false positive Semgrep finding for SQL injection in user registration.

Changes

  • Added # nosemgrep comment to suppress the tainted-sql-string rule on line 38 of flask_webgoat/users.py

Why

The flagged code already uses parameterized queries correctly with ? placeholders:

query = "INSERT INTO user (username, password, access_level) VALUES (?, ?, ?)"
query_db(query, [username, password, int(access_level)], False, True)

User input values are passed as a separate list to query_db, not concatenated into the query string. This is the standard and secure approach to prevent SQL injection. Semgrep cannot trace through to confirm that query_db handles parameters safely, resulting in a false positive.

Semgrep Finding Details

Detected user input used to manually construct a SQL string. This is usually bad practice because manual construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or modify contents of the database. Instead, use a parameterized query which is available by default in most database engines. Alternatively, consider using an object-relational mapper (ORM) such as SQLAlchemy which will protect your queries.

@267212124 requested Semgrep Assistant generate this pull request to fix a finding from the detection rule python.flask.security.injection.tainted-sql-string.tainted-sql-string.


⚠️ Review carefully before merging. This PR was generated by AI and may cause breaking changes or introduce new vulnerabilities.

Suppress false positive Semgrep finding for SQL injection in user registration.

## Changes
- Added `# nosemgrep` comment to suppress the tainted-sql-string rule on line 38 of `flask_webgoat/users.py`

## Why
The flagged code already uses parameterized queries correctly with `?` placeholders:

```python
query = "INSERT INTO user (username, password, access_level) VALUES (?, ?, ?)"
query_db(query, [username, password, int(access_level)], False, True)
```

User input values are passed as a separate list to `query_db`, not concatenated into the query string. This is the standard and secure approach to prevent SQL injection. Semgrep cannot trace through to confirm that `query_db` handles parameters safely, resulting in a false positive.

## Semgrep Finding Details
Detected user input used to manually construct a SQL string. This is usually bad practice because manual construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or modify contents of the database. Instead, use a parameterized query which is available by default in most database engines. Alternatively, consider using an object-relational mapper (ORM) such as SQLAlchemy which will protect your queries.

@267212124 requested Semgrep Assistant generate this pull request to fix [a finding](https://semgrep.dev/orgs/studentsca023_personal_org/findings/722169006) from the detection rule [python.flask.security.injection.tainted-sql-string.tainted-sql-string](https://semgrep.dev/r/python.flask.security.injection.tainted-sql-string.tainted-sql-string).
@studentsca023-rgb studentsca023-rgb marked this pull request as ready for review March 17, 2026 09:37
@studentsca023-rgb studentsca023-rgb merged commit 4799ea2 into master Mar 17, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant