Are parameterized queries in PDO necessary for request variables?

前端 未结 2 1890
北荒
北荒 2021-01-25 07:45

I understand that parameterized queries are essential when user-submitted data is on the prowl, however my question is whether this applies to user-TAMPERABLE data?

So i

2条回答
  •  生来不讨喜
    2021-01-25 08:46

    Why wouldn't you use prepared statements / paramaterised queries for all situations where there is external/variable input?

    The only queries you can trust are those where every element is hardcoded, or derived from hardcoded elements within your application.

    Do not even trust data that you have pulled from your own database. This counts as external / variable data. A sophisticated attack can use more vectors than a simple "modifying a query string parameter".

    I think for the tiny amount of extra code overhead, it is completely worth the peace of mind you will get from knowing your queries are protected.

提交回复
热议问题