What kind of malicious attacks is my web application (PHP) vulnerable to? Can someone describe them briefly, and point out what countermeasures you may develope in the code to prevent such attacks?
XSS - use htmlentities() on inputs CSRF - don't use get requests/links to perform important actions, include one time tokens in forms Session Hijacking - where possible disable query string session handling, ensure the session is tied to user agent/partial ip Session fixation - ensure you regenerate session id after succesful login I think thats the main 4 for any web app, you can google the names for loads more info.
But why should I use htmlentities instead of strip_tags() ? and btw im using mysqli_real_escape_string() aswell , is that safe? I have heard rumours about a line that removes all SQLInjections known.. Some guy I know got it from astalavista.com but refuses to share it..
htmlentities is one step to use. Because XSS can take on more than standard HTML, you will likely need more than that: http://ha.ckers.org/xss.html You should always validate information from forms. If you are using a database, be sure the data you are getting is what is expected to avoid SQL injection issues. -Bing
mysqli_real_escape_string() should be fine assuming proper usage. All of the examples the url given are thwarted by htmlentites(). strip_tags() alone will let some past. Personally I use both, as it stops the tags showing up even if they don't do anything harmful.
Check some of these links out: http://phpsec.org/library/ Some of these are really good resources on keeping php applications secure.