Skip to content

Detecting misuse of the psycopg2.sql module #412

Open
@Changaco

Description

The psycopg2.sql module is meant to provide a safe way to compose SQL queries dynamically, however it is possible to misuse it in a way that would result in an SQL injection vulnerability, and bandit currently doesn't support detecting this.

Solution: create a new test to detect when a psycopg2.sql.SQL object is being created from a non-literal, e.g. SQL(foo) or SQL('%s AND %s' % (foo, bar)). The severity and confidence levels of this new test would both be at least "medium".

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions