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 prevention #9

Open
martinell opened this issue Jan 15, 2013 · 6 comments
Open

Sql injection prevention #9

martinell opened this issue Jan 15, 2013 · 6 comments

Comments

@martinell
Copy link
Contributor

I am starting to use this module. Before, I was using the pg driver directly and I was able to prevent sql injection attacks by using placeholders in the queries and passing the parameters to the driver. Wen I started using jugglingdb I realized now I am able to inject sql code into the queries.

@1602
Copy link
Contributor

1602 commented Jan 15, 2013

If you familiar with pg driver, it would be great if you provide some examples, or, better send pull request. Thanks!

@ammmir
Copy link

ammmir commented Jan 19, 2013

the code should be updated to use $ positional parameter markers, for example:

client.query("SELECT * FROM users WHERE username=$1", ["ammmir"], function(err, result) {...});

when done this way, the pg driver sends the query to the server for parameter binding so the client doesn't need to worry about escaping.

@martinell
Copy link
Contributor Author

I've worked on that in my fork https://github.com/martinell/jugglingdb-postgres/commits/master. It is in an early stage because it still has some replicated code. This is because there are some dependencies with the jugglingdb module. To fully apply prepared statements, some modifications would be required on that code and that would affect the mysql adapter. This might require to review the interface between the ORM and the sql adapters.

@1602
Copy link
Contributor

1602 commented Jan 20, 2013

In postgres adapter you can override anything from base sql, if it doesn't
solve your issue feel free to fix API between adapter and base.

On Sun, Jan 20, 2013 at 6:25 PM, Luis [email protected] wrote:

I've worked on that in my fork
https://github.com/martinell/jugglingdb-postgres/commits/master. It is in
an early stage because it still has some replicated code. This is because
there are some dependencies with the jugglingdb module. To fully apply
prepared statements, some modifications would be required on that code and
that would affect the mysql adapter. This might require to review the
interface between the ORM and the sql adapters.


Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb-postgres/issues/9#issuecomment-12469116.

Thanks,
Anatoliy Chakkaev

@markandrus
Copy link

@1602 @martinell is this still an issue? Can you provide an example of how SQL injection can occur?

@martinell
Copy link
Contributor Author

For what I can see, the code of the adapter looks the same as before I did my changes to it on my fork (https://github.com/martinell/jugglingdb-postgres/commits/master). There you can find some tests I added to check SQL injection (https://github.com/martinell/jugglingdb-postgres/blob/ec91a67d983aae1dddbcad525e51a7734ba2aa84/test/postgres.js).

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

No branches or pull requests

4 participants