security - Securing my web application against malicious input -


i in process of building basic security layer web application. seeking validation of steps taking. current focus xss, not touching databases in post. have done far:

  1. htmlspecialchars() user input
  2. blacklist keywords {"","","text/javascript"} : using preg_replace sub these words "" instead.
  3. output escaping dynamic content.

all of seems trivial security layer. can recommend better strategies ?

your approach simple. htmlspecialchars won't in every context.

here cheat sheet xss , problems there when escaping strings put html.

https://www.owasp.org/index.php/cross-site_scripting_%28xss%29

blacklist has it's drawbacks also. browsers example might parse

text/javascript 

and

text/java        script 

the same way. new line , spaces removed latter , get's interpreted first one. blacklist isn't going bullet proof method.

best strategy use template library allready handles you. library must know context string going. element value needs different escaping attribute values.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -