Skip to content

fix(mobile-core): honor https://wss:// scheme in gateway host (#77)#186

Open
quangdang46 wants to merge 1 commit into
masterfrom
fix/mobile-gateway-tls-scheme-detect
Open

fix(mobile-core): honor https://wss:// scheme in gateway host (#77)#186
quangdang46 wants to merge 1 commit into
masterfrom
fix/mobile-gateway-tls-scheme-detect

Conversation

@quangdang46
Copy link
Copy Markdown
Owner

What

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 passing https://secure.example.com with use_tls=false silently got an http:// connection — a downgrade attack vector and a common foot-gun.

This addresses issue #77: #77

Changes

  • crates/jcode-mobile-core/src/protocol.rs:
    • If the trimmed host starts with https:// or wss://, force-enable use_tls before normalizing. Plain http:// / ws:// still respect the caller's explicit flag.
    • Added gateway_config_auto_enables_tls_for_secure_schemes covering https, wss, and the http negative case.

Tests

$ cargo test -p jcode-mobile-core gateway_config

Notes

Ports upstream PR 1jehuang#83.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant