Skip to content

Encoding request parameters to prevent query injection #1591

Answered by wolfgangwalther
vraxis asked this question in Q&A
Discussion options

You must be logged in to vote

So I did test it and it works as it should. With our test fixtures:

  • GET /authors?name=eq.Anne%20Frank returns 1 row.

  • GET /authors?name=eq.Anne%20Frank&a= returns an error, because the parameter a is missing an operator.

  • GET /authors?name=eq.Anne%20Frank%26a= returns 0 row.

Clearly the escaped & in the last request is interpreted as part of the value. So if you escape your query string on the client side correctly, then you will not suddenly create additional parameters to your request.

The problem I see here, is that the docs are very much misleading. At http://postgrest.org/en/latest/api.html#unicode-support it reads:

If filters include PostgREST reserved characters(,, ., :, ())…

Replies: 10 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by wolfgangwalther
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1591 on December 28, 2020 19:22.