KMS at Okta - Intermediate Level

50
Jon Todd - @JonToddDotCom Encryption Key Storage with AWS KMS at Okta December 2015

Transcript of KMS at Okta - Intermediate Level

Page 1: KMS at Okta - Intermediate Level

Jon Todd - @JonToddDotCom

Encryption Key Storagewith AWS KMS at OktaDecember 2015

Page 2: KMS at Okta - Intermediate Level

1 Background

• Okta• Encryption• Why use a key server?

2 KMS Evaluation 3 Implementation

Page 3: KMS at Okta - Intermediate Level

What is Okta?Okta is the foundation for secure

connections between people and technology.

Page 4: KMS at Okta - Intermediate Level

One platform, many use cases

Centralized management of every user, app, device

www.okta.com

IT

Enterprise-grade security built directly into your cloud apps

developer.okta.com

Developers

Page 5: KMS at Okta - Intermediate Level

More than 3000 customersEducation,Non-ProfitFinanceTechnologyCloudHealth Services

Manufacturing, Energy Media Consumer

Page 6: KMS at Okta - Intermediate Level

Used in 185 countries globally

Page 7: KMS at Okta - Intermediate Level

Our Stackstackshare.io/okta/okta

Page 8: KMS at Okta - Intermediate Level

Encryption

Page 9: KMS at Okta - Intermediate Level

Encryption use cases• Fundamental

• Confidentiality• Authenticity

• Practical• Compliance• Least privilege principle

Page 10: KMS at Okta - Intermediate Level

The problem with encryption

Managing these

Page 11: KMS at Okta - Intermediate Level

Alternative approaches to confidentiality• Use cases for hashing instead of encryption

• Authentication• Correlation

• Use cases without needing keys• Homomorphic applications

• Ordering, range query (for example, CryptDB)• Only require encrypt

• Use asymmetric crypto• Trust No One (client encryption scenarios)

• File storage or password vault

Page 12: KMS at Okta - Intermediate Level

Why use a key server?

Page 13: KMS at Okta - Intermediate Level

Example applicationRequirements:1. Data in database is

encrypted at rest and in memory

2. Encryption keys reside only in memory

3. Service has access to the plaintext data

Page 14: KMS at Okta - Intermediate Level

Where do we get the keys from?

• At server startup• Environment variable• File

• At run time• Over JMX + TLS• Over SSH

• Key service

Page 15: KMS at Okta - Intermediate Level

Key service

• Separation of duties• Auditable• Easy rotation of master key• Data key in memory for very short period• Centralized master key never leaves key service

Page 16: KMS at Okta - Intermediate Level

1 Background

• Requirements• How KMS works• KMS threat model

2 KMS Evaluation 3 Implementation

Page 17: KMS at Okta - Intermediate Level

Encryption use cases• Privacy of user data

• Protection of PII, PCI, PHI• Credential storage

• SAML keys• OAuth tokens• Third-party application credentials

Page 18: KMS at Okta - Intermediate Level

Requirements• Strong encryption

256 bit AES GCMStrong random-number generator

• Separation of dutiesBy designQuorum management of servers

• Support auto-scale through secure bootstrappingHypervisor bootstraps IAM keys

• AuditabilityEncryption context + CloudTrail

Page 19: KMS at Okta - Intermediate Level

How KMS works

Page 20: KMS at Okta - Intermediate Level

KMS Operations• randomKey = generateDataKey(keyId, encryptionCtx)• ciphertext = encrypt(plaintext, keyId, encryptionCtx)• plaintext = decrypt(ciphertext, keyId, encryptionCtx)

No plaintext!

Page 21: KMS at Okta - Intermediate Level

Threat model: KMS with EC2

Page 22: KMS at Okta - Intermediate Level
Page 23: KMS at Okta - Intermediate Level

Getting IAM credentials for KMS• Credentials granted via IAM Role• Hypervisor provides a per-instance metadata service• Security considerations

• Metadata service is accessible by all users• Credentials aren’t channel bound• Credentials are short lived

Page 24: KMS at Okta - Intermediate Level

IAM credentials via metadata servicecurl http://169.254.169.254/latest/meta-data/iam/security-credentials/MyApp

{ "Code" : "Success", "LastUpdated" : "2015-08-20T21:17:41Z", "Type" : "AWS-HMAC", "AccessKeyId" : “SOME_ACCESS_ID", "SecretAccessKey" : ”SOME_SECRET_ACCESS_KEY", "Token" : “SOME_SIGNED_TOKEN", "Expiration" : "2015-08-21T03:22:28Z"}

Page 25: KMS at Okta - Intermediate Level

IAM credential rotation• Credentials expire in ~ 6 hours• Credentials are rotated every ~ 1 hour

Page 26: KMS at Okta - Intermediate Level

Threat model: KMS transport

Page 27: KMS at Okta - Intermediate Level

Transport Security• TLS for confidentiality and authentication of server

• “A” rating on Qualys SSL Labs• Disallowed protocols SSL2 & SSL3• Supported protocols TLS 1.0, 1.1, 1.2• Forward secrecy required• Verisign root CA

• IAM Signature V4 for authN and authZ of client

Page 28: KMS at Okta - Intermediate Level

Threat model: KMS

Page 29: KMS at Okta - Intermediate Level

KMS key hierarchy

• CMK – Customer master key• HSA – Hardened security appliance• EKT – Exported key token• HBK – HSA backing key• CDK – Customer data key• CT – Customer token

Source: KMS Cryptographic Details

Page 30: KMS at Okta - Intermediate Level

Threat model – final comparison• AWS CloudHSM

• HSM at cost of managing High Availability (HA)

• Low performance• DIY

• Roll your own credential management and rotation

• Separate operational team• No access to hardware/TPM

Page 31: KMS at Okta - Intermediate Level

1 Background

• Goals• Failure mitigation• Authorization & auditing• Rollout & tuning

2 KMS Evaluation 3 Implementation

Page 32: KMS at Okta - Intermediate Level

Implementation goals• Multiregion support for disaster recovery (DR)• Mitigate total KMS failure• Avoid vendor lock-in• Minimal performance impact• Operational tools for key rotation

Page 33: KMS at Okta - Intermediate Level

Failure mitigation

Page 34: KMS at Okta - Intermediate Level

Multiregion encryption and decryption• Encrypt & store tenant key

encrypted by each region key• Decrypt talks to closest KMS

region• RSA public key used for encrypt

only • Private key provided to service

only in event of KMS outage

Page 35: KMS at Okta - Intermediate Level

September 20th KMS increased error rate

Page 36: KMS at Okta - Intermediate Level

Okta failed-over automaticallyKMS requests by region

https://trust.okta.com

Page 37: KMS at Okta - Intermediate Level

Authorization & auditing

Page 38: KMS at Okta - Intermediate Level

Encryption context• Features:

• Additional authenticated data (AAD) via AES GCM• Logging – Understand why the key was accessed• Authorization – Fine-grained access control to

data keys• Okta’s implementation

• Type: <ServiceName>.<EntityName>• Id: <EntityId>

• A good encryption context identifies or classifies• Think carefully about mutability and storage of context• Encryption context shouldn’t contain sensitive data

Page 39: KMS at Okta - Intermediate Level

Granular decryption policy{ "Effect":"Allow”, "Principal":{"AWS":"arn:...:DirectoryAppRole"}, "Action":"kms:Decrypt", "Condition":{ "StringEquals”:{ "kms:EncryptionContext:type": ”DirectoryService:SensitiveObject” } }}

Page 40: KMS at Okta - Intermediate Level

CloudTrail

Page 41: KMS at Okta - Intermediate Level

Rollout and tuning

Page 42: KMS at Okta - Intermediate Level

Rollout and TTL tuning

TuningGradual rollout

Page 43: KMS at Okta - Intermediate Level

Performance

Page 44: KMS at Okta - Intermediate Level

Region failovers• ~ 0.001% failure rate without tuning HttpClient retries• At retry value of 3, failure rate is negligible

Page 45: KMS at Okta - Intermediate Level

SDK client tuningkmsClientConfig = new ClientConfiguration() .withSocketTimeout(3000) // 3 seconds .withConnectionTimeout(3000) // 3 seconds .withConnectionTTL(60000) // 1 minute .withMaxErrorRetry(3);

client = new AWSKMSClient(kmsClientConfig);

Page 46: KMS at Okta - Intermediate Level

Final thoughts

Page 47: KMS at Okta - Intermediate Level

Implementation recommendations• You may not need encryption or keys

for confidentiality• Put thought into encryption context• Reconcile CloudTrail logs with

application logs• Tune the SDK for timeout and retries• Consider an extended key hierarchy

Page 49: KMS at Okta - Intermediate Level

Okta for developersUniversal Directory

Single Sign-On

Provisioning

Adaptive Multi-factor Authentication

Social Authentication

Inbound Federation

AD and LDAP Integration

Page 50: KMS at Okta - Intermediate Level

Thank You.

Find me on twitterwww.okta.com@JonToddDotCom

Learn more about Okta