Download - Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Transcript
Page 1: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Dominik Schadow bridgingIT

Secrets in the Cloud

JAX 2017

Page 2: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

spring: datasource: username: myDatabaseUser password: mySuperSecretDatabasePassword

Page 3: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

ID USERNAME PASSWORD SECRET_ID SECRET_DATA

1001 ArthurkvgkIu7ZuPIdK9G7WUAduTvd9TinwRlvA6fouxmgxMZwUsPUdW6

42 Secret

1002 ZaphodwC28772M7AYVwLe2BOudFl8VBo59KS5H1MbY9iriZpQhP6KCd33

42 Secret

1003 SlartieHkuCs817pYySnk0aKlzDeZDCSiUSedCOABqcEsRVYzS1Uc8RzK

42 Secret

1004 Ford3kQkFnjyt008yrIjnjftZewS6j8yKIbywJYzvs3HOGqtfYcAVV0

42 Secret

Page 4: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine
Page 5: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

DEV PROD

App

Page 6: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Storetechnical

and personal secrets securely

in the cloud

Page 7: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Technical Credentials

Page 8: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Embedded Configuration

Page 9: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

<dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>1.12</version></dependency>

Page 10: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine
Page 11: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

spring: datasource: username: myDatabaseUser password: ENC(vvnkG2pj//Jd1vXe7YtuLvyFCtKBA+CVOYAT9qwfB4yuv4jngb6r/g==)

Page 12: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

jasypt.encryptor.password

docker run -e jasypt.encryptor.password=sample-password -p 8080:8080-t dschadow/sample

System property Command line argument Environment variable

Page 13: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Better than before, but we are not there yet…

Page 14: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

External Configuration

Page 15: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

App

ConfigServer

Plain (git, svn)

Jasypt

Encrypted

Vault

Page 16: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Config Server Cryptography

Properties starting with {cipher} will be decrypted before returned to client

Page 17: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

# requires key# alternative: environment variable ENCRYPT_KEYencrypt: key: mySuperSecretKey

Symmetric Encryption

Page 18: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

# requires keystore or pem file encrypt: keyStore: location: classpath:/server.jks password: letmein alias: mytestkey secret: changeme

Asymmetric Encryption

Page 19: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Endpoints must be secured

Page 20: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

spring: datasource: name: config-client-db username: config-client-db-user password: '{cipher}AQAPseaUfV+p34giF9jspUa475vKWV3bLwJh9sL2Gco8xB0e4GG0z24LRIVXz5SKtESd+t9mFFkfPxJ/SgxPNOgAl+naZSay088buguJlpnYNHkNDafpoJmLGdeWq7ZTkdIeoCXpZWIioxz5e3GfWudsMjmcJ6smpq6J63OQkmHy6Z00av7kIKscNZksDDTikeKX02mnpGRelBZfMYqsMF96v7o7tuAT15tTR1v6SHrUpJ83hSy8GgtWRR6egZaTu8sYzJdkpjOmUMGXNI1flBvFdkWNt78BjzB5Lm4IiXINQFw6SObcTCsUv3nQbFOELVqg9ajVHrbKi3oaGwcbgpYR3VGgBzAgX/B/ToS/WBRLtRViSXTANE9iCvqArik4Ynfti6KKROBVk9MFe8qMEiV'

Page 21: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

decryption failure

Page 22: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine
Page 23: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Using Multiple Keys

spring: datasource: password: '{cipher}{key:myFirstKey}AQUfV+...'

Select existing key with {key:name} in properties file

Page 24: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Demo

Page 25: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

„… centrally store, secure, and tightly control access to secrets across

distributed infrastructure, applications, and humans.“

Page 26: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Internal key encrypts all data with AES

This key never leaves the system

Data is Always Encrypted

High availability

Configured storage backend never sees plain text

File, Amazon DynamoDB, Consul, …

Page 27: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Secret Storage

Store existing secrets

Dynamically create new secrets

Lease time for new secrets, automatic revocation

Access control policies for secrets

Page 28: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Audit Logs

Not active by default

Detailed audit log of all authenticated client interaction

Trace lifetime and origin of any secret

Hashes sensitive information with HMAC-SHA256

Page 29: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Accessible via HTTP API or CLI

Page 30: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Unsealing requires configured number of master keys

Page 31: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

vault server -config vault.conf

vault init -key-shares=5 -key-threshold=2

Unseal Key 1: Pv/Xx49co4Zmed2McapSOr4jC4iiAvfd5EjvILMySJUBUnseal Key 2: T00pjFgitbcy+JKOGI6DFgW/0jBdyrVriLdGu7PENbsCUnseal Key 3: YCOKtRUITlH3h155P5LM+2zLbFgIe4vwrOIhO7OWHqEDUnseal Key 4: rTLOGu3emdWa4QyKysY6Tmice1u4QTEcUFIPlrMzz+cEUnseal Key 5: glxtI6D0YjNfnsB97dp1owHoxTPt8A+HdAdoFrNh5P0FInitial Root Token: efe88b79-cf8b-825a-0f6f-ef1ca142782b

export VAULT_ADDR=http://127.0.0.1:8200

Shamir's Secret Sharing

Only visible after initialization

DEMO!

Page 32: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

vault unseal Pv/Xx49co4Zmed2McapSOr4jC4iiAvfd5EjvILMySJUBSealed: trueKey Shares: 5Key Threshold: 2Unseal Progress: 1Unseal Nonce: 87f350d5-2a25-a821-dc7f-2962fc49fe03

vault unseal rTLOGu3emdWa4QyKysY6Tmice1u4QTEcUFIPlrMzz+cESealed: falseKey Shares: 5Key Threshold: 2Unseal Progress: 0Unseal Nonce:

Page 33: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Authenticated Access Required

Token - AppId - AppRole - TLS Certificate - AWS - GitHub - …

static

spring.application.name +

user id (e.g. IP or MAC address)

machine authentication role id + secret id

cryptographically signed metadata of

EC2 instance

SSL/TLS client certificates

GitHub access token

Page 34: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Path Based Secret Storage

vault [ACTION] secret/spring-config

mount point application

Page 35: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Each ‚User‘ is Assigned a Policy

Policies use path based matching to apply rule

Policy may constrain actions and paths

Page 36: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

path "secret/*" { policy = "write"}

path "auth/token/lookup-self" { policy = "read"}

Page 37: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

CLIexport VAULT_TOKEN

=efe88b79-cf8b-825a-0f6f-ef1ca142782b

HTTP APIX-Vault-Token

Page 38: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

vault write secret/spring-config db.password=config-client-db-password

key/value format (generic backend)

Page 39: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Spring Cloud Vault

/secret/{application}/{profile}/secret/{application}/secret/{defaultContext}/{profile}/secret/{defaultContext}

Secrets are picked up during application startup

Path based on application name and active contexts

Page 40: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Reading and Writing Secrets

Page 41: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Actuator Health Endpoint

Page 42: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Demo

Page 43: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine
Page 44: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Personal Credentials

Page 45: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

API for Secret Management

VaultTemplate to read, write, list and delete secrets

vaultTemplate.read(PATH);

Similar to RestTemplate

Page 46: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Demo

Page 47: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine
Page 48: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

We have created another system to monitor and maintain…

Page 49: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

AWS Key Management Service (KMS)Master key to protect all keys

Service for storing encryption keys

Supporting cryptographic operations with these keys

Access control and auditing functionality

Page 50: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Key Encryption Key (a.k.a. master key)

Data Encryption

Key 1

Data Encryption

Key 2

Data Encryption

Key n

generate decrypt

AWS KMS

Storage(encrypted data encryption key)

Page 51: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Microsoft Azure Key Vault

IBM Bluemix Key Protect

Page 52: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine
Page 53: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

SummaryMultiple options to protect sensitive data exist

Keep it as simple as possible

Jasypt for simple applications

Config Server cipher for distributed applications

Vault when required

Consider cloud provider services

Page 54: Secrets in the Cloud - files.dominikschadow.defiles.dominikschadow.de/events/jax-2017--secrets_in_the_cloud.pdf · spring.application.name + user id (e.g. IP or MAC address) machine

Demo Projecthttps://github.com/dschadow/CloudSecurityAWS KMS https://aws.amazon.com/de/kmsJasypt integration for Spring boot https://github.com/ulisesbocchio/jasypt-spring-bootSpring Cloud http://projects.spring.io/spring-cloudVaulthttps://www.vaultproject.ioPictures http://www.dreamstime.com

Marienstr. 17 70178 Stuttgart

[email protected] www.bridging-it.de

Blog blog.dominikschadow.de Twitter @dschadow