the blackbox project: safely store secrets in git/mercurial (originally for puppet)

38
The BlackBox project Safely storing secrets and credentials in Git/Mg (mostly for use by Puppet) Tom Limoncelli, SRE, StackExchange.com Blog: EverythingSysadmin.com My new book! the-cloud-book.com

Upload: tom-limoncelli

Post on 28-Nov-2014

1.271 views

Category:

Software


0 download

DESCRIPTION

A presentation given at PuppetCamp NYC 2014 about why Puppet users should stop storing secrets in Git/Hg and encrypt them instead. TLDR: It enables collaboration.

TRANSCRIPT

Page 1: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

The BlackBox projectSafely storing secrets and credentials in

Git/Mg (mostly for use by Puppet)

Tom Limoncelli, SRE, StackExchange.comBlog: EverythingSysadmin.com

My new book! the-cloud-book.com

Page 2: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

125+ Q&A CommunitiesServerFault.comStackOverflow.com

(We <3 Puppet!)

StackExchange.com

Page 3: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

What are secrets?

Anything you don’t want exposed externally.

● SSL Certificates (the private bits)● Passwords● API keys

Page 4: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Puppet manages secrets

Page 5: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)
Page 6: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

If you store secrets in git, you’re gonna have a bad time.

Page 7: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

● Laptops get stolen.● Workstations have guest accounts● Git server “Circle of Trust” includes:

○ Everyone with admin access to workstations.■ Your desktop support people?

○ Everyone with admin access to your git server:■ Server team, storage team, backup team

○ Everyone you collaborate with that wants read-only access to Puppet manifests.

Page 8: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

You have 3 bad options:

1. Deny git access. (Hurts collaboration)2. Permit git access. (Hurts security)3. Email individual files. (Hurts… just hurts)

Page 9: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Option 4: Encrypt secret parts

● If a file contains secrets, encrypt before checking into Git.

● Need to edit a secret?○ Decrypt - Edit - Encrypt

Page 10: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

What about Puppet master?

● After “git pull”, decrypt all files.○ Automate this as part of CI.

● Files are unencrypted “at rest”.● This does not decrease security:

○ No worse than what we were doing before.○ If you can break into root or puppet on the master,

you’ve already won.

Page 11: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Easy, right?

Decrypt:

Encrypt:

Page 12: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Easy, right?

Decrypt:

Encrypt:

● ...and don’t make any typos when entering the command● ...and don't accidentally check in the unencrypted version

Page 13: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Security is 1% technology plus 99% following the procedures correctly.

Any process with more than 1 step probably won't be followed consistently most of the time.

Related reading: "Why Johnny Can't Encrypt: A Usability Evaluation of PGP 5.0”, Alma Whitten", Usenix Security 1999

Page 14: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Therefore…. we automate

Introducing: Blackbox

Scripts for keeping Puppet secrets in git/hg.

Page 15: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

User commands:

Decrypt for editing:

Encrypt when done:

Page 16: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

First time a file is encrypted:

Enroll a file into the system:

Page 17: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Commands that act on all GPG files:

Decrypt all files: (for use on puppet master)

Re-encrypt all files: (after new users added)

Page 18: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Everyone has their own key

This doesn’t use “symmetric encryption” where there is one passphrase to decrypt/encrypt all files.

We maintain a keyring of:● Each person that should have access.● A key for the Puppet master.

Page 19: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Indoctrinate a new user:

1. New user does this:

●●

(Currently a doc, not a script. Patches gladly accepted.)

Page 20: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Indoctrinate a new user:

2. Existing admin does this:

Page 21: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Demo: Edit a file

Page 22: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Demo: Edit a file

Page 23: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Demo: Edit a file

Page 24: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Demo: Edit a file

Page 25: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Demo: Edit a file

Page 26: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Demo: Edit a file

Page 27: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Demo: Edit a file

Page 28: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)
Page 29: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)
Page 30: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Code is open source as of 7/2014

● Entirely written in bash.● MIT License.● Download it now:

○ https://github.com/StackExchange/blackbox

Page 31: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

In the project’s first 9 months:

StackExchange/ServerFault has eliminated plaintext secrets in our Puppet git repo.● 7 SREs+Devs sharing the repo securely.● 50+ files now stored encrypted.

○ Mostly SSL certs and SSH private keys.● 40+ individual passwords/API keys:

○ Everything from SNMP communities, SaaS API keys, and many many passwords.

Page 32: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Future plans

❏ Open source scripts.❏ More usability enhancements.❏ Better setup documentation.

Page 33: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Join the open source projecthttp://github.com/StackExchange/blackbox

Page 34: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Q&A

URLs from this talk:https://github.com/StackExchange/blackbox

EverythingSysadmin.com

Page 35: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Shameless plugPre-order now! Save 35%

Ships in September.

informit.com/TPOSADiscount code TPOSA35

Read “rough cuts” today:safaribooksonline.com

Page 36: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

Q&A

URLs from this talk:https://github.com/StackExchange/blackbox

EverythingSysadmin.comthe-cloud-book.com

informit.com/TPOSA (code TPOSA35)

Page 37: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)

● Easier transition. No Puppet code changes for big files like SSL certs.

● Faster. Zero run-time performance impact on master.

● eyaml didn’t exist when we started.

Why didn’t we use eyaml?

Page 38: The BlackBox Project: Safely store secrets in Git/Mercurial (originally for Puppet)