SlideShare a Scribd company logo
#MDBlocal
Matthew Aylard
Using Client Side Encryption in MongoDB 4.2
LONDON
#MDBLocal
Introducing…
#MDBLocal
#MDBLocal
db.coll.insert({
_id: 1,
name: "Doris",
ssn: "457-55-5462"
})
#MDBLocal
#MDBLocal
doc = db.coll.find_one({
ssn: "457-55-5462"
})
#MDBLocal
#MDBLocal
print (doc)
#MDBLocal
{
_id: 1
name: "Doris",
ssn: "457-55-5462"
}
#MDBLocal
#MDBLocal
#MDBLocal
db.coll.insert({
name: "Doris",
ssn: "457-55-5462"
})
{
insert: "coll",
documents: [{
name: "Doris",
ssn: BinData(6, "a10x…")
}]
}
You see: MongoDB sees:
Encrypt before sending
#MDBLocal
{
_id: 1
name: "Doris",
ssn: BinData(6, "a10x…")
}
Driver receives: You see:
{
_id: 1
name: "Doris",
ssn: "457-55-5462"
}
Decrypt after receiving
#MDBLocal
How does this differ from…?
•… encryption in-transit (TLS)
•… encryption at-rest (encrypted storage engine)
#MDBLocal
Attacker
Query
Client
Disk
insert write
MongoDB
Auth
db.coll.insert({ name: "Doris", ssn: "457-55-5462" })
#MDBLocal
Client
Disk
insert write
MongoDB
Attacker
Snoop
TLS
db.coll.insert({ name: "Doris", ssn: "457-55-5462" })
#MDBLocal
Client
Disk
insert write
MongoDB
Attacker
insert
TLS
db.coll.insert({ name: "Doris", ssn: "457-55-5462" })
#MDBLocal
Client
Disk
insert write
MongoDB
Attacker
Steal
ESE
db.coll.insert({ name: "Doris", ssn: "457-55-5462" })
#MDBLocal
Client
Disk
insert write
MongoDB
Attacker
Login
Client Side Encryption
db.coll.insert({ name: "Doris", ssn: "457-55-5462" })
#MDBLocal
Client
Disk
insert write
MongoDB
Boundaries of unencrypted data
#MDBLocal
Client
Disk
insert write
MongoDB
… with Encrypted Storage Engine
#MDBLocal
Client
Disk
insert write
MongoDB
… and TLS
#MDBLocal
Client
Disk
insert write
MongoDB
with Client Side Encryption
#MDBLocal
#MDBLocal
Client
Disk
insert write
MongoDB
ssn: BinData(6, "a10x…")
#MDBLocal
db.coll.update({}, {
$set: { ssn: "457-55-5462" }
})
{
update: "coll",
updates: [{
q:{},
u: {
$set: { ssn: BinData(6, "a10x…") }
}
}]
}
You see: MongoDB sees:
Update that overwrites value
#MDBLocal
db.coll.aggregate([{
$project: { name_ssn: {$concat: [ "$name", " - ", "$ssn" ] } }
}]
Aggregate acting on the data
#MDBLocal
Find with equality query
* For deterministic encryption
db.coll.find({ssn: "457-55-5462" }) {
find: "coll",
filter: { ssn: BinData(6, "a10x…") }
}
You see: MongoDB sees:
#MDBLocal
Find with equality query
* For deterministic encryption
db.test.find(
{
$and: [
{
$or: [
{ ssn : { $in : [ "457-55-5462", "153-96-2097" ]} },
{ ssn: { $exists: false } }
]
},
{ name: "Doris" }
]
}
)
You see:
#MDBLocal
Find with equality query
* For deterministic encryption
MongoDB sees:
{
find: "coll",
filter: {
$and: [
{
$or: [
{ ssn : { $in : [ BinData(6, "a10x…"), BinData(6, "8dk1…") ]} },
{ ssn: { $exists: false } }
]
},
{ name: "Doris" }
]
}
}
#MDBLocal
MongoDB
Attacker
Login
#MDBLocal
#MDBLocal
#MDBLocal
Doris
Private stuff in storage
#MDBLocal
PoliceDoris
Private stuff in storage
#MDBLocal
Vault key
Held only by you
Vault
#MDBLocal
#MDBLocal
Encrypted Data
MongoDB
Encryption Key
#MDBLocal
#MDBLocal
{ _id: 1, ssn: BinData(0, "A81…"), name: "Kevin" }
{ _id: 2, ssn: BinData(0, "017…"), name: "Eric" }
{ _id: 3, ssn: BinData(0, "5E1…"), name: "Albert" }
…
#MDBLocal
#MDBLocal
Destroy the key
Provably delete all user data.
GDPR "right-to-be-forgotten"
#MDBLocal
#MDBLocal
client = MongoClient(
auto_encryption_opts=opts)
#MDBLocal
Not sensitive
{
#MDBLocal
One key for all vaults
#MDBLocal
One key per vault
#MDBLocal
{
name: "Doris"
ssn: "457-55-5462",
email: "Doris@gmail.com",
credit_card: "4690-6950-9373-8791",
comments: [ …. ],
avatar: BinData(0, "0fi8…"),
profile: { likes: {…}, dislikes: {…} }
}
#MDBLocal
#MDBLocal
#MDBLocal
Describes JSON
{
bsonType: "object",
properties: {
a: {
bsonType: "int"
maximum: 10
}
b: { bsonType: "string" }
},
required: ["a", "b"]
}
{
a: 5,
b: "hi"
}
{
a: 11,
b: false
}
JSON Schema
#MDBLocal
{
bsonType: "object",
properties: {
ssn: {
encrypt: { … }
}
},
required: ["ssn"]
}
JSON Schema "encrypt"
#MDBLocal
encrypt: {
keyId: <UUID[]> or <string>,
algorithm: <string>
bsonType: <string> or <string[]>
}
bsonType indicates the type of underlying data.
algorithm indicates how to encrypt (Random or Deterministic).
keyId indicates the key used to encrypt.
#MDBLocal
opts = AutoEncryptionOptions(
schema_map = { "db.coll": <schema> }
…)
Client side Schema
#MDBLocal
Remote Schema Fallback
db.createCollection("coll", { validator: { $jsonSchema: … } } )
Misconfigured
Client insert "457-55-5462"
error, that should be
encrypted
MongoDB
#MDBLocal
What if
… the server lies about the schema?
Misconfigured
Client insert "457-55-5462"
Evil MongoDB
ok :)
#MDBLocal
schema_map
Sub-options
#MDBLocal
#MDBLocal
Key vault
Key vault key
Held only by you
#MDBLocal
#MDBLocal
#MDBLocal
Stores encrypted keys
#MDBLocal
opts = AutoEncryptionOptions(
schema_map = { "db.coll": <schema> },
key_vault_namespace = "db.keyvault"
…)
#MDBLocal
schema_map
Sub-options
key_vault_namespace
#MDBLocal
What if
… attacker drops key vault collection?
#MDBLocal
Keep at home
opts = AutoEncryptionOptions(
schema_map = { "db.coll": <schema> },
key_vault_namespace = "db.keyvault",
key_vault_client = <client>
…)
#MDBLocal
schema_map
Sub-options
key_vault_namespace
key_vault_client
#MDBLocal
#MDBLocal
(Key Management Service)
#MDBLocal
Protects keys Stores keys
KMS
Key vault key
Key vault
Key vault
collection
#MDBLocal
Decryption requires
#MDBLocal
opts = AutoEncryptionOptions(
schema_map = { "db.coll": <schema> },
key_vault_namespace = "db.keys",
kms_providers = <creds>
…)
#MDBLocal
schema_map
Sub-options
key_vault_namespace
key_vault_client
kms_providers
#MDBLocal
#MDBLocal
db.coll.insert({
name: "Doris",
ssn: "457-55-5462"
})
Get encrypted key
Decrypt the key with KMSDecrypt the key with KMS
Encrypt 457-55-5462
Send insert
Compare to JSON schema
#MDBLocal
#MDBLocal
#MDBLocal
Authenticated Encryption with Associated Data using the
Advanced Encryption Standard (256) with Cipher Block Chaining
and Hashed-based Message Authentication Code using the Secure
Hash Algorithm (512).
#MDBLocal
AEAD_AES_256_CBC_HMAC_SHA_512
Provides confidentiality + integrity
#MDBLocal
AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic
AEAD_AES_256_CBC_HMAC_SHA_512-Random
#MDBLocal
coll.insert({ ssn: "457-55-5462" }) { ssn: BinData(6, "a10x…") }
You see: MongoDB stores:
coll.insert({ ssn: "457-55-5462" }) { ssn: BinData(6, "f991…") }
…Random
#MDBLocal
coll.insert({ ssn: "457-55-5462" }) { ssn: BinData(6, "a10x…") }
You see: MongoDB stores:
coll.insert({ ssn: "457-55-5462" }) { ssn: BinData(6, "a10x…") }
…Deterministic
#MDBLocal
Can be queried
doc = db.coll.find({
ssn: "457-55-5642"
})
{
find: "coll",
filter: { ssn: BinData(0, "a10x…") }
}
Driver sends:
{ ssn: BinData(6, "a10x…") }
MongoDB returns:
…Deterministic
#MDBLocal
Only for binary comparable types.
db.coll.find({ a: { b: 1.0 } })
{ a: { b: NumberInt(1) } }
{ a: { b: 1.0 } }
{ a: { b: NumberLong(1) } }
MongoDB returns:
…Deterministic
#MDBLocal
{ a: { b: NumberInt(1) } }
{ a: { b: 1.0 } }
{ a: { b: NumberLong(1) } }
{ a: BinData(6, "19d0…") }
{ a: BinData(6, "b515…") }
{ a: BinData(6, "801f…") }
Encrypted as:
#MDBLocal
db.coll.find({ a: { b: 1.0 } })
{ a: { b: 1.0 } }
MongoDB returns:
"a" encrypted
#MDBLocal
#MDBLocal
{ ssn: BinData(6, "AWNkTYTCw89Ss1DPzV3/2pSRDNGNJ9NB" }
New binary subtype
Older drivers and older MongoDB will treat as a black box.
#MDBLocal
byte algorithm
byte[16] key_id
byte original_bson_type
byte* payload
Ciphertext
#MDBLocal
byte algorithm
byte[16] key_id
byte original_bson_type
byte* payload
key_id + algorithm describes how to decrypt.
No JSON Schema necessary!
Ciphertext
#MDBLocal
byte algorithm
byte[16] key_id
byte original_bson_type
byte* payload
Provides extra server-side validation.
But prohibits single-value types (MinKey, MaxKey, Undefined, Null) and Boolean
Ciphertext
#MDBLocal
byte algorithm
byte[16] key_id
byte original_bson_type
byte* payload
Payload includes encoded IV and padding block, and HMAC.
Ciphertext adds between 66 to 82 bytes of overhead.
Ciphertext
#MDBLocal
#MDBLocal
{
_id: UUID(…)
keyAltNames: [ "mykey" ],
keyMaterial: BinData(0, "39aJ…"),
… (some metadata) …
}
> db.keyvault.find()
Identify
(Cached locally only in memory)
#MDBLocal
#MDBLocal
#MDBLocal
#MDBLocal
#MDBLocal
#MDBLocal
IMMORAL Authority
DICTATORLAND
Users
Global Shards
#MDBLocal
EAST
DICTATORLAND
#MDBLocal
EAST
DICTATORLAND
{ _id: 1, body: BinData(6, "A81…") }
{ _id: 2, body: BinData(6, "017…") }
{ _id: 3, body: BinData(6, "5E1…") }
…
#MDBLocal
Demo
THANK YOU
#MDBlocal
Using Client Side
Encryption in MongoDB 4.2
[DEV/OPS]
Matthew Aylard
https://www.surveymonkey.com/r/KFB3PDD
MongoDB .local London 2019: Using Client Side Encryption in MongoDB 4.2

More Related Content

What's hot (19)

PPTX
MongoDB 3.2 - Analytics
Massimo Brignoli
 
PPTX
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
PPTX
Powering Systems of Engagement
MongoDB
 
PDF
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB
 
PPTX
MongoDB - Back to Basics - La tua prima Applicazione
Massimo Brignoli
 
PDF
MongoDB Performance Tuning
Puneet Behl
 
PDF
Javascript Object Signing & Encryption
Aaron Zauner
 
PPTX
Back to Basics: My First MongoDB Application
MongoDB
 
PPTX
JOSE Can You See...
Brian Campbell
 
PDF
Deciphering Explain Output
MongoDB
 
PDF
Webinar: Building Your First App with MongoDB and Java
MongoDB
 
KEY
The Ruby/mongoDB ecosystem
Harold Giménez
 
PDF
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB
 
KEY
Schema design
christkv
 
PPTX
Back to Basics Webinar 5: Introduction to the Aggregation Framework
MongoDB
 
PDF
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB
 
PPTX
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
MongoDB
 
PPTX
Introduction to MongoDB
Hossein Boustani
 
PPTX
Indexing Strategies to Help You Scale
MongoDB
 
MongoDB 3.2 - Analytics
Massimo Brignoli
 
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
Powering Systems of Engagement
MongoDB
 
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB
 
MongoDB - Back to Basics - La tua prima Applicazione
Massimo Brignoli
 
MongoDB Performance Tuning
Puneet Behl
 
Javascript Object Signing & Encryption
Aaron Zauner
 
Back to Basics: My First MongoDB Application
MongoDB
 
JOSE Can You See...
Brian Campbell
 
Deciphering Explain Output
MongoDB
 
Webinar: Building Your First App with MongoDB and Java
MongoDB
 
The Ruby/mongoDB ecosystem
Harold Giménez
 
MongoDB Europe 2016 - Enabling the Internet of Things at Proximus - Belgium's...
MongoDB
 
Schema design
christkv
 
Back to Basics Webinar 5: Introduction to the Aggregation Framework
MongoDB
 
MongoDB Launchpad 2016: What’s New in the 3.4 Server
MongoDB
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
MongoDB
 
Introduction to MongoDB
Hossein Boustani
 
Indexing Strategies to Help You Scale
MongoDB
 

Similar to MongoDB .local London 2019: Using Client Side Encryption in MongoDB 4.2 (20)

PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
PDF
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB
 
PDF
Achieving compliance With MongoDB Security
Mydbops
 
PDF
MongodB Internals
Norberto Leite
 
PDF
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB
 
PDF
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Mydbops
 
PPTX
Hacking MongoDB at RelateIQ, A Salesforce Company
MongoDB
 
PDF
Building your first app with MongoDB
Norberto Leite
 
PPTX
Webinar: Architecting Secure and Compliant Applications with MongoDB
MongoDB
 
PPTX
Percona Live 2021 - MongoDB Security Features
Jean Da Silva
 
PPTX
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
PDF
MongoDB
wiTTyMinds1
 
PDF
MongoDB World 2019: New Encryption Capabilities in MongoDB 4.2: A Deep Dive i...
MongoDB
 
PPTX
introtomongodb
saikiran
 
PPTX
Server discovery and monitoring with MongoDB
Joe Drumgoole
 
PPT
Webinar: Technical Introduction to Native Encryption on MongoDB
MongoDB
 
PDF
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB
 
PPTX
Webinar: Securing your data - Mitigating the risks with MongoDB
MongoDB
 
PDF
MongoDB .local London 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...
MongoDB
 
PPTX
lecture_34e.pptx
janibashashaik25
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB
 
Achieving compliance With MongoDB Security
Mydbops
 
MongodB Internals
Norberto Leite
 
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB
 
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Mydbops
 
Hacking MongoDB at RelateIQ, A Salesforce Company
MongoDB
 
Building your first app with MongoDB
Norberto Leite
 
Webinar: Architecting Secure and Compliant Applications with MongoDB
MongoDB
 
Percona Live 2021 - MongoDB Security Features
Jean Da Silva
 
Dev Jumpstart: Build Your First App with MongoDB
MongoDB
 
MongoDB
wiTTyMinds1
 
MongoDB World 2019: New Encryption Capabilities in MongoDB 4.2: A Deep Dive i...
MongoDB
 
introtomongodb
saikiran
 
Server discovery and monitoring with MongoDB
Joe Drumgoole
 
Webinar: Technical Introduction to Native Encryption on MongoDB
MongoDB
 
MongoDB Europe 2016 - Who’s Helping Themselves To Your Data? Demystifying Mon...
MongoDB
 
Webinar: Securing your data - Mitigating the risks with MongoDB
MongoDB
 
MongoDB .local London 2019: New Encryption Capabilities in MongoDB 4.2: A Dee...
MongoDB
 
lecture_34e.pptx
janibashashaik25
 
Ad

More from Lisa Roth, PMP (10)

PPTX
MongoDB .local London 2019: New Product Announcements: MongoDB Atlas Autoscal...
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: Gaining ML insight on Google Cloud with Google Vi...
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: The Human Element in an Automated World: Building...
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: Diverse Representations in Design
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: Launch Re-entry! How to Return to the Technical W...
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: Using AWS to Transform Customer Data in MongoDB i...
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: Streaming Data on the Shoulders of Giants
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: Fast Machine Learning Development with MongoDB
Lisa Roth, PMP
 
PDF
MongoDB .local London 2019: A Complete Methodology to Data Modeling for MongoDB
Lisa Roth, PMP
 
MongoDB .local London 2019: New Product Announcements: MongoDB Atlas Autoscal...
Lisa Roth, PMP
 
MongoDB .local London 2019: Gaining ML insight on Google Cloud with Google Vi...
Lisa Roth, PMP
 
MongoDB .local London 2019: The Human Element in an Automated World: Building...
Lisa Roth, PMP
 
MongoDB .local London 2019: Diverse Representations in Design
Lisa Roth, PMP
 
MongoDB .local London 2019: Launch Re-entry! How to Return to the Technical W...
Lisa Roth, PMP
 
MongoDB .local London 2019: Using AWS to Transform Customer Data in MongoDB i...
Lisa Roth, PMP
 
MongoDB .local London 2019: Streaming Data on the Shoulders of Giants
Lisa Roth, PMP
 
MongoDB .local London 2019: Tips and Tricks++ for Querying and Indexing MongoDB
Lisa Roth, PMP
 
MongoDB .local London 2019: Fast Machine Learning Development with MongoDB
Lisa Roth, PMP
 
MongoDB .local London 2019: A Complete Methodology to Data Modeling for MongoDB
Lisa Roth, PMP
 
Ad

Recently uploaded (20)

PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 

MongoDB .local London 2019: Using Client Side Encryption in MongoDB 4.2