Reputation: 580
Is dollar quoting enough to prevent malicious inputs like SQL injection?
For example:
SELECT * FROM mytable WHERE title = $secret$ hack'-- $secret$
where user input is
hack'--
Upvotes: 0
Views: 130
Reputation: 246598
No, of course not, because the hacker could enter a string containing $secret$
.
What you suggest goes by the name “security by obscurity” and enjoys ill respect among security experts. For example, it would not work at all with open source software.
Fortunately PostgreSQL and all relevant APIs have functions that make the safe construction of SQL statements simple.
Upvotes: 1