Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passwords Stored Using Cryptographically Weak MD5 Hash (CWE-916) #153

Open
donutloop opened this issue Apr 24, 2018 · 4 comments
Open

Passwords Stored Using Cryptographically Weak MD5 Hash (CWE-916) #153

donutloop opened this issue Apr 24, 2018 · 4 comments

Comments

@donutloop
Copy link

donutloop commented Apr 24, 2018

User passwords are stored in the MongoDB database using a cryptographically weak hashing algorithm (e.g. MD5). The user’s credentials are constructed into the string format username:mongo:password. An MD5 hash of this string is stored in the database and used to authenticate the user.

Recent versions of MongoDB support the more secure SCRAM-SHA1 which should be used instead of the previous MONGODB-CR which uses the unsalted MD5 hash.

CWE-916 Reference: "https://cwe.mitre.org/data/definitions/916.html"

Password Property

mgo/session.go

Line 968 in f76e4f9

// PasswordHash is the MD5 hash of Username+":mongo:"+Password.

AddUser

bildschirmfoto 2018-04-24 um 10 38 07

Reference: "https://github.com/globalsign/mgo/blob/master/session.go#L1053:21"

UpsertUser

bildschirmfoto 2018-04-24 um 10 38 22

Reference: "https://github.com/globalsign/mgo/blob/master/session.go#L1053:19"

@domodwyer
Copy link

Hi @donutloop

You raise a very valid, important point - this is trivially breakable hash.

We highly recommend using certificate based authentication in production, it's really worth the time to set up from a security perspective.

As for password-based login mgo should definitely support the most secure hashes mongodb can use - we'll happily accept a PR for this, and will deprecate the MD5-based credentials as soon as we have an alternative.

Thanks @donutloop!

Dom

@philippgille
Copy link

Info:

Starting in version 4.0, MongoDB removes support for the deprecated MongoDB Challenge-Response (MONGODB-CR) authentication mechanism.

https://docs.mongodb.com/manual/core/security-scram/

@domodwyer
Copy link

Hi @philippgille

MGO already supports SCRAM authentication (though only SHA1, SHA-256 is in progress) - we'll happily accept a PR removing the MD5-based challenge-response auth mechanism though!

Dom

@Neustradamus
Copy link

@ all: I wish you a Happy New Year 2022!

Any news about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants