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

Mongo Shell crashes if -p is missing and user matches

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.0.1
    • Fix Version/s: 3.0.2, 3.1.1
    • Component/s: Security, Shell
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Backport Completed:
    • Sprint:
      Security 1 04/03/15

      Description

      Steps to reproduce:

      1. Start mongod
      2. Create user:

        mongo admin --eval "db.createUser({ user: 'admin', pwd: 'change_me', roles: [ 'root' ] })"

      3. Restart mongod with --auth
      4. Try to connect without -p but otherwise valid user:

        mongo admin -u admin

      Mongo Shell crashes with the following error/backtrace (the server is fine):

      ± % mongo admin -u admin
      MongoDB shell version: 3.0.1
      connecting to: admin
      LTC_ARGCHK 'key != NULL' failure on line 39 of file src/mongo/crypto/tom/hmac_memory.c
      2015-03-24T16:13:39.793+0000 F -        Got signal: 6 (Abort trap: 6).
       
       0x107d42bf9 0x107d42636 0x7fff8aa56f1a 0x7fff58071517 0x107c25543 0x107c255ea 0x107c18042 0x107c168ad 0x107bfa994 0x107c14d76 0x107bd29e7 0x107bd80a6 0x107bd3c31 0x107cb0e28 0x107ca1e92 0x107e44e84 0xf91b0306362
      ----- BEGIN BACKTRACE -----
      {"backtrace":[{"b":"107B8C000","o":"1B6BF9"},{"b":"107B8C000","o":"1B6636"},{"b":"7FFF8AA52000","o":"4F1A"},{"b":"0","o":"7FFF58071517"},{"b":"107B8C000","o":"99543"},{"b":"107B8C000","o":"995EA"},{"b":"107B8C000","o":"8C042"},{"b":"107B8C000","o":"8A8AD"},{"b":"107B8C000","o":"6E994"},{"b":"107B8C000","o":"88D76"},{"b":"107B8C000","o":"469E7"},{"b":"107B8C000","o":"4C0A6"},{"b":"107B8C000","o":"47C31"},{"b":"107B8C000","o":"124E28"},{"b":"107B8C000","o":"115E92"},{"b":"107B8C000","o":"2B8E84"},{"b":"0","o":"F91B0306362"}],"processInfo":{ "mongodbVersion" : "3.0.1", "gitVersion" : "534b5a3f9d10f00cd27737fbcd951032248b5952", "uname" : { "sysname" : "Darwin", "release" : "14.1.0", "version" : "Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64", "machine" : "x86_64" }, "somap" : [ { "path" : "/usr/local/bin/mongo", "machType" : 2, "b" : "107B8C000", "buildId" : "9B4F81D9462F3E7F88444913F7258F00" }, { "path" : "/usr/lib/libSystem.B.dylib", "machType" : 6, "b" : "7FFF89D0D000", "buildId" : "90B107BCFF7432CCB1CF4E02F544D957" }, { "path" : "/usr/lib/libc++.1.dylib", "machType" : 6, "b" : "7FFF8900E000", "buildId" : "1B9530FD989B3174BB1CBDC159501710" }, { "path" : "/usr/lib/system/libcache.dylib", "machType" : 6, "b" : "7FFF8242C000", "buildId" : "45E9A2E799C436B2BEE30C4E11614AD1" }, { "path" : "/usr/lib/system/libcommonCrypto.dylib", "machType" : 6, "b" : "7FFF869CE000", "buildId" : "D381EBC669D831D380845A80A32CB748" }, { "path" : "/usr/lib/system/libcompiler_rt.dylib", "machType" : 6, "b" : "7FFF86636000", "buildId" : "BF8FC133EE103DA69B9092039E28678F" }, { "path" : "/usr/lib/system/libcopyfile.dylib", "machType" : 6, "b" : "7FFF8FF95000", "buildId" : "0C68D3A6ACDD3EF3991ACC82C32AB836" }, { "path" : "/usr/lib/system/libcorecrypto.dylib", "machType" : 6, "b" : "7FFF82666000", "buildId" : "E178980139853949B7366B3378873301" }, { "path" : "/usr/lib/system/libdispatch.dylib", "machType" : 6, "b" : "7FFF8F8F3000", "buildId" : "502CF32B669B3709886208188225E4F0" }, { "path" : "/usr/lib/system/libdyld.dylib", "machType" : 6, "b" : "7FFF8BD8D000", "buildId" : "4E33E416F1D83598B8CC6863E2ECD0E6" }, { "path" : "/usr/lib/system/libkeymgr.dylib", "machType" : 6, "b" : "7FFF82FA7000", "buildId" : "77845842DE703CC5BD01C3D14227CED5" }, { "path" : "/usr/lib/system/liblaunch.dylib", "machType" : 6, "b" : "7FFF915B2000", "buildId" : "DFCDEBDF82473DC79879E7E497DDA4B4" }, { "path" : "/usr/lib/system/libmacho.dylib", "machType" : 6, "b" : "7FFF8FD45000", "buildId" : "126CA2EDDE91308F8881B9DAEC3C63B6" }, { "path" : "/usr/lib/system/libquarantine.dylib", "machType" : 6, "b" : "7FFF86633000", "buildId" : "DC0416272D92361CBABFA869A5C72293" }, { "path" : "/usr/lib/system/libremovefile.dylib", "machType" : 6, "b" : "7FFF8F5B5000", "buildId" : "3485B5F46CE83C628DFD8736ED6E8531" }, { "path" : "/usr/lib/system/libsystem_asl.dylib", "machType" : 6, "b" : "7FFF8CAD5000", "buildId" : "F153AC5B0542356E88C820A62CA704E2" }, { "path" : "/usr/lib/system/libsystem_blocks.dylib", "machType" : 6, "b" : "7FFF8C1DE000", "buildId" : "9615D10AFCA73BE4AA1A1B195DACE1A1" }, { "path" : "/usr/lib/system/libsystem_c.dylib", "machType" : 6, "b" : "7FFF8229C000", "buildId" : "199ED5EB77A13D43AA5181779CE0A742" }, { "path" : "/usr/lib/system/libsystem_configuration.dylib", "machType" : 6, "b" : "7FFF8663E000", "buildId" : "5E14864E089A3D8485A4980B776427A8" }, { "path" : "/usr/lib/system/libsystem_coreservices.dylib", "machType" : 6, "b" : "7FFF8B9EA000", "buildId" : "41B7C5785A5331C8A96FC73E030B0938" }, { "path" : "/usr/lib/system/libsystem_coretls.dylib", "machType" : 6, "b" : "7FFF81D03000", "buildId" : "3EAED90A7AA0323CA52BE16477981D59" }, { "path" : "/usr/lib/system/libsystem_dnssd.dylib", "machType" : 6, "b" : "7FFF82C06000", "buildId" : "62B70ECAE40D3C63896E7F00EC386DDB" }, { "path" : "/usr/lib/system/libsystem_info.dylib", "machType" : 6, "b" : "7FFF869A5000", "buildId" : "B85A85D585303A93B0C34DEC41F79478" }, { "path" : "/usr/lib/system/libsystem_kernel.dylib", "machType" : 6, "b" : "7FFF8CAB7000", "buildId" : "97CD7ACDEA0C3434BEFCFCD013D6BB73" }, { "path" : "/usr/lib/system/libsystem_m.dylib", "machType" : 6, "b" : "7FFF8D018000", "buildId" : "1E12AB456D9636D0A226F24D9FB0D9D6" }, { "path" : "/usr/lib/system/libsystem_malloc.dylib", "machType" : 6, "b" : "7FFF8B363000", "buildId" : "19BCC25757173502A71F95D65AFA861B" }, { "path" : "/usr/lib/system/libsystem_network.dylib", "machType" : 6, "b" : "7FFF8F91E000", "buildId" : "2EC3A005473F3C36A665F88B5BACC7F0" }, { "path" : "/usr/lib/system/libsystem_networkextension.dylib", "machType" : 6, "b" : "7FFF8E534000", "buildId" : "29AB225BD7FB30ED960065D44B9A9442" }, { "path" : "/usr/lib/system/libsystem_notify.dylib", "machType" : 6, "b" : "7FFF821D7000", "buildId" : "61147800F3203DAA850CBADF33855F29" }, { "path" : "/usr/lib/system/libsystem_platform.dylib", "machType" : 6, "b" : "7FFF8AA52000", "buildId" : "64E34079D7123D669CE2418624A5C040" }, { "path" : "/usr/lib/system/libsystem_pthread.dylib", "machType" : 6, "b" : "7FFF88A47000", "buildId" : "3103AA7F3BAE3673964947FFD7E15C97" }, { "path" : "/usr/lib/system/libsystem_sandbox.dylib", "machType" : 6, "b" : "7FFF8232A000", "buildId" : "95312E09DA28324AA084F3E574D0210E" }, { "path" : "/usr/lib/system/libsystem_secinit.dylib", "machType" : 6, "b" : "7FFF8FB60000", "buildId" : "581DAD0F6B633A48B63B917AF799ABAA" }, { "path" : "/usr/lib/system/libsystem_stats.dylib", "machType" : 6, "b" : "7FFF8699F000", "buildId" : "9B8CCF24DDDB399A92374BEC225D2E8C" }, { "path" : "/usr/lib/system/libsystem_trace.dylib", "machType" : 6, "b" : "7FFF8232D000", "buildId" : "A9E6B7D8C3273742AC5486C94218B1DF" }, { "path" : "/usr/lib/system/libunc.dylib", "machType" : 6, "b" : "7FFF8A72E000", "buildId" : "5676F7EAC1DF329FB006D2C3022B7D70" }, { "path" : "/usr/lib/system/libunwind.dylib", "machType" : 6, "b" : "7FFF8B9ED000", "buildId" : "BE7E51A0B6EA3A549CCA9D88F683A6D6" }, { "path" : "/usr/lib/system/libxpc.dylib", "machType" : 6, "b" : "7FFF83956000", "buildId" : "876216DCD5D3381E8AF949AE464E5107" }, { "path" : "/usr/lib/libobjc.A.dylib", "machType" : 6, "b" : "7FFF90E76000", "buildId" : "759E155DBC423D4E869B6F57D477177C" }, { "path" : "/usr/lib/libauto.dylib", "machType" : 6, "b" : "7FFF84579000", "buildId" : "A260789BD4D8316A9490254767B8A5F1" }, { "path" : "/usr/lib/libc++abi.dylib", "machType" : 6, "b" : "7FFF8FCA4000", "buildId" : "88A22A0F87C63002BFBAAC0F2808B8B9" }, { "path" : "/usr/lib/libDiagnosticMessagesClient.dylib", "machType" : 6, "b" : "7FFF83D3D000", "buildId" : "2EE8E4365CDC34C599595BA218D507FB" } ] }}
       mongo(_ZN5mongo15printStackTraceERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEE+0x39) [0x107d42bf9]
       mongo(_ZN5mongo12_GLOBAL__N_110abruptQuitEi+0xB6) [0x107d42636]
       libsystem_platform.dylib(_sigtramp+0x1A) [0x7fff8aa56f1a]
       ??? [0x7fff58071517]
       mongo(_ZN5mongo6crypto8hmacSha1EPKhmS2_mPhPj+0x73) [0x107c25543]
       mongo(_ZN5mongo5scram22generateSaltedPasswordERKNS_10StringDataEPKhiiPh+0x7A) [0x107c255ea]
       mongo(_ZN5mongo31SaslSCRAMSHA1ClientConversation11_secondStepERKNSt3__16vectorINS1_12basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEENS6_IS8_EEEEPS8_+0xD32) [0x107c18042]
       mongo(_ZN5mongo31SaslSCRAMSHA1ClientConversation4stepERKNS_10StringDataEPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE+0x1ED) [0x107c168ad]
       mongo(_ZN5mongo23NativeSaslClientSession4stepERKNS_10StringDataEPNSt3__112basic_stringIcNS4_11char_traitsIcEENS4_9allocatorIcEEEE+0x24) [0x107bfa994]
       mongo(_ZN5mongo12_GLOBAL__N_126saslClientAuthenticateImplEPNS_20DBClientWithCommandsERKNS_7BSONObjE+0x11D6) [0x107c14d76]
       mongo(_ZN5mongo20DBClientWithCommands5_authERKNS_7BSONObjE+0x297) [0x107bd29e7]
       mongo(_ZN5mongo18DBClientConnection5_authERKNS_7BSONObjE+0x1A6) [0x107bd80a6]
       mongo(_ZN5mongo20DBClientWithCommands4authERKNS_7BSONObjE+0x21) [0x107bd3c31]
       mongo(_ZN5mongo9mongoAuthEPNS_7V8ScopeERKN2v89ArgumentsE+0x438) [0x107cb0e28]
       mongo(_ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE+0x52) [0x107ca1e92]
       mongo(_ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE+0x1F4) [0x107e44e84]
       ??? [0xf91b0306362]
      -----  END BACKTRACE  -----
      

      If the -p option is provided to Mongo Shell, it works fine as expected. It also works fine with there is no matching user. For example:

      ± % mongo admin -u admin1
      MongoDB shell version: 3.0.1
      connecting to: admin
      2015-03-24T16:19:14.090+0000 E QUERY    Error: 18 Authentication failed.
          at DB._authOrThrow (src/mongo/shell/db.js:1236:32)
          at (auth):5:8
          at (auth):6:2 at src/mongo/shell/db.js:1236
      exception: login failed
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: