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:
- htmlspecialchars() user input
- blacklist keywords {"","","text/javascript"} : using preg_replace sub these words "" instead.
- 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
Post a Comment