Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: mssql SQL Injection

  1. #11
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    " single quote, double quote, slash, back slash, semi colon, extended character like NULL, carry return, new line, etc " is what I've found. Doesn't seem to be a stock function comparable to mysql_real_escape_string(). Microsoft (those loveable hunks) suggest using stored procedures and validating all inputs using custom-built regexes. I'm sure you've got enough free time for that.

  2. #12
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    haha yea, plenty of time for that. I've just gotten back to this thread now. So going further into this...


    I've started used parametrized queries as an alternative to escaping all the possible inputs.

    How secure is this method, if at all?

    Side not for mssql users stumbling upon this, mssql doesn't take the \' as escaping the double single quotes ('') is how to mssql escapes a single quote so the query would be

    Code:
    $query = "select * from users where lastname like 'o''brien';';
    Corrections to my coding/thoughts welcome.

  3. #13
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    By "parametrized queries" you mean that you have a list of possible queries or parts of queries and the user's input selects which one to use, but there are no custom fields? That should be entirely secure.
    (If one of your terms happens to be ;DROP DATABASE, then you'd need to fix that .)


    Note that in the syntax of your code above you are mixing double and single quotes. I believe the last single quote should be double instead.

    MySQL does that same method of escaping single quotes. You just never see it because mysql_real_escape...() does it for you.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. The Following User Says Thank You to djr33 For This Useful Post:

    bluewalrus (01-28-2011)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •