SlideShare uma empresa Scribd logo
1 de 73
Maciej Lasyk
AtmosphereConf 2014
Warsaw, 2014-05-19
scaling & securing node.js apps
$ whoami
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- not only sysadmin ;)
- 14+ years of exp software dev / sysop
- ops lead
- contributing to Fedora Project (and couple more)
- and...
$ whoami
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- not only sysadmin ;)
- 14+ years of exp software dev / sysop
- ops lead
- contributing to Fedora Project (and couple more)
- and...
- love AtmosphereConf – been to Velocity
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
So what do you think about JS?
- JS is for children!
- JS is slow!
- JS is not scalable!
- JS is insecure!
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js: history
- 2008: Google V8 release
- 2009: Ryan Dahl & node.js
- 2011: node.js release
- later on – Joyent till today
- and ^liftsecurity / nodesecurity.io
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
(http://www.phloxblog.in)
node.js: developing ur code
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
raw node.js coding srsly?
node.js: developing ur code
maybe some frameworks?
- webserver: express
- client-server sync: backbone.js
- push: socket.io
- templates: swig
- i18n: babelfish
- client – side: jquery
- or...
- kraken.js does the all (almost)
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js: developing ur code
Biggest win here?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js: developing ur code
Biggest win here?
One Language to Rule them all!
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
eval() like fncs takes string argument and
evalute those as source code
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
eval() like fncs takes string argument and
evalute those as source code
srsly – who does that?
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
not only evals:
setInterval(code,2)
setTimeout(code,2)
str = new Function(code)
Content-Security-Policy knows about those
but we're talking about server side...
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Global nameSpace Pollution
- node.js is single threaded
- all variable values are common
- one could thrtically change bhv of others reqs
- watch out for globals then!
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
var auth = false;
app.get('/auth', function(req, res) {
if(legit) { auth = true; res.send("success");
});
app.get('/payments-db', function(req, res) {
if (auth) res.send("legit to see all payments data");
else res.send("not logged in");
})
app.listen(8080);
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
So now imagine..
global namespace pollution + evals & co
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
So now imagine..
global namespace pollution + evals & co
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
object properties:
- writable: RO/RW
- enumerable: no loops enumeration
- configurable: deletion prohibited
- all default set to True so watch out
security: JS issues
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
var obj = {}; obj.prop = "LOL";
// OR:
Object.defineProperty(obj, "prop", {
writable: true,
enumerable: true,
configurable: true,
value: "LOL"
})
security: JS issues - prevention
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
strict mode:
- let's throw all errors!
- declare variables!
- global namespaces help
security: JS issues - prevention
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
"use strict";
function do_smt() {
do_smt.caller; // no way :)
do_smt.arguments; // no way :)
}
security: JS issues - prevention
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
"use strict";
eval("var smt = 123");
console.log(smt); // sorry – ReferenceError
security: JS issues - prevention
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
"use strict";
eval("var smt = 123");
console.log(smt); // sorry – ReferenceError
But watch out:
"use strict";
var smt = 0;
eval("smt = 123");
console.log(smt); // outputs “123” properly
security: JS issues - prevention
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
strict mode:
- evals & co are not that insecure now
- no access to caller and args props
- enable globally or for some scope
- what about strict mode in 3rd
party mods?
security: JS issues - prevention
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Static code analysis
- If not doing it already – just do
- Commit hooks in (D)VCSes
- JSHint / JSLint
- Create policy for static code analysis
- Update & check this policy regularly
node.js – exploits anyone?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- http://seclists.org/bugtraq – ? hits
- http://osvdb.org – ? hits
- http://1337day.com, http://www.exploitdb.com – ? hit
- http://nodesecurity.io/advisories – ? hits
node.js – exploits anyone?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- http://seclists.org/bugtraq – 0 hits
- http://osvdb.org – 2 hits
- http://1337day.com, http://www.exploitdb.com – 1 hit
- http://nodesecurity.io/advisories – 4 hits
node.js – exploits anyone?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- http://seclists.org/bugtraq – 0 hits
- http://osvdb.org – 2 hits
- http://1337day.com, http://www.exploitdb.com – 1 hit
- http://nodesecurity.io/advisories – 4 hits
Such security big?
node.js – exploits anyone?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- http://seclists.org/bugtraq – 0 hits
- http://osvdb.org – 2 hits
- http://1337day.com, http://www.exploitdb.com – 1 hit
- http://nodesecurity.io/advisories – 4 hits
Such security big?
not exactly
node.js – what's wrong than?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js security is a blank page
http://www.slideshare.net/ASF-WS/asfws-2012-nodejs-security-old-vulnerabilities-in-new-dresses-par-sven-vetsch
node.js – exceptions / callbacks
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
callbacks Error object – remember to handle those
var fs = require("fs");
fs.readFile("/some/file", "utf8", function (err, contents) {
// err will be null if no error occured
// ... otherwise there will be info about error
});
forget about handling and die debugging
node.js – eventemitter
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
EventEmitter: emitting events 4 async actions
var http = require("http");
http.get("http://nodejs.org/", function (res) {
res.on("data", function (chunk) {
do_something_with_chunk;
});
res.on("error", function (err) {
// listener handling error
});
});
Attach listeners to errors events or
welcome unhandled exception!
node.js – uncaught exceptions
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- by default node.js will print stack trace and terminate thread
- EventEmitter / process / uncaughtException
// it looks like this by default:
process.on("uncaughtException", function (err) {
console.error(err);
console.trace();
process.exit();
});
node.js – uncaught exceptions
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- by default node.js will print stack trace and terminate thread
- EventEmitter / process / uncaughtException
// it looks like this by default:
process.on("uncaughtException", function (err) {
console.error(err);
console.trace();
process.exit();
});
So do you really want to comment out
the 'process.exit()' line?
node.js – domains
- error handling mechanism
- group I/O operations
- when err event -> domain is notified not process
- context clarity
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js – domains
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Using Express take look at that:
https://github.com/brianc/node-domain-middleware
Assigning each Express request to a separate
domain?
node.js – npm modules
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- npm install (-g)
- who creates modules?
- who verifies those?
- how to update?
- semantic versioning in package.json
- "connect":"~1.8.7" -> 1.8.7 - 1.9
node.js – npm modules
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
--ignore-scripts
stop preinstall/prepublish scripts
- mods auditing: https://nodesecurity.io/
node.js – npm modules
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
The scale of npm modules
node.js – npm modules
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Comparison to other langs (mods/day):
node.js – npm modules
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Remember:
- use strict?
- static analysis?
- does include some test suite?
- what is the dependency tree?
node.js – express
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Express – web dev framework
Built on top of connect
node.js – express – basic auth
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
var express = require('express'),
app = express();
app.use(express.basicAuth("user", "pwd"));
app.get("/", function (req, res) {
res.send('Hello World');
});
app.listen(8080);
Plain text and simple auth issues
node.js – express – SSL auth
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
var express = require('express'), routes = require('./routes'), fs = require('fs')
var opts = {
key: fs.readFileSync('ssl/server/keys/server.key'),
cert: fs.readFileSync('ssl/server/certificates/server.crt'),
ca: fs.readFileSync('ssl/ca/ca.crt'),
crl: fs.readFileSync('ssl/ca/ca.crl'),
requestCert: true,
rejectUnauthorized: true
passphrase: "pwd" // <<<< really here?
};
var app = module.exports = express.createServer(opts);
app.configure(function(){
app.set('views', __dirname + '/views');
...
});
app.get('/', routes.index);
app.listen(8443);
node.js – express – passport.js
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- provides API for authentication and authorization
- authentication:
- LocalStrategy
- OpenIDStrategy
- OAuth / FacebookStrategy
node.js – express – authorization
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
var users = [
{ id: 1, name: "user1", role: "admin" },
{ id: 2, name: "user2", role: "common" },
];
function loadUser(req, res, next) {
req.userData = users[req.params.user];
return next();
}
function requireRole(role) {
return function (req, res, next) {
if (req.user.role === role) {
return next();
} else {
return next(new Error("Unauthorized"));
}
};}
node.js – express – authorization
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
app.get("/users/:user", loadUser, function (req, res) {
res.send(req.user.name);
});
app.del("/users/:user", requireRole("admin"), loadUser,
function (req,res) {
res.send("User deleted");
});
node.js – express – logging
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
OWASP will tell you what should be logged :)
https://www.owasp.org/index.php/Logging_Cheat_Sheet
- authentication & authorisation
- session management
- errors & weirdo events
- events (startups, shutdowns, slowdowns etc)
- high risk functionalities (payments, privileges, admins)
node.js – express – logging
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Try Winston module (Github -> flatiron/winston)
- logging to console
- logging to file
- sending logs over HTTP
- CouchDB, Redis, MongoDB, Riak etc
node.js – express – sessions
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
var express = require('express');
var app = express();
var RedisStore = require('connect-redis')(express);
app.use(express.cookieParser());
app.use(express.session({
store: new RedisStore({
host: '127.0.0.2',
port: 6379,
db: 3,
pass: 'pwd'
}),
secret: 'this-is-very-secret'
}));
app.get('/somewhere', function(req, res) {
res.send('In the middle of nowhere');
});
app.listen(process.env.PORT || 8080);
node.js – common threats
- CSRF
- input validation
- XSS
- DoS
- ReDoS
- HPP
- request size
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js – monitoring anyone?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- is app functional? :)
- is app overloaded?
- app should provide monitoring interface
- how many errors caught?
- are forks alive and OK?
node.js – sandboxing
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js – sandboxing
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Such security..Such security..
Very fortress!!1Very fortress!!1
WOW :)WOW :)
node.js – sandboxing
SElinux sandbox:
- legit r/w from stdin/out + only define FDs
- no network access
- no access to any other processes files
- cgroups friendly :)
- lightweight!
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js – sandboxing
libvirtd sandbox:
- use LXC, Qemu or KVM
- provides high level API
- don't need to know virt internals
- integrates with systemd inside the sandbox
- virt-sandbox -c lxc:/// /bin/sh
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js – sandboxing
Docker:
- very easy learning curve – just run & go
- it just works
- big community
- growing rapidly
- almost stable ;)
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js – one more thing
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Just...
node.js – one more thing
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
Just...
Don't run as `root`!!!
node.js – tracing execution
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- SmartOS / Joyent: debugging
- Bunyan / Dtrace
- strace of course...
node.js – testing
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- maybe some interface for white-box pentests?
- unit-testing 4 the sake! (Mocha, supertest, should.js)
- OWASP Zed Attack Proxy
scaling node.js – cluster module
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
http://aosabook.org
scaling node.js – cluster module
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
http://aosabook.org
scaling node.js – containers
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
scaling node.js – resources
Just use cgroups
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
node.js performance
- c10k problem!
- paypal – release the Kraken & stories
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
So what do you think about JS?
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
- JS is for children? wrong, children aren't async ;)
- JS is slow? wrong – V8!
- JS is not scalable? wrong – we'll JS the world!
- JS is insecure? wrong – people do
node.js.learning
- Node Security Book
- OWASP Node Goat (top10)
- nodesecurity.io (Twitter, RSS)
Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js security
Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js security
Infosec & meet.js meetups @krakow
meetup.com
Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js security
Docker workshops with node.js!
#dockerkrk #nodekrk
http://maciek.lasyk.info/sysop
maciek@lasyk.info
@docent-net
Any Qs?
Thank you :)

Mais conteúdo relacionado

Mais procurados

Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010Chris Gates
 
LasCon 2014 DevOoops
LasCon 2014 DevOoops LasCon 2014 DevOoops
LasCon 2014 DevOoops Chris Gates
 
Zombies in Kubernetes
Zombies in KubernetesZombies in Kubernetes
Zombies in KubernetesThomas Fricke
 
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Chris Gates
 
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...Codemotion
 
Turbocharged Java with Quarkus | JakartaOne Livestream
 Turbocharged Java with Quarkus | JakartaOne Livestream Turbocharged Java with Quarkus | JakartaOne Livestream
Turbocharged Java with Quarkus | JakartaOne LivestreamJakarta_EE
 
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...Cohesive Networks
 
Kubernetes - security you need to know about it
Kubernetes - security you need to know about itKubernetes - security you need to know about it
Kubernetes - security you need to know about itHaydn Johnson
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new blackChris Gates
 
Ryan Koop's Docker Chicago Meetup Demo March 12 2014
Ryan Koop's Docker Chicago Meetup Demo March 12 2014Ryan Koop's Docker Chicago Meetup Demo March 12 2014
Ryan Koop's Docker Chicago Meetup Demo March 12 2014Cohesive Networks
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaJadson Santos
 
Open Canary - novahackers
Open Canary - novahackersOpen Canary - novahackers
Open Canary - novahackersChris Gates
 
DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015Chris Gates
 
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...Codemotion
 
The NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelyThe NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelySander van der Burg
 
Docker Security - Secure Container Deployment on Linux
Docker Security - Secure Container Deployment on LinuxDocker Security - Secure Container Deployment on Linux
Docker Security - Secure Container Deployment on LinuxMichael Boelen
 

Mais procurados (20)

Docker 1.11
Docker 1.11Docker 1.11
Docker 1.11
 
Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010
 
LasCon 2014 DevOoops
LasCon 2014 DevOoops LasCon 2014 DevOoops
LasCon 2014 DevOoops
 
Zombies in Kubernetes
Zombies in KubernetesZombies in Kubernetes
Zombies in Kubernetes
 
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
 
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
Oded Coster - Stack Overflow behind the scenes - how it's made - Codemotion M...
 
Turbocharged Java with Quarkus | JakartaOne Livestream
 Turbocharged Java with Quarkus | JakartaOne Livestream Turbocharged Java with Quarkus | JakartaOne Livestream
Turbocharged Java with Quarkus | JakartaOne Livestream
 
JEE on DC/OS
JEE on DC/OSJEE on DC/OS
JEE on DC/OS
 
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
AppSec USA 2014 talk by Chris Swan "Implications & Opportunities at the Bleed...
 
Kubernetes - security you need to know about it
Kubernetes - security you need to know about itKubernetes - security you need to know about it
Kubernetes - security you need to know about it
 
devops@cineca
devops@cinecadevops@cineca
devops@cineca
 
Windows attacks - AT is the new black
Windows attacks - AT is the new blackWindows attacks - AT is the new black
Windows attacks - AT is the new black
 
Ryan Koop's Docker Chicago Meetup Demo March 12 2014
Ryan Koop's Docker Chicago Meetup Demo March 12 2014Ryan Koop's Docker Chicago Meetup Demo March 12 2014
Ryan Koop's Docker Chicago Meetup Demo March 12 2014
 
Containerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and JavaContainerizing a Web Application with Vue.js and Java
Containerizing a Web Application with Vue.js and Java
 
Open Canary - novahackers
Open Canary - novahackersOpen Canary - novahackers
Open Canary - novahackers
 
DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015DevOops & How I hacked you DevopsDays DC June 2015
DevOops & How I hacked you DevopsDays DC June 2015
 
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
Justin Cormack - The 10 Container Security Tricks That Will Help You Sleep At...
 
Wireguard VPN
Wireguard VPNWireguard VPN
Wireguard VPN
 
The NixOS project and deploying systems declaratively
The NixOS project and deploying systems declarativelyThe NixOS project and deploying systems declaratively
The NixOS project and deploying systems declaratively
 
Docker Security - Secure Container Deployment on Linux
Docker Security - Secure Container Deployment on LinuxDocker Security - Secure Container Deployment on Linux
Docker Security - Secure Container Deployment on Linux
 

Semelhante a Scaling and securing node.js apps

Atmosphere 2014: Scaling and securing node.js apps - Maciej Lasyk
Atmosphere 2014: Scaling and securing node.js apps - Maciej LasykAtmosphere 2014: Scaling and securing node.js apps - Maciej Lasyk
Atmosphere 2014: Scaling and securing node.js apps - Maciej LasykPROIDEA
 
Practical Approaches to Cloud Native Security
Practical Approaches to Cloud Native SecurityPractical Approaches to Cloud Native Security
Practical Approaches to Cloud Native SecurityKarthik Gaekwad
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfssusercd195b
 
The Cloud Native Stack
The Cloud Native StackThe Cloud Native Stack
The Cloud Native StackQAware GmbH
 
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
"Black Clouds and Silver Linings in Node.js Security" Liran Tal"Black Clouds and Silver Linings in Node.js Security" Liran Tal
"Black Clouds and Silver Linings in Node.js Security" Liran TalJulia Cherniak
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceBo-Yi Wu
 
Rolling Up Your Sleeves
Rolling Up Your SleevesRolling Up Your Sleeves
Rolling Up Your Sleevesdjjackj
 
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP Liran Tal
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppEdureka!
 
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015AboutYouGmbH
 
Node.js security - JS Day Italy 2018
Node.js security - JS Day Italy 2018Node.js security - JS Day Italy 2018
Node.js security - JS Day Italy 2018Liran Tal
 
Matteo Meucci - Security Summit 12th March 2019
Matteo Meucci - Security Summit 12th March 2019Matteo Meucci - Security Summit 12th March 2019
Matteo Meucci - Security Summit 12th March 2019Minded Security
 
Modern Web Architecture<br>based on JS, API and Markup
Modern Web Architecture<br>based on JS, API and MarkupModern Web Architecture<br>based on JS, API and Markup
Modern Web Architecture<br>based on JS, API and MarkupLadislav Prskavec
 
Serverless DevSecOps: Why We Must Make it Everyone's Problem | Hillel Solow
Serverless DevSecOps: Why We Must Make it Everyone's Problem | Hillel SolowServerless DevSecOps: Why We Must Make it Everyone's Problem | Hillel Solow
Serverless DevSecOps: Why We Must Make it Everyone's Problem | Hillel SolowAWSCOMSUM
 
Brad Enterprise Solution Architect
Brad Enterprise Solution ArchitectBrad Enterprise Solution Architect
Brad Enterprise Solution ArchitectBrad Travis
 
Top 50 Node.js Interview Questions and Answers | Edureka
Top 50 Node.js Interview Questions and Answers | EdurekaTop 50 Node.js Interview Questions and Answers | Edureka
Top 50 Node.js Interview Questions and Answers | EdurekaEdureka!
 
Why Architecture in Web Development matters
Why Architecture in Web Development mattersWhy Architecture in Web Development matters
Why Architecture in Web Development mattersLars Jankowfsky
 
Heterogeneous Data Mining with Spark
Heterogeneous Data Mining with SparkHeterogeneous Data Mining with Spark
Heterogeneous Data Mining with SparkKNIMESlides
 

Semelhante a Scaling and securing node.js apps (20)

Atmosphere 2014: Scaling and securing node.js apps - Maciej Lasyk
Atmosphere 2014: Scaling and securing node.js apps - Maciej LasykAtmosphere 2014: Scaling and securing node.js apps - Maciej Lasyk
Atmosphere 2014: Scaling and securing node.js apps - Maciej Lasyk
 
Practical Approaches to Cloud Native Security
Practical Approaches to Cloud Native SecurityPractical Approaches to Cloud Native Security
Practical Approaches to Cloud Native Security
 
Functional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdfFunctional Scala 2022 - scalajs Alexis.pdf
Functional Scala 2022 - scalajs Alexis.pdf
 
The Cloud Native Stack
The Cloud Native StackThe Cloud Native Stack
The Cloud Native Stack
 
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
"Black Clouds and Silver Linings in Node.js Security" Liran Tal"Black Clouds and Silver Linings in Node.js Security" Liran Tal
"Black Clouds and Silver Linings in Node.js Security" Liran Tal
 
Introduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript ConferenceIntroduction to Grunt.js on Taiwan JavaScript Conference
Introduction to Grunt.js on Taiwan JavaScript Conference
 
Rolling Up Your Sleeves
Rolling Up Your SleevesRolling Up Your Sleeves
Rolling Up Your Sleeves
 
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
Node.js Security - XSS, Vulnerable Dependencies, Snyk, OWASP
 
Node JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web AppNode JS Express: Steps to Create Restful Web App
Node JS Express: Steps to Create Restful Web App
 
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
Rolando Santamaría Masó - Simplicity meets scalability - code.talks 2015
 
Node.js security - JS Day Italy 2018
Node.js security - JS Day Italy 2018Node.js security - JS Day Italy 2018
Node.js security - JS Day Italy 2018
 
Node js Introduction
Node js IntroductionNode js Introduction
Node js Introduction
 
Matteo Meucci - Security Summit 12th March 2019
Matteo Meucci - Security Summit 12th March 2019Matteo Meucci - Security Summit 12th March 2019
Matteo Meucci - Security Summit 12th March 2019
 
Modern Web Architecture<br>based on JS, API and Markup
Modern Web Architecture<br>based on JS, API and MarkupModern Web Architecture<br>based on JS, API and Markup
Modern Web Architecture<br>based on JS, API and Markup
 
Serverless DevSecOps: Why We Must Make it Everyone's Problem | Hillel Solow
Serverless DevSecOps: Why We Must Make it Everyone's Problem | Hillel SolowServerless DevSecOps: Why We Must Make it Everyone's Problem | Hillel Solow
Serverless DevSecOps: Why We Must Make it Everyone's Problem | Hillel Solow
 
Brad Enterprise Solution Architect
Brad Enterprise Solution ArchitectBrad Enterprise Solution Architect
Brad Enterprise Solution Architect
 
Top 50 Node.js Interview Questions and Answers | Edureka
Top 50 Node.js Interview Questions and Answers | EdurekaTop 50 Node.js Interview Questions and Answers | Edureka
Top 50 Node.js Interview Questions and Answers | Edureka
 
Why Architecture in Web Development matters
Why Architecture in Web Development mattersWhy Architecture in Web Development matters
Why Architecture in Web Development matters
 
Going serverless
Going serverlessGoing serverless
Going serverless
 
Heterogeneous Data Mining with Spark
Heterogeneous Data Mining with SparkHeterogeneous Data Mining with Spark
Heterogeneous Data Mining with Spark
 

Mais de Maciej Lasyk

Programowanie AWSa z CLI, boto, Ansiblem i libcloudem
Programowanie AWSa z CLI, boto, Ansiblem i libcloudemProgramowanie AWSa z CLI, boto, Ansiblem i libcloudem
Programowanie AWSa z CLI, boto, Ansiblem i libcloudemMaciej Lasyk
 
Co powinieneś wiedzieć na temat devops?f
Co powinieneś wiedzieć na temat devops?f Co powinieneś wiedzieć na temat devops?f
Co powinieneś wiedzieć na temat devops?f Maciej Lasyk
 
"Containers do not contain"
"Containers do not contain""Containers do not contain"
"Containers do not contain"Maciej Lasyk
 
Linux containers & Devops
Linux containers & DevopsLinux containers & Devops
Linux containers & DevopsMaciej Lasyk
 
Under the Dome (of failure driven pipeline)
Under the Dome (of failure driven pipeline)Under the Dome (of failure driven pipeline)
Under the Dome (of failure driven pipeline)Maciej Lasyk
 
About cultural change w/Devops
About cultural change w/DevopsAbout cultural change w/Devops
About cultural change w/DevopsMaciej Lasyk
 
Orchestrating docker containers at scale (#DockerKRK edition)
Orchestrating docker containers at scale (#DockerKRK edition)Orchestrating docker containers at scale (#DockerKRK edition)
Orchestrating docker containers at scale (#DockerKRK edition)Maciej Lasyk
 
Orchestrating Docker containers at scale
Orchestrating Docker containers at scaleOrchestrating Docker containers at scale
Orchestrating Docker containers at scaleMaciej Lasyk
 
Ghost in the shell
Ghost in the shellGhost in the shell
Ghost in the shellMaciej Lasyk
 
High Availability (HA) Explained - second edition
High Availability (HA) Explained - second editionHigh Availability (HA) Explained - second edition
High Availability (HA) Explained - second editionMaciej Lasyk
 
Monitoring with Nagios and Ganglia
Monitoring with Nagios and GangliaMonitoring with Nagios and Ganglia
Monitoring with Nagios and GangliaMaciej Lasyk
 
RHEL/Fedora + Docker (and SELinux)
RHEL/Fedora + Docker (and SELinux)RHEL/Fedora + Docker (and SELinux)
RHEL/Fedora + Docker (and SELinux)Maciej Lasyk
 
High Availability (HA) Explained
High Availability (HA) ExplainedHigh Availability (HA) Explained
High Availability (HA) ExplainedMaciej Lasyk
 
Shall we play a game? PL version
Shall we play a game? PL versionShall we play a game? PL version
Shall we play a game? PL versionMaciej Lasyk
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?Maciej Lasyk
 

Mais de Maciej Lasyk (17)

Rundeck & Ansible
Rundeck & AnsibleRundeck & Ansible
Rundeck & Ansible
 
Programowanie AWSa z CLI, boto, Ansiblem i libcloudem
Programowanie AWSa z CLI, boto, Ansiblem i libcloudemProgramowanie AWSa z CLI, boto, Ansiblem i libcloudem
Programowanie AWSa z CLI, boto, Ansiblem i libcloudem
 
Co powinieneś wiedzieć na temat devops?f
Co powinieneś wiedzieć na temat devops?f Co powinieneś wiedzieć na temat devops?f
Co powinieneś wiedzieć na temat devops?f
 
"Containers do not contain"
"Containers do not contain""Containers do not contain"
"Containers do not contain"
 
Git Submodules
Git SubmodulesGit Submodules
Git Submodules
 
Linux containers & Devops
Linux containers & DevopsLinux containers & Devops
Linux containers & Devops
 
Under the Dome (of failure driven pipeline)
Under the Dome (of failure driven pipeline)Under the Dome (of failure driven pipeline)
Under the Dome (of failure driven pipeline)
 
About cultural change w/Devops
About cultural change w/DevopsAbout cultural change w/Devops
About cultural change w/Devops
 
Orchestrating docker containers at scale (#DockerKRK edition)
Orchestrating docker containers at scale (#DockerKRK edition)Orchestrating docker containers at scale (#DockerKRK edition)
Orchestrating docker containers at scale (#DockerKRK edition)
 
Orchestrating Docker containers at scale
Orchestrating Docker containers at scaleOrchestrating Docker containers at scale
Orchestrating Docker containers at scale
 
Ghost in the shell
Ghost in the shellGhost in the shell
Ghost in the shell
 
High Availability (HA) Explained - second edition
High Availability (HA) Explained - second editionHigh Availability (HA) Explained - second edition
High Availability (HA) Explained - second edition
 
Monitoring with Nagios and Ganglia
Monitoring with Nagios and GangliaMonitoring with Nagios and Ganglia
Monitoring with Nagios and Ganglia
 
RHEL/Fedora + Docker (and SELinux)
RHEL/Fedora + Docker (and SELinux)RHEL/Fedora + Docker (and SELinux)
RHEL/Fedora + Docker (and SELinux)
 
High Availability (HA) Explained
High Availability (HA) ExplainedHigh Availability (HA) Explained
High Availability (HA) Explained
 
Shall we play a game? PL version
Shall we play a game? PL versionShall we play a game? PL version
Shall we play a game? PL version
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 

Último

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 

Último (20)

SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Scaling and securing node.js apps

  • 1. Maciej Lasyk AtmosphereConf 2014 Warsaw, 2014-05-19 scaling & securing node.js apps
  • 2. $ whoami Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - not only sysadmin ;) - 14+ years of exp software dev / sysop - ops lead - contributing to Fedora Project (and couple more) - and...
  • 3. $ whoami Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - not only sysadmin ;) - 14+ years of exp software dev / sysop - ops lead - contributing to Fedora Project (and couple more) - and... - love AtmosphereConf – been to Velocity
  • 4. Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 5. So what do you think about JS? - JS is for children! - JS is slow! - JS is not scalable! - JS is insecure! Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 6. node.js: history - 2008: Google V8 release - 2009: Ryan Dahl & node.js - 2011: node.js release - later on – Joyent till today - and ^liftsecurity / nodesecurity.io Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 7. Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 8. Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 (http://www.phloxblog.in)
  • 9. node.js: developing ur code Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 raw node.js coding srsly?
  • 10. node.js: developing ur code maybe some frameworks? - webserver: express - client-server sync: backbone.js - push: socket.io - templates: swig - i18n: babelfish - client – side: jquery - or... - kraken.js does the all (almost) Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 11. node.js: developing ur code Biggest win here? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 12. node.js: developing ur code Biggest win here? One Language to Rule them all! Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 13. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 eval() like fncs takes string argument and evalute those as source code
  • 14. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 eval() like fncs takes string argument and evalute those as source code srsly – who does that?
  • 15. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 not only evals: setInterval(code,2) setTimeout(code,2) str = new Function(code) Content-Security-Policy knows about those but we're talking about server side...
  • 16. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Global nameSpace Pollution - node.js is single threaded - all variable values are common - one could thrtically change bhv of others reqs - watch out for globals then!
  • 17. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 var auth = false; app.get('/auth', function(req, res) { if(legit) { auth = true; res.send("success"); }); app.get('/payments-db', function(req, res) { if (auth) res.send("legit to see all payments data"); else res.send("not logged in"); }) app.listen(8080);
  • 18. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 So now imagine.. global namespace pollution + evals & co
  • 19. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 So now imagine.. global namespace pollution + evals & co
  • 20. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 object properties: - writable: RO/RW - enumerable: no loops enumeration - configurable: deletion prohibited - all default set to True so watch out
  • 21. security: JS issues Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 var obj = {}; obj.prop = "LOL"; // OR: Object.defineProperty(obj, "prop", { writable: true, enumerable: true, configurable: true, value: "LOL" })
  • 22. security: JS issues - prevention Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 strict mode: - let's throw all errors! - declare variables! - global namespaces help
  • 23. security: JS issues - prevention Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 "use strict"; function do_smt() { do_smt.caller; // no way :) do_smt.arguments; // no way :) }
  • 24. security: JS issues - prevention Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 "use strict"; eval("var smt = 123"); console.log(smt); // sorry – ReferenceError
  • 25. security: JS issues - prevention Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 "use strict"; eval("var smt = 123"); console.log(smt); // sorry – ReferenceError But watch out: "use strict"; var smt = 0; eval("smt = 123"); console.log(smt); // outputs “123” properly
  • 26. security: JS issues - prevention Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 strict mode: - evals & co are not that insecure now - no access to caller and args props - enable globally or for some scope - what about strict mode in 3rd party mods?
  • 27. security: JS issues - prevention Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Static code analysis - If not doing it already – just do - Commit hooks in (D)VCSes - JSHint / JSLint - Create policy for static code analysis - Update & check this policy regularly
  • 28. node.js – exploits anyone? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - http://seclists.org/bugtraq – ? hits - http://osvdb.org – ? hits - http://1337day.com, http://www.exploitdb.com – ? hit - http://nodesecurity.io/advisories – ? hits
  • 29. node.js – exploits anyone? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - http://seclists.org/bugtraq – 0 hits - http://osvdb.org – 2 hits - http://1337day.com, http://www.exploitdb.com – 1 hit - http://nodesecurity.io/advisories – 4 hits
  • 30. node.js – exploits anyone? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - http://seclists.org/bugtraq – 0 hits - http://osvdb.org – 2 hits - http://1337day.com, http://www.exploitdb.com – 1 hit - http://nodesecurity.io/advisories – 4 hits Such security big?
  • 31. node.js – exploits anyone? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - http://seclists.org/bugtraq – 0 hits - http://osvdb.org – 2 hits - http://1337day.com, http://www.exploitdb.com – 1 hit - http://nodesecurity.io/advisories – 4 hits Such security big? not exactly
  • 32. node.js – what's wrong than? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 node.js security is a blank page http://www.slideshare.net/ASF-WS/asfws-2012-nodejs-security-old-vulnerabilities-in-new-dresses-par-sven-vetsch
  • 33. node.js – exceptions / callbacks Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 callbacks Error object – remember to handle those var fs = require("fs"); fs.readFile("/some/file", "utf8", function (err, contents) { // err will be null if no error occured // ... otherwise there will be info about error }); forget about handling and die debugging
  • 34. node.js – eventemitter Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 EventEmitter: emitting events 4 async actions var http = require("http"); http.get("http://nodejs.org/", function (res) { res.on("data", function (chunk) { do_something_with_chunk; }); res.on("error", function (err) { // listener handling error }); }); Attach listeners to errors events or welcome unhandled exception!
  • 35. node.js – uncaught exceptions Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - by default node.js will print stack trace and terminate thread - EventEmitter / process / uncaughtException // it looks like this by default: process.on("uncaughtException", function (err) { console.error(err); console.trace(); process.exit(); });
  • 36. node.js – uncaught exceptions Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - by default node.js will print stack trace and terminate thread - EventEmitter / process / uncaughtException // it looks like this by default: process.on("uncaughtException", function (err) { console.error(err); console.trace(); process.exit(); }); So do you really want to comment out the 'process.exit()' line?
  • 37. node.js – domains - error handling mechanism - group I/O operations - when err event -> domain is notified not process - context clarity Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 38. node.js – domains Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Using Express take look at that: https://github.com/brianc/node-domain-middleware Assigning each Express request to a separate domain?
  • 39. node.js – npm modules Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - npm install (-g) - who creates modules? - who verifies those? - how to update? - semantic versioning in package.json - "connect":"~1.8.7" -> 1.8.7 - 1.9
  • 40. node.js – npm modules Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 --ignore-scripts stop preinstall/prepublish scripts - mods auditing: https://nodesecurity.io/
  • 41. node.js – npm modules Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 The scale of npm modules
  • 42. node.js – npm modules Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Comparison to other langs (mods/day):
  • 43. node.js – npm modules Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Remember: - use strict? - static analysis? - does include some test suite? - what is the dependency tree?
  • 44. node.js – express Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Express – web dev framework Built on top of connect
  • 45. node.js – express – basic auth Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 var express = require('express'), app = express(); app.use(express.basicAuth("user", "pwd")); app.get("/", function (req, res) { res.send('Hello World'); }); app.listen(8080); Plain text and simple auth issues
  • 46. node.js – express – SSL auth Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 var express = require('express'), routes = require('./routes'), fs = require('fs') var opts = { key: fs.readFileSync('ssl/server/keys/server.key'), cert: fs.readFileSync('ssl/server/certificates/server.crt'), ca: fs.readFileSync('ssl/ca/ca.crt'), crl: fs.readFileSync('ssl/ca/ca.crl'), requestCert: true, rejectUnauthorized: true passphrase: "pwd" // <<<< really here? }; var app = module.exports = express.createServer(opts); app.configure(function(){ app.set('views', __dirname + '/views'); ... }); app.get('/', routes.index); app.listen(8443);
  • 47. node.js – express – passport.js Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - provides API for authentication and authorization - authentication: - LocalStrategy - OpenIDStrategy - OAuth / FacebookStrategy
  • 48. node.js – express – authorization Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 var users = [ { id: 1, name: "user1", role: "admin" }, { id: 2, name: "user2", role: "common" }, ]; function loadUser(req, res, next) { req.userData = users[req.params.user]; return next(); } function requireRole(role) { return function (req, res, next) { if (req.user.role === role) { return next(); } else { return next(new Error("Unauthorized")); } };}
  • 49. node.js – express – authorization Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 app.get("/users/:user", loadUser, function (req, res) { res.send(req.user.name); }); app.del("/users/:user", requireRole("admin"), loadUser, function (req,res) { res.send("User deleted"); });
  • 50. node.js – express – logging Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 OWASP will tell you what should be logged :) https://www.owasp.org/index.php/Logging_Cheat_Sheet - authentication & authorisation - session management - errors & weirdo events - events (startups, shutdowns, slowdowns etc) - high risk functionalities (payments, privileges, admins)
  • 51. node.js – express – logging Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Try Winston module (Github -> flatiron/winston) - logging to console - logging to file - sending logs over HTTP - CouchDB, Redis, MongoDB, Riak etc
  • 52. node.js – express – sessions Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 var express = require('express'); var app = express(); var RedisStore = require('connect-redis')(express); app.use(express.cookieParser()); app.use(express.session({ store: new RedisStore({ host: '127.0.0.2', port: 6379, db: 3, pass: 'pwd' }), secret: 'this-is-very-secret' })); app.get('/somewhere', function(req, res) { res.send('In the middle of nowhere'); }); app.listen(process.env.PORT || 8080);
  • 53. node.js – common threats - CSRF - input validation - XSS - DoS - ReDoS - HPP - request size Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 54. node.js – monitoring anyone? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - is app functional? :) - is app overloaded? - app should provide monitoring interface - how many errors caught? - are forks alive and OK?
  • 55. node.js – sandboxing Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 56. node.js – sandboxing Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Such security..Such security.. Very fortress!!1Very fortress!!1 WOW :)WOW :)
  • 57. node.js – sandboxing SElinux sandbox: - legit r/w from stdin/out + only define FDs - no network access - no access to any other processes files - cgroups friendly :) - lightweight! Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 58. node.js – sandboxing libvirtd sandbox: - use LXC, Qemu or KVM - provides high level API - don't need to know virt internals - integrates with systemd inside the sandbox - virt-sandbox -c lxc:/// /bin/sh Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 59. node.js – sandboxing Docker: - very easy learning curve – just run & go - it just works - big community - growing rapidly - almost stable ;) Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 60. node.js – one more thing Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Just...
  • 61. node.js – one more thing Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 Just... Don't run as `root`!!!
  • 62. node.js – tracing execution Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - SmartOS / Joyent: debugging - Bunyan / Dtrace - strace of course...
  • 63. node.js – testing Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - maybe some interface for white-box pentests? - unit-testing 4 the sake! (Mocha, supertest, should.js) - OWASP Zed Attack Proxy
  • 64. scaling node.js – cluster module Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 http://aosabook.org
  • 65. scaling node.js – cluster module Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 http://aosabook.org
  • 66. scaling node.js – containers Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 67. scaling node.js – resources Just use cgroups Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 68. node.js performance - c10k problem! - paypal – release the Kraken & stories Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014
  • 69. So what do you think about JS? Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js securityMaciej Lasyk, scaling&securing node.js appsMaciej Lasyk, scaling&securing node.js apps, #AtmosphereConf 2014 - JS is for children? wrong, children aren't async ;) - JS is slow? wrong – V8! - JS is not scalable? wrong – we'll JS the world! - JS is insecure? wrong – people do
  • 70. node.js.learning - Node Security Book - OWASP Node Goat (top10) - nodesecurity.io (Twitter, RSS) Maciej Lasyk, Ganglia & Nagios 3/25Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js security
  • 71. Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js security Infosec & meet.js meetups @krakow meetup.com
  • 72. Maciej Lasyk, node.js security 1/25Maciej Lasyk, node.js security Docker workshops with node.js! #dockerkrk #nodekrk