windy city rails - layered security

45
Layered Security Whoever said it was like chess never heard of Tetris Aaron Bedra Chief Security Officer, Eligible @abedra keybase.io/abedra

Upload: aaron-bedra

Post on 18-Jan-2017

340 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: Windy City Rails - Layered Security

Layered SecurityWhoever said it was like chess never heard of Tetris

Aaron Bedra Chief Security Officer, Eligible @abedra keybase.io/abedra

Page 2: Windy City Rails - Layered Security

What problem are you solving?

Page 3: Windy City Rails - Layered Security

Start with problems and goals

Page 4: Windy City Rails - Layered Security

Design specific controls that solve specific

problems

Page 5: Windy City Rails - Layered Security

Proper security design has layers

Page 6: Windy City Rails - Layered Security

Process things at the right time and place

Page 7: Windy City Rails - Layered Security

Locality of reference is just as important in good

security design

Page 8: Windy City Rails - Layered Security

Start with a wide net and narrow focus as you get

closer to the data

Page 9: Windy City Rails - Layered Security

What does it look like?

Page 10: Windy City Rails - Layered Security

Edge

Core

Page 11: Windy City Rails - Layered Security

Layers as they apply to Rails• CDN

• Load Balancer

• Web Server

• Application

• Rack

• Active/Action*

• Database

Page 12: Windy City Rails - Layered Security

Or more succinctly, edge, application, data

Page 13: Windy City Rails - Layered Security

Act as far up the stack as you can

Page 14: Windy City Rails - Layered Security

The closer to data a request gets the more damage it can cause

Page 15: Windy City Rails - Layered Security

The Edge

Page 16: Windy City Rails - Layered Security

This is where you want to do most of the work

Page 17: Windy City Rails - Layered Security

Static configuration goes a long way!

Page 18: Windy City Rails - Layered Security

Static configuration checklistAt least a B+ rating on SSL Labs*

Reject extensions that you don’t want to accept

Reject known bad user agents

Reject specific known bad actors

Custom error pages that fit your application

Basic secure headers

Page 19: Windy City Rails - Layered Security

You can also add dynamic controls to the

edge

Page 20: Windy City Rails - Layered Security

Dynamic controls

• Authentication caching

• Web Application Firewalls*

• Load Shedding

• Repsheet

Page 21: Windy City Rails - Layered Security

The Application

Page 22: Windy City Rails - Layered Security

In Rails the Application layer has two parts

Page 23: Windy City Rails - Layered Security

We can (and should) separate what we do in Rack

and what we do after it.

Page 24: Windy City Rails - Layered Security

There’s a nice list of pre-processing tools you can

pick up for Rack

Page 25: Windy City Rails - Layered Security

Rack controls• Rack Attack

• Rack Honeypot

• Rack DetectTor/Rack Tor Block

• Warden

• Rack Throttle

• Rack Cylon

• Custom Middleware

Page 26: Windy City Rails - Layered Security

Rack should do a lot of the heavy lifting for checks that don’t require additional data

Page 27: Windy City Rails - Layered Security

Leave what’s left for the application

Page 28: Windy City Rails - Layered Security

Rails controls• Lots of built-ins

• Authorization

• Encryption*

• Domain specific logic (fraud, business rules, etc)

• A proper secure development lifecycle

Page 29: Windy City Rails - Layered Security

Software security has to play a major role

Page 30: Windy City Rails - Layered Security

It should be present in every development

phase

Page 31: Windy City Rails - Layered Security

And the stuff in between

Page 32: Windy City Rails - Layered Security

Your build should have

Tests

Some notion of what is tested

Code metrics

Brakeman

Bundler Audit

Page 33: Windy City Rails - Layered Security

Data stores

Page 34: Windy City Rails - Layered Security

You all have work to do here

Page 35: Windy City Rails - Layered Security

A lot of times this gets ignored

Page 36: Windy City Rails - Layered Security

Database checklistNothing uses the root user

Strong and securely stored production passwords

Separate users for runtime and migrations

Separate databases for production, staging, test, etc

Firewalls for everything but the systems that need access

Logs, logs, logs

Backups!!!

Page 37: Windy City Rails - Layered Security

The stuff in between

Page 38: Windy City Rails - Layered Security

You can’t forget about monitoring, auditing, and

proper logging!

Page 39: Windy City Rails - Layered Security

You’ll thank yourself when things get rough

Page 40: Windy City Rails - Layered Security

And last but not least, focus

Page 41: Windy City Rails - Layered Security

Security is not something you do when you can

Page 42: Windy City Rails - Layered Security

Doing it halfway will only create false confidence

Page 43: Windy City Rails - Layered Security

And remember…

Page 44: Windy City Rails - Layered Security
Page 45: Windy City Rails - Layered Security

References• dev.ssllabs.com/ssltest/

• www.keycdn.com/blog/http-security-headers/

• github.com/repsheet

• github.com/rack/rack/wiki/List-of-Middleware

• guides.rubyonrails.org/security.html

• www.owasp.org/index.php/Ruby_on_Rails_Cheatsheet

• brakemanscanner.org/