fix(mobile-core): honor https://wss:// scheme in gateway host (#77)#186
Open
quangdang46 wants to merge 1 commit into
Open
fix(mobile-core): honor https://wss:// scheme in gateway host (#77)#186quangdang46 wants to merge 1 commit into
quangdang46 wants to merge 1 commit into
Conversation
MobileGatewayConfig::new took a (host, port, use_tls) tuple where the host string was assumed to be a bare hostname. In practice mobile clients, copy-pasted gateway URLs, and automated provisioners often surface the full scheme (https://… / wss://…) in the host field. The old code threaded the boolean `use_tls` flag through unchanged, so a caller that passed `https://secure.example.com` with `use_tls=false` silently got an http:// connection — a downgrade attack vector and a common foot-gun. If the trimmed host begins with `https://` or `wss://`, force-enable `use_tls` before normalizing. Plain `http://` and `ws://` still respect the caller's explicit flag. Test `gateway_config_auto_enables_tls_for_secure_schemes` covers all three branches (https, wss, http). Ports upstream PR 1jehuang#83. Closes #77
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.
What
MobileGatewayConfig::newtook a(host, port, use_tls)tuple where the host string was assumed to be a bare hostname. In practice mobile clients, copy-pasted gateway URLs, and automated provisioners often surface the full scheme (https://.../wss://...) in the host field. The old code threaded the booleanuse_tlsflag through unchanged, so a caller passinghttps://secure.example.comwithuse_tls=falsesilently got an http:// connection — a downgrade attack vector and a common foot-gun.This addresses issue #77: #77
Changes
https://orwss://, force-enableuse_tlsbefore normalizing. Plainhttp:///ws://still respect the caller's explicit flag.gateway_config_auto_enables_tls_for_secure_schemescovering https, wss, and the http negative case.Tests
Notes
Ports upstream PR 1jehuang#83.