Repository navigation
Allow MongoDB SCRAM over an explicit tls=false - #163
Merged
Merged
Conversation
Many in-cluster MongoDB deployments, such as operator-managed replica sets, authenticate with SCRAM but have no TLS, and Weir refused them. Authentication now requires an explicit tls option instead of tls=true. tls=false keeps SCRAM-SHA-256, which never sends the password, and is documented for isolated networks only.
- serverStatus shows Weir's connections skip TLS, replacing the 5s requireTLS refusal - the wrong password must fail with AuthenticationFailed - unit tests pin the tls=false driver options and URI edge cases - docs name the offline-guessing and hijack risks of plaintext SCRAM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Weir accepted MongoDB credentials only with SCRAM-SHA-256 over
tls=true. Many in-cluster MongoDB deployments authenticate with SCRAM but have no TLS. MongoDB Community Operator replica sets without asecurity.tlssection are one example: every cluster in the deployment that Weir is meant to serve is set up this way. Weir could not connect to any of them, although other clients do today.Authentication now requires an explicit
tlsoption rather thantls=true. The rules:tls=falsewith SCRAM-SHA-256,authSourceand separate credentials is accepted.tls=truebehaves as before.tlsout still fails, so plaintext is never a silent default.tlswithout credentials still fails.tls=true.With
tls=falsethe SCRAM handshake and every command travel in plaintext, with nothing binding them together. Anyone who can see the traffic can read and change commands, guess the password offline from a captured handshake, or relay the handshake and use the authenticated connection with Weir's privileges.docs/configuration.md, the reference configuration and the code comment say this. They also say to prefertls=true, to usetls=falseonly when the network path to every replica-set member (including discovered members) is trusted, and to use a long random password. A NetworkPolicy limits which Pods can connect but does not hide traffic from node or host-network access. Search authentication still requires HTTPS.Tests:
uri_test.go:tls=falseandTLS=false.tls=FALSE,tls=0, conflictingtls=true&tls=falsein either order,ssl=false,tls=falsewithtlsInsecure,tls=falsewith a CA file, andtls=falsewithout credentials.TestMongoDriverPlaintextAuthenticationOptionschecks thattls=falsekeeps SCRAM authentication and sets no TLS config.TestMongoSCRAMWithoutTLSOpen(integration) runs against a SCRAMmongodthat accepts both TLS and plaintext (--tlsMode preferTLS, via the newtestmongo.OpenSecureAllowingPlaintext):tls=false, writes and reads back.serverStatuscounters show new connections but no new TLS handshakes. The baseline waits for the fixture's own monitoring connections to settle.connectionOptionsto enable TLS whenevertlsis set makes both the unit test and this test fail.go vet ./...,go test ./...andgo test -tags=integration -run TestMongoSCRAM ./internal/backend/mongodb(MongoDB 8.0.32) pass locally.