Top Banner
HARDENING YOUR CONFIG MANAGEMENT SECURITY AND ATTACK VECTORS IN CONFIG MANAGEMENT
131

Hardening Your Config Management - Security and Attack Vectors in Config Management

Jan 15, 2017

Download

Technology

Peter Souter
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Hardening Your Config Management - Security and Attack Vectors in Config Management

HARDENING YOUR CONFIG MANAGEMENT

SECURITY AND ATTACK VECTORS IN CONFIG MANAGEMENT

Page 2: Hardening Your Config Management - Security and Attack Vectors in Config Management

WHO AM I?

> Peter Souter > @petersouter

> @petems - IRC/GitHub> Professional Services Engineer at

Puppet Labs> Work with customers when they buy

services and teach Puppet classes

Page 3: Hardening Your Config Management - Security and Attack Vectors in Config Management

THIS IS MY 3RD FOSDEM!

Page 4: Hardening Your Config Management - Security and Attack Vectors in Config Management

WHAT IS THIS ALL ABOUT?

HTTPS://FLIC.KR/P/BHYT8B

Page 5: Hardening Your Config Management - Security and Attack Vectors in Config Management

SECURITY IS HARD

AND UNDER APPRECIATED!

HTTPS://TWITTER.COM/PETECHESLOCK/STATUS/595617204273618944

Page 6: Hardening Your Config Management - Security and Attack Vectors in Config Management

SPECIFIC REQUIREMENTSMULTIPLE SYSTEMS

EVERY OS HAS IT'S OWN QUIRKS AND NUANCES

Page 7: Hardening Your Config Management - Security and Attack Vectors in Config Management

CONFIG MANAGEMENT IS HERE TO SAVE THE DAY!

Page 8: Hardening Your Config Management - Security and Attack Vectors in Config Management

HOWEVER...

Page 9: Hardening Your Config Management - Security and Attack Vectors in Config Management

QUIS CUSTODIET IPSOS

CUSTODES?

Page 10: Hardening Your Config Management - Security and Attack Vectors in Config Management

A SYSTEM CAPABLE OF PERFORMING CHANGES FOR CONFIGURATION ACROSS

THOUSANDS OF SERVERS...

Page 11: Hardening Your Config Management - Security and Attack Vectors in Config Management

COULD CAUSE A LOT OF DAMAGE!

Page 12: Hardening Your Config Management - Security and Attack Vectors in Config Management

CONFIG MANAGEMENT: A PRETTY BIG ATTACK

VECTOR....

Page 13: Hardening Your Config Management - Security and Attack Vectors in Config Management

HOW DO WE HARDEN CONFIG MANAGEMENT

ITSELF?

Page 14: Hardening Your Config Management - Security and Attack Vectors in Config Management

DON'T WANT TO FOCUS TOO MUCH ON THE TOOLS

THEMSELVES

Page 15: Hardening Your Config Management - Security and Attack Vectors in Config Management

I HAVE BIASESBOTH CONSCIOUS AND SUBCONSCIOUS

Page 16: Hardening Your Config Management - Security and Attack Vectors in Config Management

THERE IS NO ONE-SIZE-FITS-ALL TO HARDEN CONFIG MANAGEMENT!

Page 17: Hardening Your Config Management - Security and Attack Vectors in Config Management

IT’S A LOT OF CHANGES TO PROCESSES

Page 18: Hardening Your Config Management - Security and Attack Vectors in Config Management

PEOPLE ARE HARDER TO CHANGE THAN COMPUTERS!

Page 19: Hardening Your Config Management - Security and Attack Vectors in Config Management

ACCEPT THAT YOU WILL FAIL, PLAN ACCORDINGLY

Page 20: Hardening Your Config Management - Security and Attack Vectors in Config Management

THE BADDIES HAVE MORE TIME/MONEY/ENERGY

THAN YOU DO!

Page 21: Hardening Your Config Management - Security and Attack Vectors in Config Management

YOU WILL FAIL AT SOME POINT. YOU NEED TO FAIL

SECURELY

Page 22: Hardening Your Config Management - Security and Attack Vectors in Config Management

A QUICK SURVEY

Page 23: Hardening Your Config Management - Security and Attack Vectors in Config Management

WHO HERE USES...ANSIBLE

CFENGINE

CHEF

PUPPET

SALTSTACK

Page 24: Hardening Your Config Management - Security and Attack Vectors in Config Management

WHERE TO START?

Page 25: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 26: Hardening Your Config Management - Security and Attack Vectors in Config Management

FIRST 3 RESULTS ARE FROM A COMPANY THAT RHYMES WITH RIPTIRE...

Page 27: Hardening Your Config Management - Security and Attack Vectors in Config Management

4TH RESULT: OWASP PRINCIPLES

Page 28: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 29: Hardening Your Config Management - Security and Attack Vectors in Config Management

5TH RESULT...

Page 30: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 31: Hardening Your Config Management - Security and Attack Vectors in Config Management

8TH RESULT: PRETTY GOOD BLOG POST

Page 32: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 33: Hardening Your Config Management - Security and Attack Vectors in Config Management

STILL, NOT SUPER IN-DEPTH...

Page 34: Hardening Your Config Management - Security and Attack Vectors in Config Management

GUESS I'LL HAVE TO ACTUALLY DO SOME

RESEARCH...

Page 35: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 36: Hardening Your Config Management - Security and Attack Vectors in Config Management

DATA

Page 37: Hardening Your Config Management - Security and Attack Vectors in Config Management

IT'S EASY TO LEAK DATA...

Page 38: Hardening Your Config Management - Security and Attack Vectors in Config Management

ESPECIALLY SOMETHING YOU CAN LOOK FOR

AUTOMATICALLY

Page 39: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 40: Hardening Your Config Management - Security and Attack Vectors in Config Management

BEST PRACTICESEPARATION OF CONCERNS

Page 41: Hardening Your Config Management - Security and Attack Vectors in Config Management

REMOVE DATA FROM CODEESPECIALLY COMPANY SPECIFIC DATA!

Page 42: Hardening Your Config Management - Security and Attack Vectors in Config Management

DATA ABSTRACTION:PUPPET - HIERA

CHEF - DATA BAGS/ATTRIBUTESANSIBLE - ROLES

SALT - GRAINS/PILLAR

Page 43: Hardening Your Config Management - Security and Attack Vectors in Config Management

BAD

Page 44: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 45: Hardening Your Config Management - Security and Attack Vectors in Config Management

GOOD

Page 46: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 47: Hardening Your Config Management - Security and Attack Vectors in Config Management

ADVANTAGE:NOT ONLY MORE SECURE, CLEANER CODE THAT'S

MORE REUSABLE!

Page 48: Hardening Your Config Management - Security and Attack Vectors in Config Management

THEORETICAL SCENARIO:

Page 49: Hardening Your Config Management - Security and Attack Vectors in Config Management

YOU SHOULD BE ABLE TO RELEASE MOST CODE YOU WRITE PUBLICALLY WITHOUT ANY SORT OF SECURITY

ISSUES

Page 50: Hardening Your Config Management - Security and Attack Vectors in Config Management

ANYTHING SENSITIVE SHOULD BE KEPT IN THE DATA ABSTRACTION LAYER

Page 51: Hardening Your Config Management - Security and Attack Vectors in Config Management

EXAMPLE: GDS

Page 52: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 53: Hardening Your Config Management - Security and Attack Vectors in Config Management

HTTPS://GITHUB.COM/ALPHAGOV/GOVUK-PUPPET

HTTPS://GDSTECHNOLOGY.BLOG.GOV.UK/2016/01/19/OPENING-GOV-UKS-

PUPPET-REPOSITORY/

Page 54: Hardening Your Config Management - Security and Attack Vectors in Config Management

YOUR DATA SHOULD IS NOW SEPARATED. HOORAY!

Page 55: Hardening Your Config Management - Security and Attack Vectors in Config Management

BUT IT'S PLAINTEXT. BOO!

Page 56: Hardening Your Config Management - Security and Attack Vectors in Config Management

ENCRYPTION

Page 57: Hardening Your Config Management - Security and Attack Vectors in Config Management

ENCRYPTING DATA WITH YOUR APPLICATION SPECIFIC TOOLS:

Page 58: Hardening Your Config Management - Security and Attack Vectors in Config Management

PUPPET - HIERA-EYAMLCHEF - CHEF-VAULT

ANSIBLE - ANSIBLE VAULTSALT - SALT.MODULES.GPGCFENGINE - CF-KEYCRYPT

Page 59: Hardening Your Config Management - Security and Attack Vectors in Config Management

TOOL-SPECIFIC VAULTS ARE GREAT, BUT ARE OFTEN LIMITED IN

FUNCTIONALITY OUTSIDE THAT TOOL.

Page 60: Hardening Your Config Management - Security and Attack Vectors in Config Management

YOU DON'T WANT TO STORE THE SAME PASSWORD IN 10 DIFFERENT SYSTEMS

IF YOU CAN HELP ITTHAT'S 10X MORE THAT NEEDS TO BE

SECURED

Page 61: Hardening Your Config Management - Security and Attack Vectors in Config Management

EXTERNAL SECRET

SERVERS?

Page 62: Hardening Your Config Management - Security and Attack Vectors in Config Management

OPEN SOURCE POTENTIALS CHOICES:OPENSTACK'S BARBICAN

CLOUDFLARE'S REDOCTOBERHASHICOP'S VAULT

Page 63: Hardening Your Config Management - Security and Attack Vectors in Config Management

GOING DEEPER:

Page 64: Hardening Your Config Management - Security and Attack Vectors in Config Management

SECURING DATA WITH SOURCE CONTROL

Page 65: Hardening Your Config Management - Security and Attack Vectors in Config Management

"I wanted to make a configuration management repository open for others to look at and contribute

to (à la Wikimedia's Puppet repository)...

Page 66: Hardening Your Config Management - Security and Attack Vectors in Config Management

However, the repository contained secret material, like SSL keys and

passwords...

Page 67: Hardening Your Config Management - Security and Attack Vectors in Config Management

git-crypt was developed so the secret material could be

protected without having to remove it from the repository (which is what Wikimedia had to

do).- ANDREW AYER

Page 68: Hardening Your Config Management - Security and Attack Vectors in Config Management

GIT-CRYPT?HTTPS://WWW.AGWA.NAME/

PROJECTS/GIT-CRYPT/

Page 69: Hardening Your Config Management - Security and Attack Vectors in Config Management

GIT-SUBMODULES OR SEPARATE REPOS

Page 70: Hardening Your Config Management - Security and Attack Vectors in Config Management

STAY IN (VERSION) CONTROL

Page 71: Hardening Your Config Management - Security and Attack Vectors in Config Management

GATE CONFIG MANAGEMENT CHANGES

BEHIND VERSION CONTROL

Page 72: Hardening Your Config Management - Security and Attack Vectors in Config Management

REMEMBER TO KEEP COMMITS CLEAN AS WELL!

Page 73: Hardening Your Config Management - Security and Attack Vectors in Config Management

commit 88a055c4c3dcec34d5r9054011963649be89d49cMerge: 783d425 1743488Author: Peter Souter <[email protected]>Date: Mon April 1 23:47:43 2030 +0000

Turned off SSL, we don't need that right?

also password is now password123

Page 74: Hardening Your Config Management - Security and Attack Vectors in Config Management

RBAC FOR GIT REPOS CONTAINING THE DATA

Page 75: Hardening Your Config Management - Security and Attack Vectors in Config Management

RBAC

Page 76: Hardening Your Config Management - Security and Attack Vectors in Config Management

SPLIT ACCESS TO CONFIG MANAGEMENT TOOLS

BASED ON NEED

Page 77: Hardening Your Config Management - Security and Attack Vectors in Config Management

MOST APPLICATIONS HAVE SOME FORM OF RBAC HOOKS TO ANOTHER

AUTHORIZED SYSTEM (LDAP, AD, ETC.)

Page 78: Hardening Your Config Management - Security and Attack Vectors in Config Management

REVIEW PROCESSES(AUTOMATED AND MANUAL)

Page 79: Hardening Your Config Management - Security and Attack Vectors in Config Management

AUTOMATEDSPEC TESTING

AUTOMATED TESTING SUITESLINTING/SYNTAX CHECKING

Page 80: Hardening Your Config Management - Security and Attack Vectors in Config Management

MANUALCODE REVIEWS

GET SECURITY TEAM INVOLVED IN THE PROCESSES!

Page 81: Hardening Your Config Management - Security and Attack Vectors in Config Management

WORK WITH AUDITORS

Page 82: Hardening Your Config Management - Security and Attack Vectors in Config Management

PEOPLE LOVE TO HATE AUDITORS

Page 83: Hardening Your Config Management - Security and Attack Vectors in Config Management

ADVERSARIAL ENVIRONMENTS ARE NOT

FUN

Page 84: Hardening Your Config Management - Security and Attack Vectors in Config Management

IF YOU HAVE A GOOD WORKING RELATIONSHIP WITH THEM, THEY'RE LIKE

AN ADDITION TO YOUR TEAM.

Page 85: Hardening Your Config Management - Security and Attack Vectors in Config Management

LET'S FACE IT, YOU'LL HAVE TO DEAL WITH THEM ANYWAY, SO YOU MIGHT AS

WELL MAKE IT ENJOYABLE!

Page 86: Hardening Your Config Management - Security and Attack Vectors in Config Management

ASK AROUND

Page 87: Hardening Your Config Management - Security and Attack Vectors in Config Management

SOFT SKILL/CULTURAL SOLUTION

Page 88: Hardening Your Config Management - Security and Attack Vectors in Config Management

COMPARE YOUR SECURITY WITH OTHERS WHEN

POSSIBLE

Page 89: Hardening Your Config Management - Security and Attack Vectors in Config Management

A SECURITY MODEL MADE IN A VACUUM IS A SMELL

Page 90: Hardening Your Config Management - Security and Attack Vectors in Config Management

IF YOU'RE A CUSTOMER, ASK YOUR VENDOR

IF YOU'RE A FOSS USER, ASK ON MAILING LISTS

Page 91: Hardening Your Config Management - Security and Attack Vectors in Config Management

GAME DAYS AND DRILLS

Page 92: Hardening Your Config Management - Security and Attack Vectors in Config Management

IF SOMEONE HAD ACCESS TO THE VARIOUS PARTS OF

YOUR CONFIG MANAGEMENT INFRA...

Page 93: Hardening Your Config Management - Security and Attack Vectors in Config Management

HOW MUCH DAMAGE COULD THEY DO?HOW FAST COULD YOU REVOKE

ACCESS?HOW LONG WOULD IT TAKE YOU TO

NOTICE?

Page 94: Hardening Your Config Management - Security and Attack Vectors in Config Management

MONITOR, DON'T JUST LOG

Page 95: Hardening Your Config Management - Security and Attack Vectors in Config Management

GET A BASELINE OF WHAT YOUR CONFIG

MANAGEMENT DEPLOYS LOOK LIKE

Page 96: Hardening Your Config Management - Security and Attack Vectors in Config Management

ELK, STATSD, RIEMANN, COLLECTD, ETC.

Page 97: Hardening Your Config Management - Security and Attack Vectors in Config Management

GET DATA ON WHAT LOOKS SUSPICIOUS

Page 98: Hardening Your Config Management - Security and Attack Vectors in Config Management

ACTIVITY WHEN YOU DON'T EXPECT IT

4XX, 5XX ERRORS FROM YOUR CONFIG MANAGEMENT INFRA

UNEXPLAINED INCREASES IN THE TEMPERATURE OF YOUR MACHINES IN

THE DATA CENTREGENERAL ERRORS IN VARIOUS LOGS

Page 99: Hardening Your Config Management - Security and Attack Vectors in Config Management

COULD BE MALICIOUS, COULD BE ACCIDENTAL,

COULD BE A BUG...

Page 100: Hardening Your Config Management - Security and Attack Vectors in Config Management

ALL OF WHICH YOU SHOULD KNOW ABOUT!

Page 101: Hardening Your Config Management - Security and Attack Vectors in Config Management

REDUCE SURFACE LEVEL

OF ATTACK

Page 102: Hardening Your Config Management - Security and Attack Vectors in Config Management

NOT SECURITY THROUGH OBSCURITY!

Page 103: Hardening Your Config Management - Security and Attack Vectors in Config Management

A BASIC EXAMPLE AT THE APPLICATION LEVEL

Page 104: Hardening Your Config Management - Security and Attack Vectors in Config Management

> Chef: sensitive: true> Puppet: show_diff=false

> Ansible: no_log: True> Salt: --state-verbose=false

Page 105: Hardening Your Config Management - Security and Attack Vectors in Config Management

SECURITY BASELINE

Page 106: Hardening Your Config Management - Security and Attack Vectors in Config Management

USE THE SAME SECURITY BASELINE FOR ANY SORT OF SYSTEM:

NO DIRECT INTERNET ACCESS UNLESS ABSOLUTELY NECESSARY

USE BASTION HOSTS FOR DIRECT INTERNET ACCESS

MIRROR REPOS AND ARTIFACTS

KEEP PACKAGES UP TO DATE AND PATCHED

SENSIBLE FIREWALL RULES

Page 107: Hardening Your Config Management - Security and Attack Vectors in Config Management

HARDEN CONFIG MANAGEMENT

INFRASTRUCTURE WITH CONFIG MANAGEMENT!

Page 108: Hardening Your Config Management - Security and Attack Vectors in Config Management

CENTER FOR INTERNET SECURITY BENCHMARKS

Page 109: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 110: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 111: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 112: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 113: Hardening Your Config Management - Security and Attack Vectors in Config Management

HARDENING.IO

Page 114: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 115: Hardening Your Config Management - Security and Attack Vectors in Config Management

SOME 3 LETTER AGENCIES HAVE EVEN RELEASED

THEIR CONFIG MANAGEMENT CODE...

Page 116: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 117: Hardening Your Config Management - Security and Attack Vectors in Config Management

IN LIGHT OF RECENT EVENTS, THAT MIGHT BE NOT SUCH A GREAT THING

BUT HEY, IT'S CONFIG MANAGEMENT, SO YOU CAN INSPECT AND ADAPT WHERE

NECESSARY!

Page 118: Hardening Your Config Management - Security and Attack Vectors in Config Management

SSH

Page 119: Hardening Your Config Management - Security and Attack Vectors in Config Management

PRIMARILY FOR ANSIBLE

Page 120: Hardening Your Config Management - Security and Attack Vectors in Config Management

BUT SSH CAN BE USED FOR OTHER TOOLS AS

WELL...

Page 121: Hardening Your Config Management - Security and Attack Vectors in Config Management

PUPPET - SUPPLY DROP/CAPISTRANOCHEF - KNIFE SOLOSALT - SALT SSH

CUSTOM MADE SSH-LOOPS WRAPPING LOCAL MODES FOR TOOLS

Page 122: Hardening Your Config Management - Security and Attack Vectors in Config Management

SSH HARDENING STANDARDS

> Whitelisted access> Bastion hosts> Restrict users

> Increase key strength> Rotate keys

> Pre-populated knownhosts

Page 123: Hardening Your Config Management - Security and Attack Vectors in Config Management

HARDEN YOUR SSH WITH CONFIG MANAGEMENT! :)

Page 124: Hardening Your Config Management - Security and Attack Vectors in Config Management

IF YOU'RE USING ~/.ssh/id_rsa FOR EVERYTHING...

YOU'RE DOING IT WRONG :(

Page 125: Hardening Your Config Management - Security and Attack Vectors in Config Management

DEEPER SSH HARDENING...

Page 126: Hardening Your Config Management - Security and Attack Vectors in Config Management

SSH KEYS ON HARDWAREYUBIKEY

SMARTCARD

Page 127: Hardening Your Config Management - Security and Attack Vectors in Config Management

THOUGHT EXPERIMENT:DISABLE SSH COMPLETELY?

Page 128: Hardening Your Config Management - Security and Attack Vectors in Config Management

CONCLUSION

> Get your data out of your code> Encrypt it and control access

> Most normal security conventions apply> Follow best practices from communities and

organizations> Auditing and gating help

> Work together! :)

Page 129: Hardening Your Config Management - Security and Attack Vectors in Config Management

GOING TO CONFIG MANAGEMENT CAMP?

Page 130: Hardening Your Config Management - Security and Attack Vectors in Config Management
Page 131: Hardening Your Config Management - Security and Attack Vectors in Config Management

QUESTIONS? IDEAS?HOW ARE YOU HARDENING YOUR CONFIG

MANAGEMENT?