I have read OWASP's XSS prevention cheat sheet but I don't really recognize my application with those rules. I don't feel like I have any of the vulnerabilities pointed out in those rules.
I am doing a PHP application that follows all the following principles:
Not a single user input is displayed directly on the HTML page without being processed and sanitized on the server-side
All my user input are sanitized with
htmlentities()
. Is that sufficient? (I use prepared statements for SQL injection)Some of the user input have a
maxlength
condition of 5 characters on server-side. Does that help protect against XSS? (since I hardly see an XSS code being shorter than 6 characters)Apart from data from the database, the only user input that is displayed back to the user was sent to the server via ajax, sanitized with
htmlentities
and reintroduced in the DOM usingtext()
instead ofhtml()
(using jQuery)
Should I be concerned about XSS in my case? What else can I do to protect myself from XSS?