Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql injection? #3

Open
lastmeta opened this issue Dec 14, 2022 · 3 comments
Open

sql injection? #3

lastmeta opened this issue Dec 14, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@lastmeta
Copy link

I wasn't able to find, in the docs, anything about sql injection or if it's guarded against or handled by serverpod.

@vlidholt
Copy link
Contributor

All strings (or other types) are escaped before being sent to the database, so there is no risk of sql injection. Documentation should probably cover this.

@vlidholt vlidholt added the enhancement New feature or request label Dec 15, 2022
@lastmeta
Copy link
Author

lastmeta commented Dec 21, 2022

I thought more about this.

Custom queries are still dangerous though, right?

String table = 'users; DROP users';
final oops = await session.db.query('select * from $table;');

so I noticed the session.db.query function doesn't allow you to supply params:

Future<List<List<dynamic>>> query(
  String query, {
  int? timeoutInSeconds,
  Transaction? transaction,
})

I expected that it would take a list of params and simply pass them onto the database so the database can avoid 'executing' the params like it does the sql query.

We're using serverpod with a pretty intricate database schema, so we use custom queries a lot in order to make efficient queries rather than hitting the database constantly.

@vlidholt
Copy link
Contributor

You are right, we should provide the option to provide parameters for this reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants