Prepared Statements or other SQL Injection Countermeasures? #1330
-
Hello Guys, I have been testing SurrealDB for a project me and a few colleagues have to complete in school. I've been really liking it so far and we thus decided to use it as our backend/data storage solution. However, along the development process we came to wonder: Is there any way to prevent SQL Injections using plain Surreal Query Language? This is not only a safety concern, but also a flexibility concern. What if a user wants to store name= CREATE text SET content = "$name" Filled in that would be: CREATE text SET content = "He said ", name = Gandalf;" like a computer" Which would not result in the desired record being created. Is there any solution for this? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
After some testing, escaping every |
Beta Was this translation helpful? Give feedback.
-
Please never use your language's formatting tools and manual replacements to pass parameters to a text-based query statement processor. Always [pass] parameters [via client library API]! Surrealdb [client libraries] support parameters [1]. If your query processor's [client library] API does not support parameters then it should instantly be deranked to "not a serious tool". [1] https://surrealdb.com/docs/surrealql/parameters - see "Defining parameters within client libraries" |
Beta Was this translation helpful? Give feedback.
Please never use your language's formatting tools and manual replacements to pass parameters to a text-based query statement processor. Always [pass] parameters [via client library API]! Surrealdb [client libraries] support parameters [1]. If your query processor's [client library] API does not support parameters then it should instantly be deranked to "not a serious tool".
[1] https://surrealdb.com/docs/surrealql/parameters - see "Defining parameters within client libraries"