How do I prevent people from doing XSS in Spring MVC?

In Spring you can escape the html from JSP pages generated by <form> tags. This closes off a lot avenues for XSS attacks, and can be done automatically in three ways: For the entire application in the web.xml file: <context-param> <param-name>defaultHtmlEscape</param-name> <param-value>true</param-value> </context-param> For all forms on a given page in the file itself: <spring:htmlEscape … Read more

Allow All Content Security Policy?

For people who still want an even more permissive posts, because the other answers were just not permissive enough, and they must work with google chrome for which * is just not enough: default-src * data: blob: filesystem: about: ws: wss: ‘unsafe-inline’ ‘unsafe-eval’ ‘unsafe-dynamic’; script-src * data: blob: ‘unsafe-inline’ ‘unsafe-eval’; connect-src * data: blob: ‘unsafe-inline’; … Read more

Sanitising user input using Python

Here is a snippet that will remove all tags not on the white list, and all tag attributes not on the attribues whitelist (so you can’t use onclick). It is a modified version of http://www.djangosnippets.org/snippets/205/, with the regex on the attribute values to prevent people from using href=”https://stackoverflow.com/questions/16861/javascript:…”, and other cases described at http://ha.ckers.org/xss.html. (e.g. … Read more

When is it best to sanitize user input?

Unfortunately, almost no one of the participants ever clearly understands what are they talking about. Literally. Only Kibbee managed to make it straight. This topic is all about sanitization. But the truth is, such a thing like wide-termed “general purpose sanitization” everyone is so eager to talk about is just doesn’t exist. There are a … Read more

What are the best practices for avoiding xss attacks in a PHP site [closed]

Escaping input is not the best you can do for successful XSS prevention. Also output must be escaped. If you use Smarty template engine, you may use |escape:’htmlall’ modifier to convert all sensitive characters to HTML entities (I use own |e modifier which is alias to the above). My approach to input/output security is: store … Read more

Sanitizing user input before adding it to the DOM in Javascript

Never use escape(). It’s nothing to do with HTML-encoding. It’s more like URL-encoding, but it’s not even properly that. It’s a bizarre non-standard encoding available only in JavaScript. If you want an HTML encoder, you’ll have to write it yourself as JavaScript doesn’t give you one. For example: function encodeHTML(s) { return s.replace(/&/g, ‘&amp;’).replace(/</g, ‘&lt;’).replace(/”/g, … Read more

Will HTML Encoding prevent all kinds of XSS attacks?

No. Putting aside the subject of allowing some tags (not really the point of the question), HtmlEncode simply does NOT cover all XSS attacks. For instance, consider server-generated client-side javascript – the server dynamically outputs htmlencoded values directly into the client-side javascript, htmlencode will not stop injected script from executing. Next, consider the following pseudocode: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)