base64 is not encryption
play

Base64 is not encryption A better story for Kubernetes secrets - PowerPoint PPT Presentation

Base64 is not encryption A better story for Kubernetes secrets @sethvargo Developer Relations Engineer What's a secret? Secret (noun) Credentials, configurations, API keys, or other pieces of information needed by an application at build


  1. Base64 is not encryption A better story for Kubernetes secrets

  2. @sethvargo Developer Relations Engineer

  3. What's a secret?

  4. Secret (noun) Credentials, configurations, API keys, or other pieces of information needed by an application at build time or run time

  5. Why protect secrets? • Attractive target for hackers • Often leaked in repos or storage buckets • Frequently includes overly broad permissions

  6. Protecting secrets Audit Encrypt Rotate Isolate Verify and log the use Always encrypt secrets Change a secret Separate where secrets of individual secrets to in transit with TLS and regularly or in case of are used from where a central system at rest suspected compromise secrets are managed

  7. Protecting secrets Audit Encrypt Rotate Isolate Verify and log the use Always encrypt secrets Change a secret Separate where secrets of individual secrets to in transit with TLS and regularly or in case of are used from where a central system at rest suspected compromise secrets are managed

  8. Layers of encryption Application-layer encryption Service-level encryption Filesystem encryption Machine-level encryption

  9. App-layer encryption • Applied at earliest possible step • Provides protection a very granular level • Protects data as it moves through the system

  10. Kubernetes defaults

  11. Insecure by default Secrets are stored in plaintext in etcd. They are base64-encoded, but not encrypted.

  12. Insecure by default * Secrets are stored in plaintext in etcd. They are base64-encoded, but not encrypted. * Many providers alter this default behavior.

  13. == kube-apiserver etcd Master

  14. == kube-apiserver etcd Master

  15. Encraption shodan.io/search?query=etcd

  16. Demo

  17. Envelope encryption

  18. Envelope encryption Data DEK KEK Data encryption key Key encryption key

  19. 01100101 01101110 01100101 01101110 01100101 01101110 01100101 01101110 01100011 01110010 01100011 01110010 01100011 01110010 01100011 01110010 01111001 01110000 01111001 01110000 01111001 01110000 01111001 01110000 01110100 01100101 01110100 01100101 01110100 01100101 01110100 01100101 01100100 00100000 01100100 00100000 01100100 00100000 01100100 00100000 01100100 01100001 01100100 01100101 01100100 01100001 01100100 01100101 01110100 01100001 01101011 00100000 01110100 01100001 01101011 00100000 Encrypted data Encrypted DEK Storage

  20. 01100101 01101110 01100101 01101110 01100011 01110010 01100011 01110010 01111001 01110000 01111001 01110000 01110100 01100101 01110100 01100101 01100100 00100000 01100100 00100000 01100100 01100001 01100100 01100101 01110100 01100001 01101011 00100000 Encrypted data Encrypted DEK

  21. Envelope encryption • Generate unique DEKs for each data entry • Crypto-shred - revoke KEK and data is gone • Easy versioning and rotation

  22. Kubernetes 1.7 Envelope encryption

  23. kind: EncryptionConfiguration apiVersion: apiserver.config.k8s.io/v1 resources: - resources: - secrets providers: - aescbc: keys: - name: key1 secret: 9RlIhvmh1e6+Ixv0CjyUkA== - name: key2 secret: u+aswHTypAyoRKH5/P0r5A== - secretbox: keys: - name: key1 secret: 9aHuiH/wrlmWEXZp9br4og==

  24. ./kube-apiserver \ --encryption-provider-config=/etc/encryption-config.yaml \ --other-options...

  25. 01100101 01101110 01100011 01110010 01111001 01110000 01110100 01100101 01100100 00100000 01100100 01100101 01101011 00100000 kube-apiserver etcd Master EncryptionConfiguration

  26. 01100101 01101110 01100011 01110010 01111001 01110000 01110100 01100101 01100100 00100000 01100100 01100101 01101011 00100000 kube-apiserver etcd Master EncryptionConfiguration

  27. 01100101 01101110 01100011 01110010 01111001 01110000 01110100 01100101 01100100 00100000 01100100 01100101 01101011 00100000 kube-apiserver etcd Master EncryptionConfiguration

  28. Drawbacks • Need to generate keys yourself • Key management is your responsibility • Rotation is a manual process (and tedious) • No HSM integration

  29. Drawbacks The underlying encryption keys are still stored in plaintext on the filesystem!

  30. Kubernetes 1.10 KMS encryption providers

  31. kind: EncryptionConfiguration apiVersion: apiserver.config.k8s.io/v1 resources: - resources: - secrets providers: - kms: name: myKmsPlugin endpoint: unix:///tmp/kms-socketfile.sock cachesize: 100

  32. 01100101 01101110 01100011 01110010 01111001 01110000 01110100 01100101 01100100 00100000 01100100 01100101 01101011 00100000 kube-apiserver etcd KMS Master EncryptionConfiguration

  33. 01100101 01101110 01100011 01110010 01111001 01110000 01110100 01100101 01100100 00100000 01100100 01100101 01101011 00100000 kube-apiserver etcd KMS Master EncryptionConfiguration

  34. 01100101 01101110 01100011 01110010 01111001 01110000 01110100 01100101 01100100 00100000 01100100 01100101 01101011 00100000 kube-apiserver etcd KMS Master EncryptionConfiguration

  35. Existing plugins (GitHub) • GoogleCloudPlatform/k8s-cloudkms-plugin • Azure/kubernetes-kms • kubernetes-sigs/aws-encryption-provider • oracle/kubernetes-vault-kms-plugin

  36. GKE Integration (beta) gcloud beta container clusters create my-cluster --database-encryption-key-location us-east1 --database-encryption-key-keyring my-keyring --database-encryption-key my-crypto-key

  37. Initial secret problem? • IAM can solve the "first secret" problem • Delegate PAM to the cloud provider via IAM • Separate concerns: etcd nodes don't need IAM permissions to talk to KMS

  38. Vault

  39. 01100101 01101110 01100011 01110010 01111001 01110000 01110100 01100101 01100100 00100000 01100100 01100101 01101011 00100000 kube-apiserver etcd KMS Master EncryptionConfiguration

  40. Demo

  41. Summary

  42. Summary • Use at least two layers of encryption • Rotate keys regularly • Leverage envelope encryption • Protect K8S secrets using an external KMS

  43. Thanks! @sethvargo Developer Relations Engineer

Recommend


More recommend