Launching soon: The world's first vendor agnostic bug scrubLearn more & join waitlist

MongoDB - Defect ID: 474663

Mongo is not accepting password as a parameter

Last updated on 10/27/2023

Overall
5.95.9
Severity
6.46.4
Community
66.0
Lifecycle
9.19.1

Vendor details

  • Priority: Major - P3
  • Status: Closed

Info

While connecting to MongoDB 3.2 via "mongo" from Debian 9 shell it seems that the password can only be typed manually after being promted for it. Example: mongo hostname:port/database -u username -p The goal, however, is for the user to be able to pass the password along with other parameters. Example: mongo hostname:port/database -u username -p password Repro steps: install Debian 9 install MongoDB 3.2 using Debian packages add some user to MongoDB enable authentication in config file restart MongoDB try connecting Expected result: User is able to pass the password along other connection parameters and is able to login successfully. Actual result: User is still prompted for password despite already passing it with other parameters. The problem does not occur for Debian 8 and MongoDB 2.4. The problem does not occur for Debian 9 and MongoDB 3.2 when using mongodump / mongorestore. According to the documentation, passing password as a parameter is possible, so what's going on here? https://docs.mongodb.com/v3.2/reference/program/mongo/

Top User Comments

adam.martin commented on Wed, 10 Jan 2018 20:40:08 +0000: This appears to work correctly in the shell for version 3.6. This issue has been fixed in current versions of the shell. If you are unable to use the workaround for this issue, please upgrade to a later version of the MongoDB Shell. t.jones commented on Tue, 2 Jan 2018 10:09:02 +0000: adam.martin I did some testing and indeed I can now connect with space between -p and password: mongo hostname:port/database -u username -p I tested on Debian 8.10 with Mongo installed from MongoDB's repos: https://docs.mongodb.com/master/tutorial/install-mongodb-on-debian/ # dpkg -l | grep mongo ii mongodb-org 3.6.1 amd64 MongoDB open source document-oriented database system (metapackage) ii mongodb-org-mongos 3.6.1 amd64 MongoDB sharded cluster query router ii mongodb-org-server 3.6.1 amd64 MongoDB database server ii mongodb-org-shell 3.6.1 amd64 MongoDB shell client ii mongodb-org-tools 3.6.1 amd64 MongoDB tools I'd like to point out, however, that this testing scenario is not exactly perfect for me: I did not test whether previous versions of Mongo coming from mentioned repo had the same issue (I can only confirm that the bug exists for Debian 9's native MongoDB package) my own environment uses Debian 9, for which MongoDB's repos are not available (they're available only for up to Debian 8) my own environment uses Debian 9's native repos, for which the latest MongoDB version is 3.2 (and it's likely that it's going stay with this number for a long time) so I am not able to test any of the latest commits adam.martin commented on Fri, 29 Dec 2017 17:44:11 +0000: Hello t.jones, I've performed a small test of this behavior on our master branch, and it seems that the shell accepts a password without a space between "-p" and the password text. Can you confirm that this is now fixed for your use case with 3.6's shell? t.jones commented on Thu, 21 Dec 2017 07:52:20 +0000: mark.agarunov, thanks for the feedback. The workaround is suprisingly trivial, so I am totally OK with using it until the fix appears. Thanks! mark.agarunov commented on Wed, 20 Dec 2017 19:24:17 +0000: Hello t.jones, Thank you for the report. After some testing, I'm able to reproduce this issue and am investigating the cause. However, as a workaround it appears that if you do not leave a space between the -p flag and the password, it logs in as expected: vagrant@stretch:~$ mongo -u test -p test MongoDB shell version: 3.2.11 Enter password: connecting to: test > bye vagrant@stretch:~$ mongo -u test -ptest MongoDB shell version: 3.2.11 connecting to: test > Thanks, Mark

Steps to Reproduce


  • 5.9Defect ID: 2956672
    Some time-series tests implicitly rely on measurement insertion order for unordered inserts when checking bucket catalog stats
  • 6.14Defect ID: 2965528
    Remove push, publish_packages, and crypt_push tasks from Graviton 4 variants in v7.0 and v8.0
  • 6.14Defect ID: 2947969
    [SBE] Release storage engine resources when saveState() or restoreState() throws
  • 5.68Defect ID: 2919474
    StackLocator broken by v5 toolchain ASAN
  • 5.88Defect ID: 2968769
    Make new write path helper functions use acquireAndValidateBucketsCollection instead of acquireCollection

Ready to prevent the next vendor outage?

BugZero | MongoDB BugID 474663 - Mongo is not accepting password as a parameter