SlideShare a Scribd company logo
Introducing…
Step 1
db.coll.insert({
_id: 1,
name: "Todd",
ssn: "457-55-5462"
})
Step 2
doc = db.coll.find({
ssn: "457-55-5642"
})
Step 3
print (doc)
{
_id: 1
name: "Todd",
ssn: "457-55-5462"
}
MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link
Client Side Encryption
Encrypt before sending. Decrypt after receiving.
Client Side Encryption
Encrypt before sending. Decrypt after receiving.
db.coll.insert({
name: "Todd",
ssn: "457-55-5462"
})
{
insert: "coll",
documents: [{
name: "Todd",
ssn: BinData("a10x…", "06")
}]

}
You see: MongoDB sees:
Client Side Encryption
How does this differ from…?
•… encryption in-transit (TLS)
•… encryption at-rest (encrypted storage engine)
Client Disk
{ ssn: "457-55-5462" } { ssn: "457-55-5462" }
Attacker
Steal disk
Listen to traffic
MongoDB
send over socket
insert: { ssn: "457-55-5462" }
{ ok: 1 }
Malicious admin
db.coll.find()
Client Disk
send over socket:
insert: { ssn: "457-55-5462" }
write to disk
{ ssn: "457-55-5462" }
MongoDB
Boundary of unencrypted data
Client Disk
send over socket:
insert: { ssn: "457-55-5462" }
write to disk
<ciphertext>
MongoDB
Boundary of unencrypted data
Enabling encrypted storage engine
Client Disk
send over socket:
<ciphertext>
write to disk
<ciphertext>
MongoDB
Encrypted storage engine
+
TLS
Client Disk
send over socket:
insert: { ssn: <ciphertext> }
write to disk
{ ssn: <ciphertext> }
MongoDB
Client Side Encryption
But why?
But why?
Store private data in the public cloud.
But why?
Store private stuff in public storage.
Storage Unit
Store private data in the public cloud.
Key to Unit
Held by you and
management
Police
Comes with a warrant
But why?
Support GDPR right-to-be-forgotten.
What is possible?
db.coll.insert({
name: "Todd",
ssn: "457-55-5462"
})
{
insert: "coll",
documents: [{
name: "Todd",
ssn: BinData("a10x…", "06")
}]

}
You see: MongoDB sees:
Insert
What is possible?
db.coll.update({}, {
$set: { ssn: "457-55-5462" }
})
{
update: "coll",
updates: [{
q:{},
u: {
$set: { ssn: BinData("a10x…", "06") }
}
}]

}
You see: MongoDB sees:
Update that overwrites value
What is possible?
db.coll.aggregate([{
$project: { name_ssn: {$concat: [ "$name", " - ", "$ssn" ] } }
}]
Aggregate acting on the data
What is possible?
Find with equality query
* For deterministic encryption
db.coll.find({ssn: "457-55-5462" }) {
find: "coll",
filter: { ssn: BinData("a10x…", "06") }
}
You see: MongoDB sees:
What is possible?
Find with equality query
* For deterministic encryption
db.test.find(
{
$and: [
{
$or: [
{ ssn : { $in : [ "457-55-5462", "153-96-2097" ]} },
{ ssn: { $exists: false } }
]
},
{ name: "Todd" }
]
}
)
You see:
What is possible?
Find with equality query
* For deterministic encryption
MongoDB sees:
{
find: "coll",
filter: {
$and: [
{
$or: [
{ ssn : { $in : [ BinData("a10x…", "06"), BinData("8dk1…", "06") ]} },
{ ssn: { $exists: false } }
]
},
{ name: "Todd" }
]
}
}
But how does it work?
encrypted_client = MongoClient(client_side_encryption_opts=opts)
Curtain #1
The Key Vault
Storage Unit Key to Unit
Held by you and
management
Vault key
Held only by you
Vault
Storage Unit
Vault
Vault key
Held only by you
Unit key
Held by you and
management
Storage Unit
Vault keys
Held only by you
Unit key
Held by you and
management
Vault keys
Held only by you
Vault keys Key vault
Key vault key
Held only by you
Storage Unit
Key vault key
Held only by you
Unit key
Held by you and
management
Storage Unit
MongoDB
collection
Key Management
Service (KMS)
MongoDB
credentials
Encrypted
data keys
VaultUnit key Vault keys Key vault key
Encrypted
data
Key vault
MongoDB
key vault
collection
db.coll.insert({
name: "Todd",
ssn: "457-55-5462"
})
1. Get encrypted data key from key vault collection
2. Decrypt data key with KMS
3. Encrypt "457-55-5462" with decrypted keyMaterial
4. Send insert to MongoDB
Key Vault Collection
{
_id: <UUID>,
keyAltNames: <string[]>,
keyMaterial: <BinData>,
creationDate: <Date>,
updateDate: <Date>
masterKey: <Document>
}
keyAltNames are alternate string identifiers.keyAltNames are alternate string identifiers.
masterKey identifies the KMS key
keyMaterial is the data key (encrypted with KMS)
What if
… a data key is compromised?
Data is safe, the key can't be decrypted without KMS
What if
… malicious DB admin drops key vault?
Then you lose access.
MongoDB key vault can be on a separate cluster.
…but
Curtain #2
JSON Schema
JSON Schema
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 "encrypt"
{
bsonType: "object",
properties: {
ssn: {
encrypt: { … }
}
},
required: ["ssn"]
}
encrypt: {
keyId: <UUID[]> or <string>,
algorithm: <string>
bsonType: <string> or <string[]>
}
bsonType indicates the type of underlying data.
E.g. "string" or [ "string", "objectId" ]
algorithm indicates how to encrypt.
"AEAD_AES_256_CBC_HMAC_SHA_512-Random" or
AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"
keyId indicates the key used to encrypt.
UUID("E0A8…") or "/fieldName"
keyId
encrypt: {
bsonType: "string"
keyId: [ UUID(1) ]
algorithm: "AEAD…"
}
Schema
{
_id: UUID(1)
keyAltNames: [ "Todd" ]
keyMaterial: BinData("AQIC…")
}
Key Vault Document
keyId
encrypt: {
bsonType: "string"
keyId: "/name"
algorithm: "AEAD…"
}
Schema
{
_id: UUID(1)
keyAltNames: [ "Todd" ]
keyMaterial: BinData("AQIC…")
}
Key Vault Document
{
name: "Todd",
ssn: "457-55-5462"
}
Document to insert
algorithm
AEAD_AES_256_CBC_HMAC_SHA_512-Random
AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic
Deterministic can satisfy equality queries.
Random is more secure.
bsonType
Only one type may be specified. Additional types are excluded:. "bool", "double",
"decimal128", "object", "array", "javascriptWithScope"
DETERMINISTIC restrictions
Single value types (undefined, null, minkey, maxkey) are prohibited.
Restrictions
Setting the JSON Schema
db.createCollection("coll", { validator: { $jsonSchema: … } } )
What if
… malicious DB admin sends you a bad schema?
Client is tricked into sending unencrypted data.
encryption_schema = {…}
client = MongoClient(schema_map={
"db.encrypted": encryption_schema
}, …)
Set it locally
Thanks

More Related Content

What's hot (19)

PDF
MongoDB
Rawin Windygallery
 
PPTX
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
PDF
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
PDF
MongoDB Europe 2016 - Debugging MongoDB Performance
MongoDB
 
PPTX
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB
 
PDF
Building a Social Network with MongoDB
Fred Chu
 
PPTX
Back to Basics Webinar 5: Introduction to the Aggregation Framework
MongoDB
 
PPTX
Back to Basics Webinar 3: Schema Design Thinking in Documents
MongoDB
 
PPTX
Back to Basics: My First MongoDB Application
MongoDB
 
PPTX
Introduction to MongoDB
Hossein Boustani
 
KEY
Mongo db presentation
Julie Sommerville
 
PPTX
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
MongoDB
 
PDF
はじめてのMongoDB
Takahiro Inoue
 
PPTX
Webinar: Back to Basics: Thinking in Documents
MongoDB
 
PDF
Blockchain Technologies for Data Science
Bruno Gonçalves
 
PDF
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB
 
PPTX
Schema Design Best Practices with Buzz Moschetti
MongoDB
 
PDF
Mongodb index 讀書心得
cc liu
 
PPTX
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
MongoDB
 
Webinar: General Technical Overview of MongoDB for Dev Teams
MongoDB
 
Inside MongoDB: the Internals of an Open-Source Database
Mike Dirolf
 
MongoDB Europe 2016 - Debugging MongoDB Performance
MongoDB
 
MongoDB San Francisco 2013: Hash-based Sharding in MongoDB 2.4 presented by B...
MongoDB
 
Building a Social Network with MongoDB
Fred Chu
 
Back to Basics Webinar 5: Introduction to the Aggregation Framework
MongoDB
 
Back to Basics Webinar 3: Schema Design Thinking in Documents
MongoDB
 
Back to Basics: My First MongoDB Application
MongoDB
 
Introduction to MongoDB
Hossein Boustani
 
Mongo db presentation
Julie Sommerville
 
Back to Basics Webinar 4: Advanced Indexing, Text and Geospatial Indexes
MongoDB
 
はじめてのMongoDB
Takahiro Inoue
 
Webinar: Back to Basics: Thinking in Documents
MongoDB
 
Blockchain Technologies for Data Science
Bruno Gonçalves
 
MongoDB .local Munich 2019: Aggregation Pipeline Power++: How MongoDB 4.2 Pip...
MongoDB
 
Schema Design Best Practices with Buzz Moschetti
MongoDB
 
Mongodb index 讀書心得
cc liu
 
Webinarserie: Einführung in MongoDB: “Back to Basics” - Teil 3 - Interaktion ...
MongoDB
 

Similar to MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link (20)

PDF
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
PDF
MongoDB .local London 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
PDF
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB
 
PDF
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Mydbops
 
PDF
Achieving compliance With MongoDB Security
Mydbops
 
PPT
Webinar: Technical Introduction to Native Encryption on MongoDB
MongoDB
 
PPTX
Webinar: Architecting Secure and Compliant Applications with MongoDB
MongoDB
 
PPTX
Percona Live 2021 - MongoDB Security Features
Jean Da Silva
 
PPTX
Securing Your Deployment with MongoDB Enterprise
MongoDB
 
PPTX
MongoDB Days UK: Securing Your Deployment with MongoDB Enterprise
MongoDB
 
KEY
2012 phoenix mug
Paul Pedersen
 
PPTX
Webinar: Securing your data - Mitigating the risks with MongoDB
MongoDB
 
PPT
Overview on NoSQL and MongoDB
harithakannan
 
PPTX
Securing Your Enterprise Web Apps with MongoDB Enterprise
MongoDB
 
PPTX
Hacking MongoDB at RelateIQ, A Salesforce Company
MongoDB
 
PDF
Mongo db 2.6_security_architecture
Mat Keep
 
PPT
MongoDB Pros and Cons
johnrjenson
 
KEY
Mongodb intro
christkv
 
ODP
MongoDB PhillyDB database throw down
zippy1981
 
PDF
MongodB Internals
Norberto Leite
 
MongoDB .local San Francisco 2020: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local London 2019: Using Client Side Encryption in MongoDB 4.2
MongoDB
 
MongoDB .local Bengaluru 2019: New Encryption Capabilities in MongoDB 4.2: A ...
MongoDB
 
Navigating MongoDB's Queryable Encryption for Ultimate Security - Mydbops
Mydbops
 
Achieving compliance With MongoDB Security
Mydbops
 
Webinar: Technical Introduction to Native Encryption on MongoDB
MongoDB
 
Webinar: Architecting Secure and Compliant Applications with MongoDB
MongoDB
 
Percona Live 2021 - MongoDB Security Features
Jean Da Silva
 
Securing Your Deployment with MongoDB Enterprise
MongoDB
 
MongoDB Days UK: Securing Your Deployment with MongoDB Enterprise
MongoDB
 
2012 phoenix mug
Paul Pedersen
 
Webinar: Securing your data - Mitigating the risks with MongoDB
MongoDB
 
Overview on NoSQL and MongoDB
harithakannan
 
Securing Your Enterprise Web Apps with MongoDB Enterprise
MongoDB
 
Hacking MongoDB at RelateIQ, A Salesforce Company
MongoDB
 
Mongo db 2.6_security_architecture
Mat Keep
 
MongoDB Pros and Cons
johnrjenson
 
Mongodb intro
christkv
 
MongoDB PhillyDB database throw down
zippy1981
 
MongodB Internals
Norberto Leite
 
Ad

More from MongoDB (20)

PDF
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
PDF
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
PDF
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
PDF
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
PDF
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
PDF
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
PDF
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
PDF
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
PDF
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
PDF
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
PDF
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
PDF
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
PDF
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB
 
MongoDB SoCal 2020: Migrate Anything* to MongoDB Atlas
MongoDB
 
MongoDB SoCal 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB SoCal 2020: Using MongoDB Services in Kubernetes: Any Platform, Devel...
MongoDB
 
MongoDB SoCal 2020: A Complete Methodology of Data Modeling for MongoDB
MongoDB
 
MongoDB SoCal 2020: From Pharmacist to Analyst: Leveraging MongoDB for Real-T...
MongoDB
 
MongoDB SoCal 2020: Best Practices for Working with IoT and Time-series Data
MongoDB
 
MongoDB SoCal 2020: MongoDB Atlas Jump Start
MongoDB
 
MongoDB .local San Francisco 2020: Powering the new age data demands [Infosys]
MongoDB
 
MongoDB .local San Francisco 2020: Using MongoDB Services in Kubernetes: any ...
MongoDB
 
MongoDB .local San Francisco 2020: Go on a Data Safari with MongoDB Charts!
MongoDB
 
MongoDB .local San Francisco 2020: From SQL to NoSQL -- Changing Your Mindset
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Jumpstart
MongoDB
 
MongoDB .local San Francisco 2020: Tips and Tricks++ for Querying and Indexin...
MongoDB
 
MongoDB .local San Francisco 2020: Aggregation Pipeline Power++
MongoDB
 
MongoDB .local San Francisco 2020: A Complete Methodology of Data Modeling fo...
MongoDB
 
MongoDB .local San Francisco 2020: MongoDB Atlas Data Lake Technical Deep Dive
MongoDB
 
MongoDB .local San Francisco 2020: Developing Alexa Skills with MongoDB & Golang
MongoDB
 
MongoDB .local Paris 2020: Realm : l'ingrédient secret pour de meilleures app...
MongoDB
 
MongoDB .local Paris 2020: Upply @MongoDB : Upply : Quand le Machine Learning...
MongoDB
 
MongoDB .local Paris 2020: Les bonnes pratiques pour sécuriser MongoDB
MongoDB
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
What’s my job again? Slides from Mark Simos talk at 2025 Tampa BSides
Mark Simos
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Designing_the_Future_AI_Driven_Product_Experiences_Across_Devices.pptx
presentifyai
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 

MongoDB World 2019: Using Client Side Encryption in MongoDB 4.2 Link