89

Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

  • Upload
    docong

  • View
    226

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 2: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Microservices –a security nightmare?

GOTO Nights Zürich - March 3, 2016

Maximilian Schöfmann | @schoefmann

Container Solutions Switzerland

Page 3: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 4: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 5: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 6: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 7: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Microservices (2016) …

small, hence many services

talking over the network built with different technologies

by autonomous teams with end-to-end responsibility doing DevOps and Continuous Delivery

using containers

Page 8: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Microservices (2016) …

small, hence many services

talking over the network built with different technologies

by autonomous teams with end-to-end responsibility doing DevOps and Continuous Delivery

using containers

Page 9: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Microservices are the result of combining

architectural ideas from lightweight SOA and Domain Driven Design,

organisational approaches like DevOps and Agile Software Development, and

technology innovations like Containers and Programmable Infrastructure

Page 10: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Architecture Organisation

Technology

Page 11: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Monolith

Page 12: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“many small services”

Page 13: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Monolith - method calls

Page 14: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Microservices - talking over the network

Page 15: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Java7(1.7.0_03)

Monolith - few technologies

Page 16: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Microservices - built with different technologies

nodejs0.9

Ruby2.1

Java7

Go1.4

Java8

Page 17: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Security Gates vs…

Page 18: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

… autonomous teams with end-to-end responsibility

Page 19: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

dedicated security experts vs…

(ISC)2®

Page 20: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

doing DevOps

OWASP??

Page 21: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

classic “Security Sandwich” vs…

Specification

Implementation Validation

Page 22: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

… Continuous Delivery

Page 23: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

well isolated “real server” vs…

Page 24: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

… using containers

Page 25: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Attack surface - VMs vs containers

XENHypervisor-10^5LOC

LinuxKernel-10^7LOC

Page 26: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 27: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 28: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Highly coupled services No clear boundaries

Page 29: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Loosely coupled services Clear boundaries

Page 30: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

many small services

Page 31: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

impact of breach can be contained locally

Page 32: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Clear service boundaries limit the impact of breaches”

Page 33: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Keep APIs minimal

Page 34: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

payment_data

(stateless)

cat_ pictures

(stateless)

user_db

Microservices have their own data store

Page 35: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

payment_data

(stateless)

cat_ pictures

(stateless)

user_db

Microservices have their own data store

Page 36: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Let the need-to-know principle guide your API design”

Page 37: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

payment_data

(stateless)

cat_ pictures

(stateless)

user_db

different security levels should require different security properties in services, e.g. encryption, auth, security testing…

Page 38: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Classify services into distinct security levels”

Page 39: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

API Gateways

APIG

atew

ay

• Access control • Rate limiting • HTTPS termination

. . .

Page 40: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

API Gateways

APIG

atew

ay

WAF PaymentSvc.

Page 41: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Isolate services with different security levels through gateways”

Page 42: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Authorization & Authentication

Page 43: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Authorization & Authentication

Page 44: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Use scalable auth techniques without single points of failure”

Page 45: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 46: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Secrets management

vaultproject.io square.github.io/keywhiz

Page 47: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Manage secrets with special purpose services”

Page 48: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 49: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Freeze image for analysis

paymentservice

instance#2

docsuploadservice

instance#1

paymentservice

instance#1

catpictureservice

instance#1

memegeneratorinstance#1

bookmarkmanager

instance#1

paymentservice

instance#1

Page 50: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Or even the running container… (criu.org)

paymentservice

instance#2

docsuploadservice

instance#1

paymentservice

instance#1

catpictureservice

instance#1

memegeneratorinstance#1

bookmarkmanager

instance#1

paymentservice

instance#1

Page 51: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Leverage container features for forensics”

Page 52: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Scheduling constraints

paymentservice

instance#2

docsuploadservice

instance#1

paymentservice

instance#1

catpictureservice

instance#1

memegeneratorinstance#1

bookmarkmanager

instance#1

Page 53: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Run services of different security levels on different hosts”

Page 54: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Replace containers on deploy

paymentservice

instance#2

docsuploadservice

instance#1

paymentservice

instance#3

catpictureservice

instance#1

memegeneratorinstance#1

bookmarkmanager

instance#1

Page 55: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Embrace immutable infrastructure”

Page 56: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“built with different technologies”

nodejs0.9

Ruby2.1

Java7

Go1.4

Java8

Page 57: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Monocultures…

Page 58: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Scanning images at rest

Clair(CoreOS)Nautilus(DockerInc.)

Page 59: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Scan images already during the build process”

Page 60: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Container technology…

BSDJails2000

2001Virtuozzo

Linux-VServer

SolarisZones2004

LXC2008

2013Docker

rkt2014

1982chroot

2007cgroups

Page 61: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Docker security hardening…

container-solutions.com/security

•read-onlycontainers•minimalbaseimages•dropcapabilities•traditionalhardening(AppArmor,SELinux…)

...

Page 62: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Minimise the attack surface of images and hosts”

Page 63: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Unify & secure deployment methods

Simple to add… • TLS • Authentication • Authorisation • Logging & Auditing • Image verification

scprsync

git

Page 64: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Have a single, hardened method to deploy”

Page 65: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 66: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

…end-to-end responsibility

Page 67: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Gates and Accountability

Page 68: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Security Sandwich and Autonomy

Specification

Implementation Validation

Page 69: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Security Sandwich and Autonomy

Page 70: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Trust

IdeafromA.T.KearnyAnalysis

Accountability Expertise

Autonomy&Entrepreneurship

Collaboration&Support

Trust

Page 71: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Security aspects must becomepart of the Definition of Done…

Page 72: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Rugged Software Manifesto

ruggedsoftware.org

Page 73: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

SecDevOps?

SecOps?

DevSec?

Page 74: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing
Page 75: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

TheroleofITArchitectsisalreadychanging

Now,theroleoftheSecurityTeamneedstochange

Page 76: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Accountability ensures security is built in, not bolted on”

Page 77: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Avg: 103 days to fix a vulnerability

http://darkmatters.norsecorp.com/2015/06/09/security-vulnerabilities-take-average-of-103-days-to-remediate/

Page 78: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

CD reduces reaction time

Page 79: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Leverage Continuous Delivery as a security feature”

Page 80: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Test pyramid

UnitTests

ServiceTests

UItests

fasterfeed

back

from“SucceedingwithAgile”(MikeCohn)

confiden

ce

Page 81: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Security-Test pyramid / AppSec pipeline

staticcodeanalysis

Vulnerabilityscanning

E2Esecuritytests

fasterfeed

back

confiden

ce

Page 82: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

BDD style

continuumsecurity.net/bdd-intro.htmlgauntlt.org

Page 83: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

“Have your test pyramid reflect security”

Page 84: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Architecture Organisation

Technology

Page 85: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Architecture

Clearserviceboundarieslimittheimpactofbreaches

Lettheneed-to-knowprincipleguideyourAPIdesign

Classifyservicesintodistinctsecuritylevels,whichmandatedifferentsecurityproperties

Usescalableauthtechniqueswithoutsinglepointsoffailure

Isolateserviceswithdifferentsecuritylevelswithgateways

Managesecretsinspecialisedservices

Page 86: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Technology

Runservicesofdifferentsecuritylevelsondifferenthosts

Leveragecontainerfeaturesforforensics

Embraceimmutableinfrastructure

Scanimagesaspartofthebuildprocess

Haveasingle,hardenedmethodtodeploy

Minimisetheattacksurfaceofimagesandhosts

Page 87: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Organisation

LeverageContinuousDeliveryasasecurityfeature

Haveyourtestpyramidreflectsecurity

Accountabilityensuressecurityisbuiltin,notboltedon

Page 88: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

Nightmare?

Page 89: Microservices - · PDF file(stateless) user_db Microservices have their own data store “Let the need-to-know principle ... • Authentication • Authorisation • Logging & Auditing

[email protected] | @schoefmann

container-solutions.com