nodeJS introduction
JavaScript in the backend
Built on Chrome´s Javascript runtime(V8)
NodeJs is based on event loop
Designed to be asynchronous
Single Thread
Concurrent requests.
Delete cookies from cache browser
// Set cache control header to eliminate cookies from cache
app.use(function (req, res, next) {
res.header('Cache-Control', 'no-cache="Set-Cookie, Set-Cookie2"');
next();
});
Slide 22
Slide 22 text
XSS attacks
An attacker can exploit XSS vulnerability to:
Steal session cookies/Sesion hijacking
Redirect user to malicious sites
Defacing and content manipulation
Cross Site Request forgery
Regular expressions
https://www.npmjs.com/package/safe-regex
Detect vulnerable regular
expressions that can cause DoS
Slide 32
Slide 32 text
NodeJS Crypto
http://nodejs.org/api/crypto.html
Use require(‘crypto’) to access this module
The crypto module requires OpenSSL
require("crypto")
.createHash("sha1") //algorithm
.update(“cOdEmOtiOn") //text
.digest("hex"); //hexadecimal result
Building a secure HTTPS server
https://www.npmjs.com/package/https-redirect-server
https://www.npmjs.com/package/express-enforces-ssl
Redirect all traffic to https and a
secure port
Slide 39
Slide 39 text
Building a secure HTTPS server
Slide 40
Slide 40 text
Building a secure HTTPS server
var helmet = require("helmet");
var ms = require("ms");
app.use(helmet.hsts({
maxAge: ms("1 year"),
includeSubdomains: true
}));
Send hsts header for all requests