2

apparently, some of our websites have been hacked by a hack bot. The reason: bad input sanitzation. Our boss is giving us this file to put on all our servers to secure them: http://pastebin.com/0gJ19TQG

Personally, i just do this on my personal websites: filter_var(mysql_real_escape_string($_POST['Nom']), FILTER_SANITIZE_STRING);. So you tell me, which one is better and why?

3
  • 4
    That is one of the worst sanitization functions i have ever seen! Are you actually passing html/sql through get/post vars??? May 12, 2011 at 12:32
  • omg Yesssssssss
    – mahen23
    May 12, 2011 at 12:39
  • 3
    How about you post a link to your websites so we can test how well your input sanitization works. >;) May 12, 2011 at 13:34

2 Answers 2

6

Input sanitazion isn't just about "including a file and you're done"! It requires extensive knowledge about the system and starts with designing the processes accepting the data. Neither solution will solve all your problems. It might defend some attacks but certainly not all!

2

This is a pretty bad filter.

Use something standard if possible, like http://htmlpurifier.org/.

Also, do white-list input validation, and output encoding.

https://www.owasp.org/index.php/Data_Validation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.