os-nginx: add X-Frame-Options, Permissions-Policy and Server header removal

オープン
#5,942 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
nginx, php
領域
backend, security

調査の方向性

Start by locating the os-nginx Security Header model and its template, then inspect the HTTP settings model and template where server_tokens off; is rendered. Check the existing field validation and header rendering patterns, and run the relevant plugin tests or configuration checks. Done means the requested validated header options and Server header removal are persisted in configuration and render into the intended nginx contexts.

索引モデルが issue の本文から書いたものです。

説明

incomplete

Important notices

  • I have read the contributing guide
  • I have searched for existing issues

Is your feature request related to a problem? Please describe.
The Security Header object in os-nginx currently supports Referrer, XSS Protection,
Don't Sniff Content Type, HSTS, HPKP and CSP. Three common hardening measures
recommended by the OWASP Secure Headers Project and flagged by scanners are missing:

  • X-Frame-Options
  • Permissions-Policy
  • removing the Server response header (server_tokens off only hides the version;
    nginx still sends Server: nginx)

The only way to achieve this today is custom files in /usr/local/etc/nginx/http_post/.
That has two drawbacks:

  1. add_header at http level is not inherited by server blocks that define their own
    add_header – which every server does as soon as a Security Header object is
    assigned. The workaround therefore needs more_set_headers / more_clear_headers
    (headers-more module), which is not obvious to most users.
  2. The files are not part of config.xml, so they are not included in configuration
    backups, are not synchronised to an HA peer, and are lost on reinstall.

Describe the solution you like
Constrained, validated fields only – no free-form config:

  1. X-Frame-Options – OptionField in the Security Header model
    Values: (not set), DENY, SAMEORIGIN
    Rendered as:
    proxy_hide_header X-Frame-Options;
    add_header X-Frame-Options "" always;

  2. Permissions-Policy – TextField with strict mask validation in the Security
    Header model
    Only directive=allowlist pairs separated by commas, e.g.
    camera=(self), microphone=(self), geolocation=(), payment=()
    Suggested mask (rejects ;, {, }, quotes outside origins and newlines):
    /^[a-z-]+=(*|((\s*(self|"https?://[^"\s;{}]+")\s*)))(\s,\s*[a-z-]+=(*|((\s*(self|"https?://[^"\s;{}]+")\s*))))$/
    Rendered as:
    proxy_hide_header Permissions-Policy;
    add_header Permissions-Policy "" always;

  3. Remove Server response header – global checkbox in the HTTP settings
    (next to the existing option that renders server_tokens off;)
    Since the plugin already loads ngx_http_headers_more_filter_module, this could be
    rendered in the http block as:
    more_clear_headers Server;

Items 1 and 2 follow the existing behaviour of the Security Header object ("if you set
a setting here, it will override what the webserver sets").

Optional, if in scope: Cross-Origin-Opener-Policy and Cross-Origin-Resource-Policy
as OptionFields with their standard values.

Describe alternatives you considered

  • Custom files in http_post/ (more_set_headers / more_clear_headers) – works, but
    not persisted in config.xml (see above).
  • Patching the model/template locally – overwritten on every plugin update.
  • A generic free-text field – I understand this has been declined before because broken
    input can take down nginx; the proposal above deliberately avoids that by using
    validated fields only.

Additional context

  • OPNsense 26.10.0p1-amd64, os-nginx 1.36_5, nginx 1.36_5
  • Side note, possibly a separate issue: browsers have dropped HPKP, and current guidance
    for X-XSS-Protection is 0 or omitting it. The help texts could mention this.
主要言語
PHP
スター
1.2k
フォーク
926
平均マージ
1日 10時間
マージ済み PR(30日)
25

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

opnsense/plugins のほかの issue

opnsense/plugins の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。