Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlalchemy filters and sql injection

Tags:

sqlalchemy

I'm accepting a GET query parameter which will be used as piece of a search string.

If I have this:

x = request.args['x']
MyTable.query.filter(MyTable.myCol.ilike(x)).one()

Am I vulnerable to a SQL injection attack?

EDIT - I am using Postgres and SQLAlchemy 1.0 I think.

like image 940
Tony Ennis Avatar asked Jul 21 '26 06:07

Tony Ennis


1 Answers

According to https://stackoverflow.com/a/31949750/3359014,

MyTable.query.filter(MyTable.myCol.ilike(x)).one() is not considered a raw sql and the underlying db-api will escape x.

like image 119
Jinsu Oh Avatar answered Jul 25 '26 20:07

Jinsu Oh