Upgrade to Pro — share decks privately, control downloads, hide ads and more …

MongoDB Client-Side Field Level Encryption

Kenn White
November 21, 2019

MongoDB Client-Side Field Level Encryption

2019 MongoDB.local Toronto

Kenn White

November 21, 2019
Tweet

More Decks by Kenn White

Other Decks in Technology

Transcript

  1. #MDBlocal
    Kenneth White
    Security Principal
    TORONTO
    New encryption capabilities in MongoDB 4.2:
    A deep dive into protecting sensitive
    workloads

    View full-size slide

  2. New encryption capabilities in MongoDB 4.2:
    A deep dive into protecting sensitive workloads

    View full-size slide

  3. New encryption capabilities in MongoDB 4.2:
    A deep dive into protecting sensitive workloads
    Agenda

    View full-size slide

  4. New encryption capabilities in MongoDB 4.2:
    A deep dive into protecting sensitive workloads
    Agenda
    • A brief history of database security
    • Trust models: server vs. client
    • Encrypting data-in-use
    • Hands on deep dive
    • Q&A

    View full-size slide

  5. A brief history of database security

    View full-size slide

  6. A brief history of database security
    Evolution

    View full-size slide

  7. A brief history of database security
    Evolution
    • access controls

    View full-size slide

  8. A brief history of database security
    Evolution
    • access controls
    • passwords
    • plaintext > hashing > key derivation
    • bearer tokens
    • NTLM, Kerberos tickets, LDAP/S, SCRAM, web session
    • multi-factor auth
    • LCD fobs / SMS / 2FA apps / FIDO-U2F / WebAuthn / mobile enclaves
    • federated RBAC

    View full-size slide

  9. A brief history of database security
    Evolution
    • network

    View full-size slide

  10. A brief history of database security
    Evolution
    • network
    • (plaintext) native wire protocols
    • SSL encryption
    • TLS
    • TLS w/ PFS

    View full-size slide

  11. A brief history of database security
    Evolution
    • storage

    View full-size slide

  12. A brief history of database security
    Evolution
    • storage
    • plaintext / raw filesystem
    • encrypted

    View full-size slide

  13. A brief history of database security
    Evolution
    • storage
    • volume-level / full disk encryption (FDE)
    • BitLocker, DMCrypt, FileVault, encrypted EBS
    • file-level encryption
    • whole database
    • per-database (WiredTiger ESE)
    • tablespace
    • database-level encryption
    • column / field

    View full-size slide

  14. A brief history of database security
    These are all important defenses, but…

    View full-size slide

  15. A brief history of database security
    What is the threat?

    View full-size slide

  16. A brief history of database security
    Against whom/what are we defending?

    View full-size slide

  17. A brief history of database security
    Against whom/what are we defending?
    • “hackers”?

    View full-size slide

  18. A brief history of database security
    Against whom/what are we defending?
    • “hackers”?
    • criminal blackhats?
    • competitors?
    • activists?
    • unknown actors?

    View full-size slide

  19. A brief history of database security
    Against whom/what are we defending?
    • “hackers”?
    • criminal blackhats?
    • competitors?
    • activists?
    • unknown actors?
    • insiders?

    View full-size slide

  20. A brief history of database security
    Against whom/what are we defending?
    • “hackers”?
    • criminal blackhats?
    • competitors?
    • activists?
    • unknown actors?
    • insiders?
    • admins?

    View full-size slide

  21. A brief history of database security
    Against whom/what are we defending?

    View full-size slide

  22. A brief history of database security
    What is the threat?

    View full-size slide

  23. A brief history of database security
    What is the threat?

    View full-size slide

  24. A brief history of database security
    What is the threat?

    View full-size slide

  25. The security model for many Prod databases

    View full-size slide

  26. The security model for many Prod databases
    Source: Imgur (author unknown)

    View full-size slide

  27. A brief history of database security

    View full-size slide

  28. A brief history of database security
    Let’s talk about breaches.

    View full-size slide

  29. A brief history of database security
    Every sector of the global economy has been impacted.

    View full-size slide

  30. A brief history of database security
    Every sector of the global economy has been impacted
    • enterprise
    • consumer tech
    • retail
    • government
    • healthcare
    • finance

    View full-size slide

  31. A brief history of database security
    Major shifts in regulatory & privacy climate

    View full-size slide

  32. A brief history of database security
    Major shifts in regulatory & privacy climate
    • GDPR
    • HIPAA
    • PCI DSS
    • NIST/FISMA
    • Consumer protection
    • State & provincial

    View full-size slide

  33. A brief history of database security
    System architect & developer security challenges

    View full-size slide

  34. A brief history of database security
    System architect & developer security challenges
    Meeting legal/regulatory obligations
    • Controls
    • Audit/attestation

    View full-size slide

  35. A brief history of database security
    System architect & developer security challenges
    Meeting legal/regulatory obligations
    • Controls
    • Audit/attestation
    Defending real-world attacks
    • First Principles: C/I/A
    • Separation of duties
    • Access control
    • Identifying & protecting sensitive data

    View full-size slide

  36. A brief history of database security
    System architects & develop security challenges
    Meeting legal/regulatory obligations
    • Controls
    • Audit/attestation
    Defending real-world attacks
    • First Principles: C/I/A
    • Separation of duties
    • Access control
    • Identifying & protecting sensitive data

    View full-size slide

  37. Trust models: server vs. client

    View full-size slide

  38. Trust models: server vs. client
    What is the source of trust?

    View full-size slide

  39. Trust models: server vs. client
    What is the source of trust?
    • Traditionally, DB encryption has relied on server-side trust

    View full-size slide

  40. Trust models: server vs. client
    What is the source of trust?
    • Traditionally, DB encryption has relied on server-side trust
    • This has implications, many not so obvious

    View full-size slide

  41. Trust models: server vs. client
    What is the source of trust?
    • Traditionally, DB encryption has relied on server-side trust
    • This has implications, many not so obvious
    • With a few caveats, the database operator typically has unrestricted
    technical access, including:
    • DBAs
    • system admins
    • hosting/infrastructure providers

    View full-size slide

  42. Trust models: server vs. client
    What is the source of trust?
    • In a server-side encryption model, a leak or breach can be
    catastrophic

    View full-size slide

  43. Trust models: server vs. client
    What is the source of trust?
    • In a server-side encryption model, a leak or breach can be
    catastrophic
    • This potentially includes: logs, backups, temp files, process
    memory…

    View full-size slide

  44. Trust models: server vs. client
    What is the source of trust?
    • In a server-side encryption model, a leak or breach can be
    catastrophic
    • This potentially includes: logs, backups, temp files, process
    memory…
    • They who hold the keys controls the kingdom

    View full-size slide

  45. Trust models: server vs. client
    This is particularly important in a cloud context, especially so when
    running highly sensitive workloads.

    View full-size slide

  46. Trust models: server vs. client
    A common pain for system architects

    View full-size slide

  47. Trust models: server vs. client
    A common pain for system architects
    • Most notably in healthcare, finance, and consumer tech
    • The benefits of managed, easily expanded compute & cloud storage
    have often been considered out of reach because of data
    confidentiality & privacy concerns.

    View full-size slide

  48. Trust models: server vs. client
    The fundamental challenge is protecting the confidentiality of data while
    it’s in use.

    View full-size slide

  49. Encrypting Data-in-Use

    View full-size slide

  50. Encrypting Data-in-Use
    Introducing MongoDB Client-Side Field Level Encryption

    View full-size slide

  51. Encrypting Data-in-Use
    Introducing MongoDB Client-Side Field Level Encryption
    • encryption as a first-class citizen
    • modern, authenticated encryption algorithms
    • strong security guarantees
    • customer-managed keys
    • sensitive content is opaque to server & server operator

    View full-size slide

  52. Encrypting Data-in-Use
    Introducing MongoDB Client-Side Field-Level Encryption
    • major investment
    • 2 years in the making
    • 18+ engineers spanning core server, query, security, cloud, drivers
    • targeting 12+ languages
    • all major hardware & operating system platforms
    • Linux, MacOS, Windows

    View full-size slide

  53. MongoDB Client-Side Field-Level Encryption

    View full-size slide

  54. MongoDB Client-Side Field-Level Encryption
    Core design

    View full-size slide

  55. MongoDB Client-Side Field-Level Encryption
    Core design
    • CSFLE is enabled in drivers & integrated into shell
    • All encryption/decryption is done in the driver, on the client
    • Drivers have expanded MQL awareness for automatic encryption
    • Individual fields within collections can be marked as encrypted
    • Keys can be used on a per-field or even per-document basis

    View full-size slide

  56. MongoDB Client-Side Field-Level Encryption
    Implementation

    View full-size slide

  57. MongoDB Client-Side Field-Level Encryption
    Implementation
    • Extends existing JSON Schema with new “encrypt” property
    • Schema validation extended client-side
    • Key management services natively integrated into drivers
    • KMS envelope encryption used to protect field data keys
    • Server only sees encrypted binary data (BinData subtype-6)

    View full-size slide

  58. MongoDB Client-Side Field-Level Encryption
    Cryptography

    View full-size slide

  59. MongoDB Client-Side Field-Level Encryption
    Cryptography
    • Multiple encryption options, including deterministic search
    • Cloud key services are natively integrated
    • Modern authenticated encryption: AEAD AES-256 & HMAC-SHA512
    • 2015 IETF draft: McGrew, Foley, Paterson
    • Abuse- & misuse-resistant derived HMACs w/ deterministic IVs
    • Native OS libraries used for crypto primitives

    View full-size slide

  60. MongoDB Client-Side Field-Level Encryption
    Cryptography
    • Raw key material never persisted to disk (in-memory only)
    • Stored field keys protected by strong symmetric encryption
    • Field wrapping keys secured in HSM-backed external KMS
    • Key service master key rotation: scheduled or on-demand
    • Core constructions are Post-Quantum secure
    • Engaged with expert cryptography teams on design & security
    properties, and conducted independent security assessments

    View full-size slide

  61. MongoDB Client-Side Field-Level Encryption
    How does it work?

    View full-size slide

  62. View from application

    View full-size slide

  63. View from application
    {
    firstName: "Pat",
    lastName: "Lee",
    ssn: "901-01-0001",
    email: "[email protected]",
    mobile: "+1-212-555-1234",
    medRecNum: 235498
    }

    View full-size slide

  64. View from application
    View from database (admin, server, DB logs, process memory)
    {
    firstName: "Pat",
    lastName: "Lee",
    ssn: "901-01-0001",
    email: "[email protected]",
    mobile: "+1-212-555-1234",
    medRecNum: 235498
    }

    View full-size slide

  65. {
    firstName: "Pat",
    lastName: "Lee",
    ssn: "901-01-0001",
    email: "[email protected]",
    mobile: "+1-212-555-1234",
    medRecNum: 235498
    }
    {
    firstName: "Pat",
    lastName: "Lee",
    ssn: "r6EaUcgZ4lGw…",
    email: "K4b5U3TlcIXh…",
    mobile: "oR72CW4Wf5Ej…",
    medRecNum: 235498
    }
    View from application
    View from database (admin, server, DB logs, process memory)

    View full-size slide

  66. Client-Side Field Level Encryption Step by Step

    View full-size slide

  67. Client-Side Field Level Encryption Step by Step
     Step 1: Identify fields to encrypt

    View full-size slide

  68. Identify fields to encrypt
    {
    "medRecNum" : 235498,
    "firstName" : "Pat",
    "lastName" : "Lee",
    "ssn" : "901-01-0001",
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    }

    View full-size slide

  69. Client-Side Field Level Encryption Step by Step
     Step 1: Identify fields to encrypt
     Step 2: Set JSON data types & key(s) for encrypted
    fields

    View full-size slide

  70. "test.patients" : {
    "bsonType" : "object",
    "properties" : {
    "ssn" : {
    "encrypt" : {
    "bsonType" : "string",
    "keyId" : [ myKey ],
    "algorithm" : encryption_mode,
    }
    }
    }
    }

    View full-size slide

  71. Client-Side Field Level Encryption Step by Step
     Step 1: Identify fields to encrypt
     Step 2: Set JSON data types & key(s) for encrypted
    fields
     Step 3: Create a new Mongo session with encryption
    options

    View full-size slide

  72. var keystore = db.getCollection("__keystore")
    var clientSideFLEOptions = {
    "kmsProviders" : {
    "aws" : {
    "accessKeyId" : env.KMSKID ,
    "secretAccessKey" : env.KMSKEY
    }
    },
    "schemas" : { patientSchema } ,
    "keyVaultCollection" : keystore
    }
    encryptedSession = new Mongo( "localhost", clientSideFLEOptions )

    View full-size slide

  73. Client-Side Field Level Encryption Step by Step
     Step 1: Identify fields to encrypt
     Step 2: Set JSON data types & key(s) for encrypted
    fields
     Step 3: Create a new Mongo session with encryption
    options
     Step 4: Run your queries.

    View full-size slide

  74. db.patients.insert({
    "medRecNum" : 235498,
    "firstName" : "Pat",
    "lastName" : "Lee",
    "ssn" : "901-01-0001",
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    });
    ...
    db.patients.find({ "ssn": "901-01-1234" });

    View full-size slide

  75. Client-Side Field Level Encryption Step by Step
     Step 1: Identify fields to encrypt
     Step 2: Set JSON data types & key(s) for encrypted
    fields
     Step 3: Create a new mongo session with encryption
    options
     Step 4: Run your queries.
    (That’s it)

    View full-size slide

  76. Let’s go deeper

    View full-size slide

  77. Example: Direct query on an encrypted field
    encryptedDb.patients.find({"ssn": "901-01-0001" })

    View full-size slide

  78. Example: Direct query on an encrypted field
    encryptedDb.patients.find({"ssn": "901-01-0001" })

    View full-size slide

  79. Example: Direct query on an encrypted field
    encryptedDb.patients.find({"ssn": "901-01-0001" })
    encryptedDb.patients.find({ "ssn": BinData(6,"ASV2YBzOhUY…" )})

    View full-size slide

  80. Auto-decryption for clients holding a valid key:
    {
    "medRecNum" : 235498,
    "firstName" : "Pat",
    "lastName" : "Lee",
    "ssn" : "901-01-0001",
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    }

    View full-size slide

  81. View to a DBA:
    {
    "medRecNum" : 235498,
    "firstName" : "Pat",
    "lastName" : "Lee",
    "ssn" : BinData(6,"ASV2YBzOhUZZu643i7Y..."),
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    }

    View full-size slide

  82. View to a client lacking a valid key:
    {
    "medRecNum" : 235498,
    "firstName" : "Pat",
    "lastName" : "Lee",
    "ssn" : BinData(6,"ASV2YBzOhUZZu643i7Y..."),
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    }

    View full-size slide

  83. View to database, server memory, logs, backups:
    {
    "medRecNum" : 235498,
    "firstName" : "Pat",
    "lastName" : "Lee",
    "ssn" : BinData(6,"ASV2YBzOhUZZu643i7Y..."),
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    }

    View full-size slide

  84. {
    "firstName" : "Pat",
    "lastName" : "Lee",
    "medRecNum" : 235498,
    "ssn" : BinData(6,"ASV2YBzOhUZZu643i7Y..."),
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    }
    View to legacy clients:
    {
    "medRecNum" : 235498,
    "firstName" : "Pat",
    "lastName" : "Lee",
    "ssn" : BinData(6,"ASV2YBzOhUZZu643i7Y..."),
    "mobile" : "212-555-1234",
    "email" : "[email protected]"
    }

    View full-size slide

  85. Subdocuments & embedded fields supported

    View full-size slide

  86. Subdocuments & embedded fields supported
    {
    "_id": 923452345,
    "name": "John Doe",
    "ssn": "555-55-5555,
    "addresses": {
    "home": {
    "street": "123 secret way",
    "state": "NV",
    "zip": "89429"
    } }
    }

    View full-size slide

  87. Subdocuments & embedded fields supported
    {
    "_id": 923452345,
    "name": "John Doe",
    "ssn": "9+4/J%|]yr4t^(M",
    "addresses":
    "cEfgjCW,WqK+vB4V&fX1{G4XI*oi?OmQA7kT9>,}1vo
    SG!5\cJkl0?6ckTmL*9TmZ^[x`2gRkCYpP)~Ol5dpBz"
    }

    View full-size slide

  88. Subdocuments & embedded fields supported
    {
    "_id": 923452345,
    "name": "John Doe",
    "ssn": "9+4/J%|]yr4t^(M",
    "addresses": {
    "home": {
    "street": "8u^,%k78`[l9*AqMM",
    "state": "NV",
    "zip": "89429"
    } }
    }

    View full-size slide

  89. Sorts, range, and reference queries schema design
    {
    "firstName": ")2~Y8cJQuM",
    "lastName": "u?n"DOB": 1978,
    "location": {
    "city": "u^fj,%k78*)qV",
    "state": "NV",
    },
    "ssn": "9+4/J%|]yr4t^(M",
    "payerID": 62501,
    "medicalCode": "89K",
    "accountBalance": 4000.34
    }

    View full-size slide

  90. MongoDB Client-Side Field-Level Encryption
    Recap

    View full-size slide

  91. MongoDB Client-Side Field-Level Encryption
    Recap
    • Run anywhere: Atlas, self-managed cloud, GovCloud, local
    • Targeting all supported drivers on all supported platforms
    • Encrypt at the collection-, field-, or document-level
    • Search on encrypted fields
    • Subdocuments, objects and aggregation pipeline support
    • Multiple enforcement options (client-side, server-side, or both)
    • Backwards compatible with existing admin & cluster tools

    View full-size slide

  92. MongoDB Client-Side Field-Level Encryption
    Roadmap

    View full-size slide

  93. MongoDB Client-Side Field-Level Encryption
    Roadmap
    • Beta preview now – Java, Node.js, C# .Net, Python, Go
    • Server support on Atlas 4.2 clusters now
    • Shell update in flight
    • Additional language beta previews in coming weeks
    • 3rd party cryptography reviews & security assessments complete

    View full-size slide

  94. #MDBlocal
    Kenneth White
    Security Principal
    TORONTO
    New encryption capabilities in MongoDB 4.2:
    A deep dive into protecting sensitive
    workloads

    View full-size slide