ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.16, 9.0.7, 8.0.37, 7.0.48
    • Affects Version/s: None
    • Component/s: None
    • Server Security
    • Fully Compatible
    • ALL
    • v9.0, v8.3, v8.0, v7.0
    • Hide

      1. start a standalone mongod with --auth
      2. run the following (expected to pass):

      db.getSiblingDB("$external").runCommand({createUser: "CN=admin,OU=eng,O=corp", roles: [{role: "root", db: "admin"}]})
      

      3. run the following

      db.getSiblingDB("admin").runCommand({createUser: "pwn", pwd: "pwn", roles: [{role: "root", db: "admin"}]})
      

      Step 3 is expected to fail with Unauthorized error, but passes.

      Show
      1. start a standalone mongod with --auth 2. run the following (expected to pass): db.getSiblingDB( "$external" ).runCommand({createUser: "CN=admin,OU=eng,O=corp" , roles: [{role: "root" , db: "admin" }]}) 3. run the following db.getSiblingDB( "admin" ).runCommand({createUser: "pwn" , pwd: "pwn" , roles: [{role: "root" , db: "admin" }]}) Step 3 is expected to fail with Unauthorized error, but passes.
    • Server Security 2026-11-20
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In a auth-enabled server bound to localhost, the localhost exception allows an unauthenticated user to run a tiny set of commands (e.g. createUser and createRole) in order to bootstrap the server and create the initial set of users. Under this mode, a createUser command is permitted if the authentication database is either "admin" or "$external" (see AuthorizationSessionImpl::_getDefaultPrivileges in authorization_session_impl.cpp). Once a user is created in either of those DBs, the localhost exception is expected to close and start requiring authorization on the exempted commands. This works fine if the first user is created in the "admin" database, and this is the case that is well-tested. However, if the first user is created in the "$external" database, the localhost exception remains open, so if a user only ever creates a user in "$external" during setup, assuming that auth will be enforced fully afterwards, an attacker can connect and still create users that could be granted root privileges.

            Assignee:
            Erwin Pe
            Reporter:
            Erwin Pe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: