Skip to content

Potential SQL Injection vulnerability #2

@Arian-Ott

Description

@Arian-Ott

Zaber,

I have seen your repo listed in the GitHub education community exchange and I looked through some of your code.

cursor.execute(f"SELECT COUNT(*) FROM {table_name}")

From what I see here is that you pass the table name directly from the input.

python -m database_swap.main test-connection --db-type sqlite --database "; DROP DATABASE;"

Inputs like those I described in the example command should either throw errors or be escaped.

Depending on the config file or migration file, unauthorised third parties who have access to the file could take down entire databases.

I would recommend using an ORM or sanitise the SQL statement before running it.

Best regards,
Arian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions