Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#308 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
冷清
技术栈
ruby

调研方向

从 lib/net/http.rb#connect 开始,具体检查创建代理 SSLSocket 的 @proxy_use_ssl 分支。将其设置与目标 TLS 连接进行比较,并确定应如何分别配置代理证书验证和主机名检查。完成的标准是:在发送 Proxy-Authorization 之前默认验证代理证书,并涵盖所有必要的验证设置。

由索引模型根据 Issue 内容生成。

描述

When connecting to a destination over TLS through a TLS proxy (an "HTTPS proxy"), enabling p_use_ssl encrypts the client→proxy hop but does not authenticate the proxy's certificate. The proxy TLS socket is built with no SSLContext and no post-connection check, so it defaults to VERIFY_NONE. This makes the proxy hop MITM-able, which matters because the Proxy-Authorization (Basic) credential is written over that socket in the CONNECT request.

Setup

Either of the documented ways to enable a TLS proxy:

  proxy = Net::HTTP.Proxy('proxy.example.com', 8080, 'user', 'pass', true)  # 5th arg -> @proxy_use_ssl
  http  = proxy.new('login.example.com', 443)
  http.use_ssl = true
  # ...or Net::HTTP.new(addr, port, p_addr, p_port, p_user, p_pass, p_no_proxy, true)
  http.get('/')
What happens

In Net::HTTP#connect, when @proxy_use_ssl is set, the proxy socket is wrapped as:

  proxy_sock = OpenSSL::SSL::SSLSocket.new(s)   # no SSLContext passed
  ssl_socket_connect(proxy_sock, @open_timeout)
  # ... then CONNECT + "Proxy-Authorization: Basic <creds>" is written to proxy_sock

SSLSocket.new(s) with no context uses a default context (verify_mode effectively VERIFY_NONE), and there is no post_connection_check on proxy_sock— the only post_connection_check in connect targets @address (the destination). So:

  • The destination cert is verified (via @ssl_context + post_connection_check(@address)). ✅
  • The proxy cert is neither verified nor hostname-checked. ❌

A MITM on the client→proxy path can therefore present any certificate, terminate the TLS, and read the Proxy-Authorization credential — the same credential exposure that enabling proxy TLS is meant to prevent.

Expected

The proxy TLS connection should verify the proxy certificate by default (use an SSLContext with VERIFY_PEER and run post_connection_check against the proxy host), consistent with how the destination connection is verified. At minimum there should be a way to supply verification settings (CA store, verify_mode, hostname) for the proxy connection distinct from the destination's.

Environment
  • Ruby 4.0.5
  • net-http 0.9.1
  • Reproduced by reading lib/net/http.rb#connect (the if @proxy_use_ssl branch) — the proxy SSLSocket is built without a context and gets no post_connection_check.
Related
  • jnunemaker/httparty#839 tracks a separate, complementary gap: HTTParty can't even set p_use_ssl (it passes only 6 of Net::HTTP.new's proxy args). This net-http issue is about the flag existing but not verifying the proxy cert.
主要语言
Ruby
星标
148
派生
95
平均合并
10 小时 54 分钟
30 天内合并 PR
4

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ruby/net-http 的其他 Issue

查看 ruby/net-http 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。