www/nginx: per-server option to reject requests whose Host differs from the TLS SNI (421)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 68/100
調査の方向性
Read Nginx.xml, dialogHttpServer.xml, and the http.conf template named in the issue. Trace how per-server options such as https_only are defined, shown in the form, and rendered. Add the opt-in setting and conditional mismatch handling described in the issue; done means enabled servers return 421 for mismatched SNI and Host while the listed HTTP and TLS cases remain unaffected.
索引モデルが issue の本文から書いたものです。
説明
Important notices
Before you add a new report, we ask you kindly to acknowledge the following:
- I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
- I have searched the existing issues, open and closed, and I'm convinced that mine is new.
- When the request is meant for an existing plugin, I've added its name to the title.
Is your feature request related to a problem? Please describe.
nginx selects the TLS certificate by SNI, but the server block by the Host header. A client can complete the TLS handshake for one server name and then request a different virtual host on the same listener (domain fronting).
This becomes a real problem when a component in front of nginx can only see the SNI. Examples are an SNI-based TLS passthrough (HAProxy req.ssl_sni, or the plugin's own stream SNI routing) and a captive portal or firewall that lets unauthenticated clients reach a single host name. The filter allows login.example.com, but inside that connection the client can send Host: internal-app.example.com and reach any other site on the same nginx.
I hit this in practice. Before sign-in, a guest network may only reach an SSO login, and HAProxy filters by SNI. With SNI login.example.com and a different Host header, guests can reach other proxied instances hosted on the same nginx when you want only to allow login.example.com.
Describe the solution you'd like
A checkbox per HTTP server in /ui/nginx, e.g. "Reject requests whose Host does not match the TLS SNI (421)", default off.
Suggested rendering in http.conf: a map at http level, emitted only when at least one server enables the option, plus one line in the server block next to the existing https_only handling:
# http level
map "$scheme|$ssl_server_name|$host" $sni_host_mismatch {
default 1;
"~^http\|" 0; # plain HTTP: redirects and ACME http-01 unaffected
"~^https\|\|" 0; # TLS without SNI
"~*^https\|([^|]+)\|\1$" 0; # SNI equals Host (case-insensitive)
}
# server level, when the option is enabled
if ($sni_host_mismatch) { return 421; }
- 421 Misdirected Request is the status RFC 9110 defines for this case. Browsers that coalesce HTTP/2 connections across names on the same certificate get the 421 and retry on a new connection.
- Plain HTTP and TLS without SNI are unaffected, so
https_onlyredirects and ACME http-01 keep working. $hostis lowercased by nginx and the regex is case-insensitive, so SNI casing doesn't matter.
Changes needed:
Nginx.xml: aBooleanFieldonhttp_server(e.g.sni_host_strict, default0).dialogHttpServer.xml: a form field with help text.http.conf: themap(only when used) and theifline in the server block.
Describe alternatives you've considered
- A dedicated listener/port that only the allowed server uses, with the SNI filter forwarding there. This works through the API and is what I use now, but each case needs an extra port and firewall rule, and it only protects that one path.
- Include files in
<server-uuid>_pre/(the template'sinclude {{ server['@uuid'] }}_pre/*.conf) containing the rendering above. This works, but it needs shell access and silently stops applying when a server is recreated with a new UUID. - Naxsi rules or security headers: not possible. Naxsi only inspects the HTTP request and never sees the SNI.
Additional context
The rendering above was tested as include files on OPNsense 26.7 (os-nginx, nginx 1.30):
- SNI
login.example.comwithHost: git.example.com→ 421. - Every site requested with its own name → unchanged.
- http → https redirects → unchanged.
The map logic was also checked on a plain nginx 1.29, including mixed-case SNI, an empty SNI, and a Host that only shares a suffix with the SNI.
- 主要言語
- PHP
- スター
- 1.2k
- フォーク
- 926
- 平均マージ
- 1日 10時間
- マージ済み PR(30日)
- 25
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
opnsense/plugins のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
opnsense/plugins#5976 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
net/haproxy: IPv6 literal in real server "Source address" generates an invalid `source` directiveオープンincomplete
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
opnsense/plugins#5973 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[dns/ddclient] Support hiding unused standard fields per service (optional_hiding)対応中かも @bringha1 が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
q-feeds-connector: "error in configd communication" every update when the Unbound DNSBL rebuild takes longer than 120s対応中かも @mhatipog が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
opnsense/plugins の issue をすべて見る
似ている issue
-
15.0
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
open-telemetry/opentelemetry-php-distro#176 ·
メンテナーはふだん 2 日以内に返信
-
No Code Attached Yet
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
joomla/joomla-cms#48941 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage Platform(Default)
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug new
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
moodle-an-hochschulen/moodle-theme_boost_union#1500 ·
メンテナーはふだん 1 日以内に返信