Fix basic auth denial for proxy-protocol cert clients#3561
Open
pieterhollander wants to merge 1 commit intoeclipse-mosquitto:masterfrom
Open
Fix basic auth denial for proxy-protocol cert clients#3561pieterhollander wants to merge 1 commit intoeclipse-mosquitto:masterfrom
pieterhollander wants to merge 1 commit intoeclipse-mosquitto:masterfrom
Conversation
Signed-off-by: Pieter Hollander <eclipse@hollander.online>
c8acb46 to
b71e765
Compare
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.
Problem
When a listener uses PROXY protocol v2 with
use_identity_as_username true,clients authenticated via mTLS at the proxy are incorrectly denied by
mosquitto_basic_auth().With direct TLS,
handle_connect.cskipsmosquitto_basic_auth()whenssl_ctxis set anduse_identity_as_usernameis enabled — authenticationis "assumed to be cleared." However, with proxy protocol,
ssl_ctxis NULL(TLS was terminated externally), so the bypass does not trigger. The client
falls through to
mosquitto_basic_auth(), all plugins defer (no password),and the
allow_anonymousfallback rejects it becauseusername != NULL.Code path (before fix)
Fix
Extend the auth bypass condition to also recognize proxy protocol listeners:
When
enable_proxy_protocol > 0anduse_identity_as_usernameis set, theclient was authenticated externally via certificate — same as direct TLS.
Testing
Tested with:
use_identity_as_username trueTt seems the fixes branch doesn't contain Mosquitto 2.1 with PROXY protocol support yet. Therefore, I'm submitting this to "master".
make testwith your changes locally?