How to prevent Sql-Injection on User-Generated Sql Queries

前端 未结 15 1958
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 11:55

I have a project (private, ASP.net website, password protected with https) where one of the requirements is that the user be able to enter Sql queries that will directly query t

15条回答
  •  执笔经年
    2021-02-10 12:39

    Well, you already have enough people telling you "dont' do this", so if they aren't able to dissuade you, here are some ideas:

    INCLUDE the Good, Don't try to EXCLUDE the bad
    (I think the proper terminology is Whitelisting vs Blacklisting ) By that, I mean don't look for evil or invalid stuff to toss out (there are too many ways it could be written or disguised), instead look for valid stuff to include and toss out everything else.

    You already mentioned in another comment that you are looking for a list of user-friendly table names, and substituting the actual schema table names. This is what I'm talking about--if you are going to do this, then do it with field names, too.

    I'm still leaning toward a graphical UI of some sort, though: select tables to view here, select fields you want to see here, use some drop-downs to build a where clause, etc. A pain, but still probably easier.

提交回复
热议问题