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

Preventing SQL Injection #274

Closed
r0man opened this issue Jan 23, 2017 · 8 comments
Closed

Preventing SQL Injection #274

r0man opened this issue Jan 23, 2017 · 8 comments

Comments

@r0man
Copy link

r0man commented Jan 23, 2017

Hello,

what's the proper way to prevent SQL injection in the Java client? I found this ticket for the Go client, but could not find anything related in the Java sources.

influxdata/influxdb#2926

Thanks, Roman.

@majst01
Copy link
Collaborator

majst01 commented Jan 23, 2017

Hi @r0man

This is indeed required. Any idea how we could implement such a prepared statement parse with as least effort as possible ?

@r0man
Copy link
Author

r0man commented Jan 23, 2017

@majst01 Thanks for the confirmation. No, don't have an idea yet. I'll let you know if I do :)

@joelmarty
Copy link
Contributor

Perhaps the most obvious way would be to support prepared statements in the jdbc lib or hibernate framework does i.e. :

PreparedQuery pq = new PreparedQuery("SELECT * FROM measures WHERE time > :lowerBound and time < :upperBound and device = :device");
pq.setDate("lowerBound", myLowerDate);
pq.setDate("upperBound", myUpperDate);
pq.setString("device", myDevice);

this way you can sanitize the input for each argument.

@majst01
Copy link
Collaborator

majst01 commented Jan 23, 2017

sure, but i dont want to add hibernate for example as a direct dependency to influxdb-java.

Is there any small implementation out there which can be reused easily ?

@majst01
Copy link
Collaborator

majst01 commented Mar 7, 2017

From Influxdb documentation this must look like:

curl -G 'http://localhost:8086/query?db=mydb' --data-urlencode 'q=SELECT * FROM "mymeas" WHERE "myfield" > $field_value' --data-urlencode 'params={"field_value":30}'

so adding a params parameter to the Influxdb.query should do the trick.

@r0man
Copy link
Author

r0man commented Mar 7, 2017

Thanks!

@majst01
Copy link
Collaborator

majst01 commented Mar 7, 2017

But the current implementation does not allow this kind of query. We need to add this ability.

@majst01
Copy link
Collaborator

majst01 commented May 6, 2017

I quite simple impl of Select is here https://github.com/gocraft/dbr/blob/master/select.go but apperently in golang. Could be used as a starting point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants