Skip to content

fix: verify HTTPS proxy certificates before CONNECT - #368

Open
abu-tahir-0 wants to merge 1 commit into
ruby:masterfrom
abu-tahir-0:fix/https-proxy-certificate-verification-308
Open

abu-tahir-0 wants to merge 1 commit into
ruby:masterfrom
abu-tahir-0:fix/https-proxy-certificate-verification-308

Conversation

@abu-tahir-0

Copy link
Copy Markdown

Problem

Net::HTTP::Proxy(..., true) wrapped the proxy connection in TLS without enabling certificate or hostname verification. Proxy credentials and application traffic could therefore be sent to an unauthenticated proxy.

Root cause

The proxy TLS socket was created with a default SSLContext, whose verification mode is VERIFY_NONE. Origin-server verification settings were not applied to the proxy connection.

Solution

Create a separate proxy SSLContext with VERIFY_PEER and hostname checking, set SNI for DNS proxy addresses, support an optional proxy_cert_store, and call post_connection_check before CONNECT or proxy authentication. Origin-server TLS configuration remains independent.

Testing

  • Focused proxy suite through Rake: 5 tests, 7 assertions, 0 failures.
  • Tests use loopback proxies with untrusted, trusted, and wrong-host certificates and assert that rejected proxies receive no application bytes.
  • Agent verification: full Rake suite 211 tests, 936 assertions; Ruby syntax, rbs validate, and diff check passed.
  • Ruby 4.0.10 was used. This addresses the already-public issue HTTPS proxy connection (p_use_ssl/proxy_use_ssl) does not verify the proxy's certificate #308; no embargo or coordinated advisory is claimed.

Fixes #308

Use a dedicated proxy SSL context with peer and hostname verification so
proxy credentials and application bytes are never sent over an
unauthenticated TLS connection. Add an optional proxy certificate store
and cover trusted, untrusted, and wrong-host proxies.

This branch has not been deployed

No deployments
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.

HTTPS proxy connection (p_use_ssl/proxy_use_ssl) does not verify the proxy's certificate

1 participant