Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-2312

SCRAM-SHA-* authentication fails on special characters in the password even after URL encoding

    • Type: Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.10.1
    • Component/s: Auth
    • Labels:
      None
    • Environment:
      Linux 4.15.0-1065-aws
      Ubuntu 18.04

      We have a MongoDB instance running on our public cloud (v4.2.8/Community) with a database called `etl_data` which contains 1 user `etl`. We were trying to connect to the database from our service instance (in the same network) and kept on receiving `Authentication failed`. Relevant log lines:

       

      2020-07-09T15:30:08.567+0530 I NETWORK [listener] connection accepted from [Redacted]:47432 #268 (6 connections now open)
      2020-07-09T15:30:08.567+0530 I NETWORK [conn268] received client metadata from [Redacted]:47432 conn268: { driver: { name: "PyMongo", version: "3.10.1" }, os: { type: "Linux", name: "Linux", architecture: "x86_64", version: "4.15.0-1065-aws" }, platform: "CPython 3.6.9.final.0" }
      2020-07-09T15:30:08.590+0530 I ACCESS [conn268] SASL SCRAM-SHA-256 authentication failed for etl on etl_data from client [Redacted]:47432 ; AuthenticationFailed: SCRAM authentication failed, storedKey mismatch
      2020-07-09T15:30:09.073+0530 I NETWORK [conn267] end connection [Redacted]:47430 (5 connections now open)
      2020-07-09T15:30:09.073+0530 I NETWORK [conn268] end connection [Redacted]:47432 (4 connections now open)

       

      We were following the [escaping practices as mandated by the documentation|https://api.mongodb.com/python/current/examples/authentication.html]; however, it still gave authentication failed. 

      Just out of curiosity, I changed the password to `password123` and it successfully authenticated. I changed the password again to something which contained special characters (`nIOAIK5S122HO-@?_rUp$EUt[+h%CEylDEu:ok:bM4OmH9#WB@Fj]Pk]I(U2}V%4`) and yet again, we received the dreaded authentication failed message.

      I looked around Jira for MongoDB and found a couple of related questions but none of them answer this exact bug.

            Assignee:
            prashant.mital Prashant Mital (Inactive)
            Reporter:
            shreyansh@getinfino.com Shreyansh Pandey
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: