Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: looking for straight answer - what's the safest or joint-safest way to validate data?

  1. #21
    Join Date
    Jun 2006
    Location
    Birmingham
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    "PHP injection" is not a technical term, since it doesn't exist. It sounds to me as if you're expecting data submitted to your PHP script to be automatically executed somewhere along the way, thus compromising your security. It isn't. It's nothing more than a string until you pass it to something that tries to execute it in some form, such as eval(), shell_exec(), mysql_query(), or a browser (or a file, if that file has the wrong permissions/filename). Unless you are passing it to such a function, there is nothing to worry about.
    ok twey, i'll take ur word for it until i get hacked or learn to hack by injecting self-executing php code into a script that reads form data, and if that happens i'll get back to you and on your conscience may it remain

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

    Default

    You can't force something to execute as php from inside a string.

    For example, try running this--
    <?php echo "eval(1+1)"; ?>

    The eval function executes the code, but since it's in quotes, as a string, it does nothing. It'll just print that.
    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

  3. #23
    Join Date
    Jun 2006
    Location
    Birmingham
    Posts
    39
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Arrow

    Quote Originally Posted by djr33
    You can't force something to execute as php from inside a string.

    For example, try running this--
    <?php echo "eval(1+1)"; ?>

    The eval function executes the code, but since it's in quotes, as a string, it does nothing. It'll just print that.
    injection of any malicious code usually works by first closing the quotes and the command then starting a new one.

    anyway, i'll settle for the "there's nothing to worry about" for the time being. i might just send some emails to php.net just to make sure though

  4. #24
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    injection of any malicious code usually works by first closing the quotes and the command then starting a new one.
    If this were possible in direct input into a script, no server-side script would be safe, since there would be no way to escape it.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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

    Default

    Yeah. Quotes are converted to "safe" characters before being used in strings. You can't just put one in there from a form or something... it'll become a new character.
    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

  6. #26
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33
    Quotes are converted to "safe" characters before being used in strings.
    Are you referring to the "magic quotes" feature? That may protect data for certain uses, but for databases and such, the vendor-specific function (such as mysql_real_escape_string) should be used.

    For distributed code, magic quotes should never be relied upon as it is a configuration option (I have it disabled: I find it to be annoying, more than anything else). Development should be conducted without it, and code should be written to check the current state of the option and act accordingly.

    Mike

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
  •