3 ms·
The answer is basically the same for every language. Use SQL interfaces that support bound variables[1]. It's not about remembering to correctly sanitize inpu
by kbenson 11y ago
The answer is basically the same for every language. Use SQL interfaces that support bound variables[1]. It's not about remembering to correctly sanitize input, it's about adopting practices that eliminate the possibility of that class of attack. Forcing databases to consider each argument as an atomic item (not a string to be interpreted) is one such way to do so.
There are still other attack vectors, such as viewing non-associated records by tweaking parameters, but that's not SQL injections, it's leaking content through loose ownership checking, and that may or may not be a problem in the DB or the application, depending on whether you are relying on the DB for user level permissions and ownership, or the application.
1: https://metacpan.org/pod/DBI#Placeholders-and-Bind-Values https://metacpan.org/pod/DBI#Placeholders-and-Bind-Values