using vault to decouple mysql secrets

70
Vault DECOUPLING SECRETS & APPLICATIONS

Upload: derek-downey

Post on 10-Jan-2017

157 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Using Vault to decouple MySQL Secrets

VaultDECOUPLING SECRETS & APPLICATIONS

Page 2: Using Vault to decouple MySQL Secrets

Armon Dadgar @armon

Page 3: Using Vault to decouple MySQL Secrets
Page 4: Using Vault to decouple MySQL Secrets

HASHICORP

Page 5: Using Vault to decouple MySQL Secrets

© 2016 Pythian5

Derek Downey @derek_downey

Page 6: Using Vault to decouple MySQL Secrets

© 2016 Pythian6

ABOUT PYTHIAN

11,400 Pythian currently manages more than 11,400 systems.

400+ Pythian currently employs more than 400 people in 200 cities in 35 countries

1997 Pythian was founded in 1997

Global Leader In IT Transformation And Operational Excellence

Unparalleled Expertise • Top 5% in databases, applications, infrastructure, Big Data, Cloud, Data

Science, and DevOps

Unmatched Certifications • 9 Oracle ACEs, 4 Oracle ACE Directors, 1 Oracle ACE Associate • 6 Microsoft MVPs, 1 Microsoft Certified Master • 5 Google Platform Qualified Developers • 1 Cloudera Champion of Big Data • 1 Mongo DB Certified DBA Associate Level • 1 DataStax Certified Partner, 1 MVP • 11 AWS Certified Solutions Architects, 1 AWS Certified Developer, 1 AWS Certified SysOps Administrator

Broad Technical Experience • Oracle, Microsoft, MySQL, Oracle EBS, Hadoop, Cassandra, MongoDB,

virtualization, configuration management, monitoring, trending, and more.

Page 7: Using Vault to decouple MySQL Secrets

© 2016 Pythian7

SOME OF OUR CLIENTS

Page 8: Using Vault to decouple MySQL Secrets

SECRET MANAGEMENT

Page 9: Using Vault to decouple MySQL Secrets

WHAT IS "SECRET"?

Page 10: Using Vault to decouple MySQL Secrets

SECRET VS. SENSITIVE

Page 11: Using Vault to decouple MySQL Secrets

SECRET SENSITIVEDB CREDENTIALS

CLOUD ACCESS KEYS

SSL CA/CERTIFICATES

ENCRYPTION KEYS

WIFI PASSWORDS

EMAIL ADDRESSES

PHONE NUMBERS

MOTHER'S MAIDEN NAME

DATACENTER LOCATIONS

CUSTOMER PII

SOURCE CODE EMAIL/CHAT

Page 12: Using Vault to decouple MySQL Secrets

SECRET SENSITIVEDB CREDENTIALS

CLOUD ACCESS KEYS

SSL CA/CERTIFICATES

ENCRYPTION KEYS

WIFI PASSWORDS

EMAIL ADDRESSES

PHONE NUMBERS

MOTHER'S MAIDEN NAME

DATACENTER LOCATIONS

CUSTOMER PII

SOURCE CODE EMAIL/CHAT

Page 13: Using Vault to decouple MySQL Secrets

SECRET MANAGEMENT 1.0

Page 14: Using Vault to decouple MySQL Secrets

HOW DO I DISTRIBUTE SECRETS?

How do applica3ons get secrets?

How do humans acquire secrets?

How are secrets updated?

How is a secret revoked?

Page 15: Using Vault to decouple MySQL Secrets

{ "mysql_user": "root", "mysql_pass": "s3(Ret"}

secure � master cat config.son

Page 16: Using Vault to decouple MySQL Secrets

WHY NOT CONFIG MANAGEMENT?

Centrally stored

Eventually consistent

No access control

No audi3ng

No revoca3on

Page 17: Using Vault to decouple MySQL Secrets

WHY NOT (ONLINE) DATABASES?

RDBMS, Consul, ZooKeeper, etc

Not designed for secrets

Limited access controls

Typically plaintext storage

No audi3ng or revoca3on abili3es

Page 18: Using Vault to decouple MySQL Secrets

HOW TO HANDLE SECRET SPRAWL?

Secret material is distributed

Who has access?

When were secrets used?

What is the aMack surface?

What do we do in the event of a compromise?

Page 19: Using Vault to decouple MySQL Secrets

STATE OF THE WORLD 1.0

Secret sprawl

Decentralized keys

Limited visibility

Poorly defined “break glass” procedures

Page 20: Using Vault to decouple MySQL Secrets

SECRET MANAGEMENT 2.0

Page 21: Using Vault to decouple MySQL Secrets

VaultMODERN SECRETS MANAGEMENT

Page 22: Using Vault to decouple MySQL Secrets

VAULT GOALS

Single source for secrets

Programma3c applica3on access (Automated)

Operator access (Manual)

Prac3cal security

Modern data center friendly

Page 23: Using Vault to decouple MySQL Secrets

VAULT FEATURES

Secure secret storage (in-memory, Consul, file, postgres, and more)

Audi3ng

Rich ACLs

Mul3ple client authen3ca3on methods

Leasing, renewal, and revoca3on

Dynamic secrets

Page 24: Using Vault to decouple MySQL Secrets

SECURE SECRET STORAGE

Data is encrypted in transit and at rest

256bit AES in GCM mode

TLS 1.2 for clients

No HSM required

Page 25: Using Vault to decouple MySQL Secrets

AUDITING

Pluggable Audit Backends

Request and Response Logging

Priori3zes Safety over Availability

Secrets Hashed in Audits

Searchable, but not reversible

Page 26: Using Vault to decouple MySQL Secrets

RICH ACLS

Role Based Policies

Restrict access to “need to know”

Default Deny, must be explicitly allowed

Page 27: Using Vault to decouple MySQL Secrets

FLEXIBLE AUTH

Pluggable Backends

Tokens, GitHub, AppID, User/Pass, TLS Certs

Machine-Oriented vs Operator-Oriented

Page 28: Using Vault to decouple MySQL Secrets

LEASING, RENEWAL, AND REVOCATION

Every Secret has a Lease*

Secrets are revoked at the end of the lease unless renewed

Secrets may be revoked early by operators

“Break Glass” procedure

Dynamic Secrets make leases enforceable

Not possible for arbitrary secrets

Page 29: Using Vault to decouple MySQL Secrets

DYNAMIC SECRETS

Never provide “root” creden3als to clients

Provide limited access creden3als based on role

Generated on demand when requested

Leases are enforceable via revoca3on

Audit trail can iden3fy point of compromise

Page 30: Using Vault to decouple MySQL Secrets

DYNAMIC SECRETS

Pluggable Backends

AWS, Cassandra, Consul, MySQL, PostgreSQL, MSSQL, …

Grow support over 3me

Page 31: Using Vault to decouple MySQL Secrets

INTEGRATING MYSQL

Page 32: Using Vault to decouple MySQL Secrets

© 2016 Pythian

MySQL user management

32

● Clunky to manage many users ● Difficult to manage passwords ● Password expiration only recently ● Password validation only recently

Page 33: Using Vault to decouple MySQL Secrets

© 2016 Pythian

MySQL user management

33

● Hardcoded in applications ● Plaintext secrets ● Difficult to rotate

Page 34: Using Vault to decouple MySQL Secrets

© 2016 Pythian

How does Vault help?

34

● Creates users with high entropy secrets ● Secrets have aggressive expiration ● Secrets can easily be revoked

Page 35: Using Vault to decouple MySQL Secrets

© 2016 Pythian35

$ vault write mysql/roles/readonly \ sql="CREATE USER '{{name}}'@'%' IDENTIFIED BY '{{password}}';GRANT SELECT ON *.* TO '{{name}}'@'%';"

Create user pattern

Page 36: Using Vault to decouple MySQL Secrets

© 2016 Pythian36

$ vault read mysql/creds/readonly Key Value lease_id mysql/creds/readonly/b9b1fbb4-5ef8-1977-1fd2-ed21912e6288 lease_duration 600 lease_renewable true password 04f9d427-5ea4-8ce4-8e92-30c5cdcb5f7eusername root-6dd78551-dd

Read from Vault

Page 37: Using Vault to decouple MySQL Secrets

© 2016 Pythian37

$ vault read mysql/creds/readonly Key Value lease_id mysql/creds/readonly/b9b1fbb4-5ef8-1977-1fd2-ed21912e6288 lease_duration 600lease_renewable true password 04f9d427-5ea4-8ce4-8e92-30c5cdcb5f7e username github-6dd78551-dd

Read from Vault

Page 38: Using Vault to decouple MySQL Secrets

© 2016 Pythian38

$ mysql -ugithub-6dd78551-dd -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.7.11 MySQL Community Server (GPL)

mysql> SELECT USER(); +——————————————+ | User() | +——————————————+ | github-6dd78551-dd@localhost | +——————————————+ 1 row in set (0.00 sec)

mysql> SHOW GRANTS; +———————————————————————+ | Grants for github-6dd78551-dd@% | +———————————————————————+ | GRANT SELECT ON *.* TO 'github-6dd78551-dd'@'%' | +———————————————————————+ 1 row in set (0.00 sec)

Page 39: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Doesn’t MySQL do this natively?

39

● Proxy users (5.5+) ● Secrets have expiration (in 5.6+) ● Strong password policies can be implemented (5.6+)

Page 40: Using Vault to decouple MySQL Secrets

© 2016 Pythian

But…

40

● Must manually add/remove users ● Must manually update passwords ● MySQL-specific authentication plugins

Page 41: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Why Vault?

41

● Centralized secret management with rest of organization ● Users easier to manage ● Vault generates high-entropy secrets by default ● Limit attack surface if secrets compromised ● “Breakglass” policies to revoke secrets

Page 42: Using Vault to decouple MySQL Secrets

© 2016 Pythian42

$ vault revoke mysql/creds/readonly/6f1a7e70-cdd7-6954-eb57-b46da0c88ad5docker Key revoked with ID ‘mysql/creds/readonly//6f1a7e70-cdd7-6954-eb57-b46da0c88ad5'.

$ mysql -uroot -p -e "SELECT user, host FROM mysql.user" Enter password: +—————————+——+ | user | host | +—————————+——+ | root | % | +—————————+——+

Remove single secret

Page 43: Using Vault to decouple MySQL Secrets

© 2016 Pythian43

$ mysql -uroot -p -e "SELECT user, host FROM mysql.user" +————————+——+ | user | host | +————————+——+ | root | % | | root-6a1e1fbb-37 | % | | root-7dc68b1f-dd | % | | root-fcb6e200-87 | % | +————————+——+

$ vault revoke --prefix mysql Key revoked with ID 'mysql'.

$ mysql -uroot -p -e "SELECT user, host FROM mysql.user“ +———+———+ | user | host | +———+———+ | root | % | +———+———+

Remove all MySQL secrets

Page 44: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Vault for Direct Access

44

● Great for third-party access: consultants, auditors, etc ● Only create a single user to grant appropriate access ● Or create user per vendor or role ● Aggressive secrets expiration limits risk of password

exposure ● Authentication plugins

Page 45: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Vault Authentication

45

● Github ● LDAP

Page 46: Using Vault to decouple MySQL Secrets

© 2016 Pythian46

$ vault policies github path "mysql/*" { policy = "write" }

$ vault auth -method=github token=$GITHUB_TOKEN Successfully authenticated! token: 920b84f1-4ca9-33aa-4946-f046ef0b3f53 token_duration: 2591999 token_policies: [default, github]

$ vault read mysql/creds/readonly Key Value lease_id mysql/creds/readonly/6b4c559e-5008-f813-92af-19eaa41cbac4 lease_duration 600 lease_renewable true password 8bb914dc-9619-3c87-ba4e-18f1ec602e98 username github-dte-7a311

Page 47: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Vault for MySQL Applications

47

● Dynamic config via consul-template ● Secrets not stored in plaintext ● consul-template automatically renews

Page 48: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Vault Auditing

48

● Log access ● Supports writing syslog and file ● Hashes access so secrets are not stored in plaintext

Page 49: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Audit log

49

{"time":"2016-04-07T19:20:46Z","type":"request","auth":{"display_name":"root","policies":["root"],"metadata":null},"request":{"operation":"read","client_token":"hmac-sha256:ab960b87941cb0ad31477bec09b31671457c1967b15a89bf8574bae528c11ffa","path":"mysql/creds/readonly","data":null,"remote_address":"127.0.0.1"},"error":""}

Page 50: Using Vault to decouple MySQL Secrets

© 2016 Pythian

Considerations

50

● Current implementation requires multiple mysql mount per unique environment.

● Auditing only access requests to Vault, not whether used on DB or what was done.

Page 51: Using Vault to decouple MySQL Secrets

OPERATING VAULT

Page 52: Using Vault to decouple MySQL Secrets

HIGH AVAILABILITY

Consul used for leader elec3on

Ac3ve/Standby

Automa3c failover

Page 53: Using Vault to decouple MySQL Secrets

UNSEALING THE VAULT

Data in Vault encrypted

Vault requires encryp3on key

Must be provided online

Page 54: Using Vault to decouple MySQL Secrets

WATCHING THE WATCHMEN

Master Key is the “key to the kingdom”

All data could be decrypted

Protect against insider aMack

Two-Man Rule

Page 55: Using Vault to decouple MySQL Secrets

SHAMIR SECRET SHARING

Protect Encrypt Key with Master Key

Split Master Key into N shares

T shares to recompute Master

Quorum of key holders required to unseal

Default N:5, T:3

Page 56: Using Vault to decouple MySQL Secrets

SUMMARY

Solves the “Secret Sprawl Problem”

Protects against external threats (Cryptosystem)

Protects against internal threats (ACLs and Secret Sharing)

Page 57: Using Vault to decouple MySQL Secrets

DEMONSTRATION

Page 58: Using Vault to decouple MySQL Secrets

© 2016 Pythian58

● Setup vault, unseal (Docker containers), setup file audit ● Create github auth config ● Authenticate ● Create mysql user ● Request secret ● Use secret ● Revoke secret ● Verify Audit log

Demo Github Authentication

Page 59: Using Vault to decouple MySQL Secrets

BUILDING ON VAULT

Page 60: Using Vault to decouple MySQL Secrets

SECURITY FOUNDATION

Base of Trust

Core Infrastructure

Flexible Architecture

Founda3on for Security Infrastructure

Page 61: Using Vault to decouple MySQL Secrets

PERSONALLY IDENTIFIABLE INFORMATION

PII informa3on is everywhere

SSN, CC#, OAuth Tokens, etc.

Email? Physical address?

Security of storage?

Scalability of storage?

Audibility of access?

Page 62: Using Vault to decouple MySQL Secrets

PII WITH VAULT

“transit” backend in Vault

Encrypt/Decrypt data in transit

Avoid secret management in client applica3ons

Builds on Vault founda3on

Page 63: Using Vault to decouple MySQL Secrets

TRANSIT BACKEND

Web server has no encryp3on keys

Requires two-factor compromise (Vault + Database)

Decouples storage from encryp3on and access control

Page 64: Using Vault to decouple MySQL Secrets

EXTENSIBLE

PKI backend for Cer3ficate Authority + Signing

Mutual TLS for Applica3ons

SSH backend for SSH key management

“vault ssh” CLI command, dynamic keys or one-3me-passwords

Page 65: Using Vault to decouple MySQL Secrets

VAULT IN PRACTICE

Page 66: Using Vault to decouple MySQL Secrets

USING VAULT

API Driven

JSON/HTTPS

Rich CLI for humans and scripts

Rich client libraries

Page 67: Using Vault to decouple MySQL Secrets

APPLICATION INTEGRATION

Vault-aware

Na3ve client libraries (go, ruby, rails, python, node, and more)

Secrets only in-memory

Safest but high-touch

Page 68: Using Vault to decouple MySQL Secrets

CONSUL TEMPLATE INTEGRATION

Secrets templa3zed into applica3on configura3on

Vault is transparent

Lease management is automa3c

Non-secret configura3on s3ll via Consul

Page 69: Using Vault to decouple MySQL Secrets

{{ with $secret := vault "mysql/creds/production" }}---production: adapter: mysql database: mysql.service.consul username: {{$secret.Data.username}} password: {{$secret.Data.password}} pool: {{key "production/mysql/pool"}}{{ end }}

secure � master cat secrets.yml.ctmpl

Page 70: Using Vault to decouple MySQL Secrets

hashicorp/vault

hOps://vaultproject.io

[email protected]

QUESTIONS?THANK YOU!

hashicorp/vault

hOps://vaultproject.io

[email protected]

QUESTIONS?THANK YOU!

hOps://pythian.comhOps://pythian.com