Skip to content

Fix SQL injection in database_exists - #841

Open
raghu45345 wants to merge 1 commit into
kvesteri:masterfrom
raghu45345:database-exists-bound-parameter
Open

raghu45345 wants to merge 1 commit into
kvesteri:masterfrom
raghu45345:database-exists-bound-parameter

Conversation

@raghu45345

Copy link
Copy Markdown
  1. database_exists interpolates the database name from the URL into a single-quoted SQL literal in the postgresql, mysql and mssql branches, so the URL from SQL Injection in database.py database_exists #760 (postgresql://user:pass@localhost/test'; CREATE TABLE hello (id int); COMMIT; SELECT 1 FROM pg_database;--) runs the injected statements on the server while the function returns False.
  2. The name is now passed as a bound parameter via sa.text(...).bindparams(database=database) in all three branches, and each dialect test class gained a regression test using an OR-based database name that made the old query match an existing database.

Fixes #760.

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.

SQL Injection in database.py database_exists

1 participant