Preventing XSS in Node.js / server side javascript

Techwraith picture Techwraith · Sep 14, 2010 · Viewed 55.2k times · Source

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?

Answer

theSmaw picture theSmaw · Oct 29, 2010

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.