Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-78493

Issues with $set on non-encrypted fields QE

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.1.0-rc0, 7.0.0-rc8
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • ALL
    • v7.0
    • Security 2023-07-10
    • 163

      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
      }
      })
      

       

       

            Assignee:
            shreyas.kalyan@mongodb.com Shreyas Kalyan
            Reporter:
            shreyas.kalyan@mongodb.com Shreyas Kalyan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: