[SERVER-78493] Issues with $set on non-encrypted fields QE Created: 28/Jun/23  Updated: 29/Oct/23  Resolved: 06/Jul/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.1.0-rc0, 7.0.0-rc8

Type: Bug Priority: Major - P3
Reporter: Shreyas Kalyan Assignee: Shreyas Kalyan
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0
Sprint: Security 2023-07-10
Participants:
Linked BF Score: 163

 Description   

In an encrypted collection with encrypted fields, if a user inserts a document with no encrypted fields, and attempts to update the document with $set to set non-encrypted fields, the document fails to update, returning a response “Found indexed encrypted fields but could not find {}safeContent{}“.
 
For example, if the collection schema is:

assert.commandWorked(edb.createCollection("basic", {
encryptedFields: {
"fields": [
{"path": "first", "bsonType": "string", keyId: studentsKeyId, "queries": {"queryType": "equality"}},
{"path": "last", "bsonType": "string", keyId: key2, "queries": {"queryType": "equality"}}
]
}
}));

 
Then we insert the doc:

edb.basic.insert({"middle": "happy"})

 
Then run an updateOne command:

edb.basic.updateOne({_id: ObjectId("649b414fb88e21eab30d6481")}, {$set: {middle: "E"}})

 
We get a response:

 

WriteError({
"index" : 0,
"code" : 6371506,
"errmsg" : "Found indexed encrypted fields but could not find _safeContent_",
"op" : {
"q" :
{ "_id" : ObjectId("649b414fb88e21eab30d6481") }
,
"u" : {
"$set" :
{ "middle" : "E" }
},
"multi" : false,
"upsert" : false
}
})

 

 



 Comments   
Comment by Githook User [ 14/Jul/23 ]

Author:

{'name': 'Shreyas Kalyan', 'email': 'shreyas.kalyan@mongodb.com', 'username': 'shreyaskal'}

Message: SERVER-78493 Issues with on non-encrypted fields QE

(cherry picked from commit f2fa5763fa214a8f7bcc217b6517c9f6c55177dc)
Branch: v7.0
https://github.com/mongodb/mongo/commit/24698ea71c06ba7c9477ffbe63095759ad5f3c8c

Comment by Githook User [ 07/Jul/23 ]

Author:

{'name': 'Shreyas Kalyan', 'email': 'shreyas.kalyan@mongodb.com', 'username': 'shreyaskal'}

Message: SERVER-78493 Issues with on non-encrypted fields QE
Branch: master
https://github.com/mongodb/mongo/commit/918c3a76223f3d29d767b6e7282fcc61b3dbd77e

Comment by Githook User [ 06/Jul/23 ]

Author:

{'name': 'Shreyas Kalyan', 'email': 'shreyas.kalyan@mongodb.com', 'username': 'shreyaskal'}

Message: SERVER-78493 Issues with on non-encrypted fields QE
Branch: master
https://github.com/mongodb/mongo/commit/f2fa5763fa214a8f7bcc217b6517c9f6c55177dc

Generated at Thu Feb 08 06:38:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.