Secrets in the Cloud - Dominik...

41
Dominik Schadow bridging IT Secrets in the Cloud Java Forum Nord 2017

Transcript of Secrets in the Cloud - Dominik...

Page 1: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Dominik Schadow bridgingIT

Secrets in the Cloud

Java Forum Nord 2017

Page 2: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

spring: datasource: name: myDatabase username: myDatabaseUser password: mySuperSecretDatabasePasswordmanagement: context-path: /admin security: enabled: truelogging: level: warn

Page 3: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

DEV PROD

Page 4: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase
Page 5: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

ID USERNAME PASSWORD SECRET_ID SECRET_DATA

1001 ArthurkvgkIu7ZuPIdK9G7WUAduTvd9TinwRlvA6fouxmgxMZwUsPUdW6

42 Secret

1002 ZaphodwC28772M7AYVwLe2BOudFl8VBo59KS5H1MbY9iriZpQhP6KCd33

42 Secret

1003 SlartieHkuCs817pYySnk0aKlzDeZDCSiUSedCOABqcEsRVYzS1Uc8RzK

42 Secret

1004 Ford3kQkFnjyt008yrIjnjftZewS6j8yKIbywJYzvs3HOGqtfYcAVV0

42 Secret

Page 6: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Storetechnical

and personal secrets securely

in the cloud

Page 7: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Technical Credentials

Page 8: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Embedded Configuration

Page 9: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

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

Page 10: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase
Page 11: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

spring: datasource: name: myDatabase username: myDatabaseUser password: ENC(p12MjKuU5xk7Pn0OdxJf627ssa Nyov2U30MRKlVjQb97Cbkfi5+/uQ==)management: context-path: /admin security: enabled: truelogging: level: warn

Page 12: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

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 - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Encrypted!

Encryption password?

Page 14: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

External Configuration

Page 15: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

App

ConfigServer

Plain

Jasypt

Encrypted (sym, asym)

Vault

App

App

App

Page 16: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Config Server Cryptography

Symmetric EncryptionRequires encrypt.key property (config or env variable)

Asymmetric EncryptionRequires key in PEM file or Java KeyStore and encrypt.key-store.* properties

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

Page 17: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase
Page 18: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

spring: datasource: name: myDatabase username: myDatabaseUser password: '{cipher}AQAlocajMl+cUswb9rnJ/5q1Xfvu49zD2nnf8o4PZuVQdXKpXI2cpXvur8eCWvwfZkQCYpZH8LBGAYbRt2WH7CJW9H+JiHXP700L2fNm/6E4uq7qUIpPtXX4u2H7Mzap4aPzVo8tGIq/jWNUV8fT/+svJwnEIB3ID8I2FLkgZ1pEu9YNIIXWuOqnZuI8h6zQsflY1/zQVdTk848B9plCO5PoMXhxPlUyXi5W7iP+5ZDh8MgxJ+SRSeslqvsP1c8JjrlRkzGe84bP5zcaCtLkwAhv697Z1qeDDeAwEuUFlo7ZpiPdZmebB8MOcHp3iIfGDKD8RN7TKiXgDPoWm6ENlcI+cJ+8l4TT7vFf7+G0YogJA20AOaudAuxabCjok56Rno4Op88KKPob9dJOFpawSqmR'

Page 19: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase
Page 20: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase
Page 21: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Key Rotation

spring: datasource: name: myDatabase username: myDatabaseUser password: '{cipher}{key:myFirstKey}AQAloc...'

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

Page 22: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Demo

Page 23: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Encrypted!

Encryption password or encryption key?

Spring Cloud Config Server security?

Page 24: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

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

distributed infrastructure, applications, and humans.“

Page 25: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

All Data is Always Encrypted

Selected storage backend never sees plain text

File, Amazon DynamoDB, Consul, …

Unsealing requires n configured unseal keys

Internal key encrypts everything with AES

Key never leaves the system

Page 26: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Secret Storage

Store and create secrets

Lease time for new secrets, automatic revocation

Access control policies for secrets

Page 27: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Audit Logs

Detailed audit log of all authenticated client interaction

Sensitive data hashed

Disabled by default

Page 28: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Accessible via HTTP API or CLI

Page 29: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

vault server -config vault-local.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 30: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

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 31: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Authenticated Access Required

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

Token (default), LDAP, Username/Password, GitHub Token, AWS EC2, Certificates, …

Page 32: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

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

mount point

key/value format(generic backend)

Page 33: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Spring Cloud Vault

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

Page 34: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Demo

Page 35: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Encrypted!

Multiple unseal keys!

Vault server security?

Page 36: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Personal Credentials

Page 37: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

API for Secret Management

VaultTemplate to read, write and list secrets

vaultTemplate.read(PATH);

Similar to RestTemplate

Page 38: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Demo

Page 39: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Vault securely stores any data!

Multiple unseal keys!

Vault server security?

Page 40: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

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

Page 41: Secrets in the Cloud - Dominik Schadowfiles.dominikschadow.de/events/jfn-2017--secrets_in_the_cloud.pdf · Secrets in the Cloud Java Forum Nord 2017. spring: datasource: name: myDatabase

Demo Projecthttps://github.com/dschadow/CloudSecurity

Jasypthttp://www.jasypt.org

Jasypt integration for Spring boot https://github.com/ulisesbocchio/jasypt-spring-boot

Spring Cloud http://projects.spring.io/spring-cloud

Vaulthttps://www.vaultproject.io

Pictures http://www.dreamstime.com

Marienstr. 17 70178 Stuttgart

[email protected] www.bridging-it.de

Blog blog.dominikschadow.de Twitter @dschadow