Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing XSS in Node.js / server side javascript

Any idea how one would go about preventing XSS attacks on a node.js app? Any libs out there that handle removing javascript in hrefs, onclick attributes,etc. from POSTed data?

I don't want to have to write a regex for all that :)

Any suggestions?

like image 658
Techwraith Avatar asked Sep 14 '10 00:09

Techwraith


People also ask

Can XSS be server side?

Server XSS The source of this data could be from the request, or from a stored location. As such, you can have both Reflected Server XSS and Stored Server XSS. In this case, the entire vulnerability is in server-side code, and the browser is simply rendering the response and executing any valid script embedded in it.

Is XSS attack client or server side?

Cross-site Scripting (XSS) is a client-side code injection attack. The attacker aims to execute malicious scripts in a web browser of the victim by including malicious code in a legitimate web page or web application.

What is XSS attack in node JS?

Update 2021-04-16: xss is a module used to filter input from users to prevent XSS attacks. Sanitize untrusted HTML (to prevent XSS) with a configuration specified by a Whitelist.


1 Answers

I've created a module that bundles the Caja HTML Sanitizer

npm install sanitizer 

http://github.com/theSmaw/Caja-HTML-Sanitizer

https://www.npmjs.com/package/sanitizer

Any feedback appreciated.

like image 152
theSmaw Avatar answered Oct 02 '22 20:10

theSmaw