66
Rebooting (secure) (web) software development with continuous deployment Nick Galbreath http://www.client9.com / [email protected] @ngalbreath OWASP AppSec USA Austin, Texas Oct 25, 2012

Rebooting Software Development - OWASP AppSecUSA

Embed Size (px)

DESCRIPTION

If we are ever going to get ahead of the whack-a-mole security vulnerability game, we, as security professionals need to start getting involved more in the development of software. Let's review the origins of the traditional software development, and what assumptions are made. Then we'll review if those assumptions still hold for modern web applications, and what problems they cause, especially for security. Continuous deployment helps address these problems and allows for faster, more secure development. It's more than just "pushing code a lot", when done correctly it can be transformative to the organization. We'll discuss what continuous deployment is, how to get started, and what components are needed to make it successful, and secure.

Citation preview

Page 1: Rebooting Software Development - OWASP AppSecUSA

Rebooting (secure) (web) software development

with continuous deployment

Nick Galbreathhttp://www.client9.com/ [email protected] @ngalbreath

OWASP AppSec USAAustin, TexasOct 25, 2012

Page 2: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

The latest version of these slideshttp://client9.com/20121025

Page 3: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Presented at OWASP AppSec USAAustin, Texas, USAOctober 25, 2012

Page 4: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Based on a BSides Los Angeles presentation at Hermosa Beach, August 18, 2012http://client9.com/20120816

Three Blocks from Conference.

Page 5: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

I took all these photos in NYC.Unless I didn't.In which case, they are from The Internet.

Page 6: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Continuous Deployment?"Rebooting" software development?

Page 7: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

whoami

• Director of Engineering, Etsy

• enterprise, fraud, security, fun

• New Gig, but... Etsy sponsored my trip here

• VP Engineering, “Company Confidential”

• Stay tuned for details

Nick Galbreath www.client9.com @ngalbreath

Page 8: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Context Alert!• My background is software development

• Mostly in public, web-facing applications

• Everything from C to PHP

• Your mileage may vary if you are in different industries, with different risk profiles

Page 9: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Problem Statement• Web App vulnerabilities aren’t conceptually that

hard and should be easy to deal with.

• In spite (or because) of our efforts, security is an “end of line” process or whack-a-mole

• Security education has been at best marginally useful to developers (in the large, your organization may be different).

• How can we get ever get ahead?

Page 10: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

How did we get here?

View from Hyatt Austin hotel room.

Page 11: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

The Software Product ModelCode flows to functional groups.

• Product Managers spec code

• Engineers write code

• QA tests code

• Security tests code

• Release engineers package code

• Operations runs code

Page 12: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

High Distribution CostThe Software Product Model is designed for applications where the cost of distribution is high. Where “high” might be measure by risk, money, time, resources, customer annoyance.

• Retail, CD/DVDs

• Embedded or Exotic Hardware

• Safety, Medical or Defense Systems

• Operating Systems (phone or desktop)

• Your Homework (1-time deploy)

Page 13: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

SPM -SDLCOpsRelease

QAQA

Development Bug Fix / Slush

New Specs

Com

mits

time in weeks or months

freeze

Specs

Page 14: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

SPM-Production Changes to Production

Major Release Minor Releases Major Release

BigBang

BigBang

New Features going live are 100% correlated with volume of changes to production.

Page 15: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Nothing wrong here.

Given high distribution costs, it makes sense to front-load the development process

Page 16: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

WebApps Y2K• Mostly followed software product model since

that’s all we knew

• High barrier to entry

• Specialized Hardware, software, people to get started

• Lots of engineering to keep things running and scaling.

Page 17: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

True Story

• “Can’t push out the spelling error change since it’s too risky”

• “That code has already been through QA, it’s locked down.”

• “Product has to prioritize that, else we aren’t touching it.”

This

Smells

Page 18: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

WebApps 2012

• Almost no barrier to entry

• Commodity hardware

• “Learn PHP in 24 hours”

• Scaling problems can be outsourced (sorta)

Page 19: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

WebApps 2012 and Cost of Distribution

• Moving a few megabytes from source control to a few machines in production over a 1Gb or 10Gb link.

• In other words... free!

Page 20: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Given this and competitive /customer expectations, it’s not

unreasonable to expect an SDLC moves faster

than the Software Product Model

Page 21: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

On the other hand, WebApps 2012 have very different failure cases

Page 22: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

The Nature of Failure• WebApps 2012 are data-driven.

• and frequently have APIs, user-generated content, social features (unexpected use cases, new problems)

• Failure might be due to algorithm problems, but...

• ...more likely it’s bad user input, bad data in database, or operational load.

• This means data added in the past might cause problems in the future. Complicated!

Page 23: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

• Rollback

• Spend next week figuring out what changed, by whom, caused the breakage

• Re-qa

• Re-push

• meanwhile new code is piling up.

And When It Happens

Page 24: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

When SPM meets WebApp2012• There is a long time between code-written to code-

deployed. This “non-value added” steps for what should be low-cost changes.

• Might be weeks or months before code deployed.

• Feedback loop between code in dev and code in production broken.

• When the bug/security report comes in, it’s likely the engineer is on a different project.

• Any wonder that engineers don’t care for operations or security?

Page 25: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Hypothesis• It is impossible to simulate the production

environment in development, either to operational differences or data differences.

• No amount of QA or Security Testing can prove you don’t have bugs, vulnerabilities, or won’t cause severe operational problems.

• You have bugs and vulnerabilities right now your site.

Page 26: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Conclusion:You're Screwed!

Page 27: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

• Company wide push to move faster

• Being a bottleneck isn’t acceptable.

• Nor is giving up or saying “need more resources”

• Engineers disengaged

• Looming security disaster awaits

• Whack-a-Mole doesn’t scale

Page 28: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

If we want to fix Security,

we have tofix Development.

Page 29: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Continuous Deployment

A System of Software Production Characterized By Numerous Small Changes to the Production Environment

or That Crazy Shit That Etsy Does. And Google.

And Facebook. And Amazon. And Twitter. And NetFlix. So maybe not that crazy.

Page 30: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

CD -Changes to Production

New Features are not correlated with volume of changes to production

new featurenew feature

Page 31: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Developers are responsible and confident with their code.

In Production

Page 32: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

What If You Had a Button that saidDEPLOY

This button logs who performed the change, and what the change was, but no other rules or controls.

•Pushes whatever is on HEAD/TRUNK to production.•In about a minute.•Anyone is allowed to push it.

Page 33: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 1: Fear• Likely no one is going to

push it since they are afraid they’ll break something.

• Meanwhile un-deployed code keeps piling up.

ex. New hires are terrified of deploying an... HTML change!“but I don’t want to break Etsy!”

Page 34: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 2: First Attempt

• At some point, some brave sole will put their code on TRUNK, and push the button.

• It’s likely someone else tells them that their feature blew up the site or doesn’t work, and to please role it back.

Page 35: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 3: With Graphs• The developer learns that they’d don’t know

how the code runs in production and they need some way of understanding how it works.

• Enter Graphite/Ganglia/StatsD! http://codeascraft.etsy.com/2011/02/15/measure-anything-measure-everything/

• Make it free to monitor anything in the application and expose that to everyone.

Page 36: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 4: Push It

• Repushing out code with fix, still causes some problem as witness by a graph falling off a cliff, but the developer was aware of it and was able to role back.

Page 37: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 5: Isolation

• Hmmm, the developer in reviewing the code notices that actually they are pushing a few bugs fixes, and some other minor features.

• Maybe just pushing out a single bug fix one at time to help isolate the problem.

Page 38: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 6: Success!

• Yes! The developer pushed code and fixed a bug and made the site just that much better.

• The secret about continuous deployment is small deltas that you or anyone can understand easily.

Page 39: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 7: Dark Pushes• Now that the developer got the bugs out of the

way, it time for the feature.

• Let’s push out all the supporting files. By themselves they do nothing. By getting these out first, you isolate them as being “unlikely to cause a site problem”

• Also now that they are on the trunk, others can look at them (easily).

Page 40: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 8: Ramp-ups• Now it’s time to get that feature live.

• Instead of a Big Bang, he’ll put a ‘ramp-up’ in the code. This will control how many people on the site will get the new feature.

• Maybe start with “employees only” so his team can test in production.

• Start at 1%, 5%, 10% and make sure things work, graphs are stable and work up to 100%.

• if problem, can ramp-down or turn off.

Page 41: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 8: Eliminate• Along the way you’ll get burned by little things, so, we’ll

• A development environment that mimics prod as close as possible (won’t be exact)

• Fast and stable unit and functional tests that are easy to run. If they are slow and flakey, no one will use them

• Eliminate stupid bugs with commit or pre-commit static analysis.

• Move QA/Security/Release checks as close as possible to the developer.

Page 42: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 9: Communicate• As more people get use to it, you’ll need a way

of co-ordinating releases among people.

• IRC works well

• Need set of conventions that match your risk levels.

• At least developers are talking about releases!

Page 43: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Take 10: Learn• No doubt along the way, serious mistakes will be made.

Complex system failures will happen.

• Learn from them. Do Post-Mortems. Do Root-Cause Analysis.

• Recount what happened.

• 99.99999999% of problems are caused by mistakes ... not maliciousness

• How can the environment be changed so it doesn’t happen again?

• Publish the results.

Page 44: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Butt What About...

Page 45: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

What About That Guy Who Pushes at 3AM

• That Guy who pushes at 3AM, and something goes wrong and wakes up all of operations with pagers going off will quickly learn this was a bad idea.

• It’s about courtesy and respect.

• Of course there are off-hours exception, in which That Guy should pre-inform everyone.

Page 46: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

What about...code reviews?

• Yup, do them

• Nothing here precludes code reviews.

• In fact, it’s frequently easier to do since the reviewer doesn’t have to dork around with branches or tags.... they have all the dark code already on Trunk/Head

• .. and the reviews are smaller and faster

Page 47: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

What about... security reviews?

• Yup do ‘em.

• Nothing here eliminates your existing review cycle.

Page 48: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

What about...Agile Methods?

• (everyone does “agile differently” so hard to qualify this).

• Agile methods frequently work to improve the spec-writing / development cycle

• Or the spec / dev / qa cycle

• But code still pools up waiting to go to production.

Page 49: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

What about Customer Service? Do they freak out with all the changes?

• Remember, most changes either do nothing, or are trivial or are minor.

• Feature launches always need to be co-ordinated with customer service

(from audience question)

Page 50: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreathSo why did I tell you all this?

Page 51: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

That Engineer who previously didn’t push code is now sensitized that their code has consequences

and are responsive to fix it.It’s amazing how interested engineers become in security when you find problems with their code

when they are able to fix quickly themselves.

Page 52: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Security Fixes can go out quickly.

In addition, you know fixes can go out since they happen every day.

Page 53: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

You can repurpose the QA stack, graphing and log analysis for

attack detection and vulnerability prevention.

Need ideas? Check out these other presentations on fraud and security by Etsy:

http://slidesha.re/IMaavqhttp://slidesha.re/JGaU2shttp://slidesha.re/KPvHYuhttp://slidesha.re/Kw5zdV

Page 54: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

While there is always whack-a-mole, you can focus

on being a service organization and work on engineering to be

secure by default.

Page 55: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

New Roles, Less Silos• Developers: works with operations

• QA: works on making systems to empower people to write tests, static analysis, in-house consultancy on good test design

• Release: tools to push code to production, system images.

• Security: in house consultancy, security engineering, secure by default, detection

Page 56: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

So Continuous Deployment is Only for Websites?

Wine Robot at DFW American Airlines lounge

Page 57: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Google Chrome• Really made updates painless for the consumer.

• Frequent changes “regularly” -- maybe not continuous but way faster than normal software product

• Multiple channels of releases.

• Config flags can turn on or off experimental features.

• Works so well, many others are copying this approach.

Page 58: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Apps• Due to cost of deployment being high

(e.g. due to approval from Apple)

• And due to diversity of destination (how many different types of hardware will it run on), hard to predict how well it work.

• Put as much as you can into the release

• Then read configs from internet to light up or turn off features

Page 59: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Chip Design• After this talk, I met an engineer who does

hardware design.

• All changes are tiny and then tested, then committed.

• Any change too big is rejected.

• Learned the hard way that big changes are impossible to understand and test.

Page 60: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

So What Now?

Ice Skating at Rockefeller Center in October.

Page 61: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Security is in a Good Position to Force Change• Security bridges multiple disciplines:

ops, dev, qa, release, business.

• Unique position to make change.

• When breach happens (in whatever the layer), we need to patch fast.

• I hope that is not controversial.

Page 62: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Start with the Deploy Button

Page 63: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

It will change your SDLC

NYC Public Library

Page 64: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Continuous Deployment

Page 65: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Thanks!

Page 66: Rebooting Software Development - OWASP AppSecUSA

Nick Galbreath OWASP USA 2012-10-25 @ngalbreath

Nick Galbreath@ngalbreath [email protected]

http://client9.com/20121025