[Bug] HTTPS-enforcement scenarios fail when Connect / Package Manager terminate TLS on their own port
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
cross_product/test_ssl.py と security/test_https.py を読み、request_http と make_http_request が HTTP レスポンスをどのように分類するかを、selftests/test_ssl_helper.py と selftests/test_https_helper.py にある既存のヘルパーテストと比較してください。TLS の拒否を示す既知のレスポンスと、無関係な 400 レスポンスについて、対象を絞ったケースを追加してください。既知の TLS 上の平文レスポンスが HTTPS の強制として受け入れられ、無関係な 400 および 200 レスポンスは引き続き該当するアサーションを満たさない状態になれば完了です。
索引モデルが issue の本文から書いたものです。
説明
VIP version
Seen live with posit-vip 2026.11.2. Reproduced against the v2026.12.0 source (1a54f5f4). The step logic in both files is unchanged on main.
Affected area
Cross-product tests (cross_product/test_ssl.py) and security tests (security/test_https.py)
What happened?
On a deployment where Connect and Package Manager terminate TLS themselves, four scenarios fail:
cross_product/test_ssl.py::test_http_redirects_to_https_for_product[Connect]and[Package Manager]security/test_https.py::test_product_enforces_https[Connect]and[Package Manager]
Here "terminate TLS themselves" means [HTTPS] Listen = :3939 / :4242, with no plain-HTTP listener on those ports.
Both make_http_request and request_http build the HTTP URL by swapping the scheme and keeping the port. So https://connect.example.com:3939 becomes http://connect.example.com:3939, and the plaintext request lands on the TLS listener.
Connect and Package Manager serve TLS with Go's net/http. On a TLS listener, Go answers a plaintext request with a valid HTTP response, not a reset (src/net/http/server.go, c.serve, the tls.RecordHeaderError / tlsRecordHeaderLooksLikeHTTP branch):
HTTP/1.0 400 Bad Request
Client sent an HTTP request to an HTTPS server.
httpx parses that as an ordinary response, so neither function reaches its httpx.NetworkError / httpx.ProtocolError branch. The code comments there describe that branch as "what a plaintext HTTP request gets back from a TLS-only port". The assertions then see a non-3xx status:
make_http_request -> {'status': 400, 'location': '', 'refused': False}
AssertionError: HTTP request was not refused or redirected (got HTTP 400). HTTPS is not enforced.
request_http -> {'status': 400, 'location': '', 'final_url_scheme': 'http', 'error': None}
AssertionError: HTTP did not redirect to HTTPS. Initial response: HTTP 400, Location: '', final URL scheme after following redirects: 'http'
The products are enforcing HTTPS. Nothing is served over plaintext, and http_port_no_content passes on the same response. They also cannot redirect on that port. Both products document HTTP→HTTPS redirection as a separate listener ([HTTPRedirect] Listen = :80). HTTPS.Permanent only adds HSTS and the secure cookie flag. References: Connect HTTPRedirect, Connect HTTPS, Package Manager HttpRedirect, Package Manager SSL.
So a deployment that follows the docs is reported as "HTTPS is not enforced". In the same run, Workbench on :443 with a :80 redirect passes both scenarios.
What did you expect to happen?
A TLS-only port that rejects plaintext with Go's 400 should be classified like the refused/reset case (refused: True / error: "port_closed"). Both scenarios should then pass for Connect and Package Manager on :3939 / :4242.
Steps to reproduce
No Posit product needed. Run a 12-line Go TLS listener and call VIP's own step functions against it.
main.go:
package main
import (
"log"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("ok\n")) })
log.Fatal(http.ListenAndServeTLS("127.0.0.1:18443", "cert.pem", "key.pem", nil))
}
openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 1 \
-subj /CN=localhost -addext subjectAltName=DNS:localhost,IP:127.0.0.1
printf 'module repro\ngo 1.27\n' > go.mod && go build -o tlsonly . && ./tlsonly &
curl -s http://127.0.0.1:18443/ # -> Client sent an HTTP request to an HTTPS server.
test_repro.py, run from an empty dir containing a bare pytest.ini ([pytest]):
import types
URL = "https://127.0.0.1:18443"
def cfg(url):
pc = types.SimpleNamespace(is_configured=True, url=url)
return types.SimpleNamespace(verify=False, product_config=lambda key: pc)
def test_security_https_enforced():
from vip_tests.security.test_https import make_http_request, https_enforced
https_enforced(make_http_request(URL, cfg(URL)))
def test_ssl_redirects_to_https():
from vip_tests.cross_product.test_ssl import request_http, redirects_to_https
redirects_to_https(request_http("Connect", cfg(URL)))
def test_ssl_http_port_no_content():
from vip_tests.cross_product.test_ssl import request_http, http_port_no_content
http_port_no_content(request_http("Connect", cfg(URL)))
uv run --no-project --with /path/to/vip python -m pytest -p no:vip -q -rA test_repro.py
# FAILED test_security_https_enforced - AssertionError: HTTP request was not refused or redirected (got HTTP 400) ...
# FAILED test_ssl_redirects_to_https - AssertionError: HTTP did not redirect to HTTPS. Initial response: HTTP 400 ...
# PASSED test_ssl_http_port_no_content
Relevant logs or output
Live vip verify --basic (2026.11.2), on one host running all three products: 4 failed, 65 passed, 26 skipped. The four failures are exactly the scenarios above, with the same assertion messages. A plain curl http://<host>:3939/ and curl http://<host>:4242/ both return Client sent an HTTP request to an HTTPS server.
Environment
- Live:
- Ubuntu 24.04, publicly trusted certificates.
- Workbench 2026.11.1 on
:443, with a:80redirect. - Connect 2026.11.1 with
[HTTPS] Listen = :3939and noHTTP.Listen. - Package Manager 2026.11.2 with
[HTTPS] Listen = :4242and[HTTP] Listen =(empty).
- Repro: Go 1.27.4, Python 3.15, VIP source
1a54f5f4.
Suggested fix
The comments in request_http and make_http_request say to keep the two in sync. In both, classify the response as refused / port_closed when it is a 400 carrying a known plaintext-on-TLS signature.
Keep it as narrow as #457 / #555 intended: match the server's signature, not any 400. A 400 for any other reason should still fail.
_PLAINTEXT_ON_TLS = (
b"Client sent an HTTP request to an HTTPS server", # Go net/http: Connect, Package Manager
b"The plain HTTP request was sent to HTTPS port", # nginx 497 -> 400 page
)
def _rejected_plaintext_on_tls(resp: httpx.Response) -> bool:
return resp.status_code == 400 and any(sig in resp.content for sig in _PLAINTEXT_ON_TLS)
The nginx string is from ngx_http_special_response.c (ngx_http_error_497_page). I only hit the Go case. Nothing here tested Workbench serving TLS on a non-default port.
request_http could report a distinct reason such as "tls_only" instead of reusing port_closed. The report would then say the TLS port rejected plaintext rather than "port closed".
Selftests can follow the existing monkeypatch.setattr(httpx, "get", fake_get) pattern in selftests/test_https_helper.py and the #555 block in selftests/test_ssl_helper.py:
httpx.Response(400, content=b"Client sent an HTTP request to an HTTPS server.\n")→ refused / passes;- a 400 with an unrelated body → still fails;
- a 200 → still fails
http_port_no_content.
Related: #457 and #555 narrowed this exception handling. #546 (TLS in CI) would exercise this path if the product terminates TLS itself.
- 主要言語
- Python
- スター
- 9
- フォーク
- 1
- 平均マージ
- 15時間 31分
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
posit-dev/vip のほかの issue
-
team: workbench
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
nightly-failure
難易度 4/5 1〜2日 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
-
nightly-failure
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
tracking
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
future-agi/future-agi#6392 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
memmapped_arange ignores the start value and drops the last point above the memmap threshold対応中かも @prathameshfuke が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
StingraySoftware/HENDRICS#213 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信