SQL injection: isn't replace(“'”, “''”) good enough?

后端 未结 5 1485
执笔经年
执笔经年 2020-12-03 05:38

While I can certainly see the advantages of using parameters for SQL queries, especially when dealing with datetimes and things like that, I\'m still unsure about parameters

5条回答
  •  感动是毒
    2020-12-03 06:22

    No, it is not enough. It will do in a pinch, but it is a very weak alternative, and using parameterized queries or parameterized stored procedures is better, if your platform and/or RDBMS support either feature.

    From

    OWASP's SQL Injection Prevention Cheat Sheet

    ...this methodology is frail compared to using parameterized queries. This technique should only be used, with caution, to retrofit legacy code in a cost effective way.

    There are more below

    SQL injection — but why isn't escape quotes safe anymore?

    Sql Injection Myths and Fallacies

    SQL Injection after removing all single-quotes and dash-characters

提交回复
热议问题