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

mongo shell does not URL-decode password from connection URI

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • None
    • ALL

      I was trying to connect to a mongod with a password that happens to contain special characters. These special characters are supposed to be URL-encoded in the connection URI. For example, if the password is pass%word the connection URI should be mongodb://root:pass%25word@localhost:27017/test.

      Using db.auth shows that the password contains a special character:

      /tmp/repro % mongo
      MongoDB shell version: 3.2.10
      connecting to: test
      > db.auth('root', 'pass%word')
      1
      >
      bye
      

      The shell accepts this incorrect connection URI:

      /tmp/repro % mongo 'mongodb://root:pass%word@localhost:27017/test'
      MongoDB shell version: 3.2.10
      connecting to: mongodb://root:pass%word@localhost:27017/test
      >
      bye
      

      The shell does not accept this correct connection URI:

      /tmp/repro % mongo 'mongodb://root:pass%25word@localhost:27017/test'
      MongoDB shell version: 3.2.10
      connecting to: mongodb://root:pass%25word@localhost:27017/test
      2016-10-11T17:43:25.421-0400 E QUERY    [thread1] Error: Authentication failed. :
      connect@src/mongo/shell/mongo.js:223:14
      @(connect):1:6
      
      exception: connect failed
      

      Relevant part of the connection URI spec:

      4. Validate, split (if applicable), and URL decode the user information.

      https://github.com/mongodb/specifications/blob/master/source/connection-string/connection-string-spec.rst#reference-implementation

            Assignee:
            sara.golemon@mongodb.com Sara Golemon
            Reporter:
            david.percy@mongodb.com David Percy
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: