os-nginx: add X-Frame-Options, Permissions-Policy and Server header removal
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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-OptionsPermissions-Policy- removing the
Serverresponse header (server_tokens offonly hides the version;
nginx still sendsServer: nginx)
The only way to achieve this today is custom files in /usr/local/etc/nginx/http_post/.
That has two drawbacks:
add_headerathttplevel 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 needsmore_set_headers/more_clear_headers
(headers-more module), which is not obvious to most users.- 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:
-
X-Frame-Options –
OptionFieldin the Security Header model
Values: (not set),DENY,SAMEORIGIN
Rendered as:
proxy_hide_header X-Frame-Options;
add_header X-Frame-Options "" always; -
Permissions-Policy –
TextFieldwith strict mask validation in the Security
Header model
Onlydirective=allowlistpairs 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; -
Remove
Serverresponse header – global checkbox in the HTTP settings
(next to the existing option that rendersserver_tokens off;)
Since the plugin already loadsngx_http_headers_more_filter_module, this could be
rendered in thehttpblock 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 inconfig.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
forX-XSS-Protectionis0or omitting it. The help texts could mention this.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 926
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 25
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from opnsense/plugins
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
opnsense/plugins#5976 · 1 comment ·
Maintainers usually reply within 1 day
-
net/haproxy: IPv6 literal in real server "Source address" generates an invalid `source` directiveOpenincomplete
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
opnsense/plugins#5973 · 1 comment ·
Maintainers usually reply within 1 day
-
[dns/ddclient] Support hiding unused standard fields per service (optional_hiding)Possibly taken @bringha1 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
q-feeds-connector: "error in configd communication" every update when the Unbound DNSBL rebuild takes longer than 120sPossibly taken @mhatipog claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
All issues in opnsense/plugins
Similar issues
-
15.0
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
open-telemetry/opentelemetry-php-distro#176 ·
Maintainers usually reply within 2 days
-
No Code Attached Yet
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
joomla/joomla-cms#48941 ·
Maintainers usually reply within 1 day
-
needs-triage Platform(Default)
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
bug new
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
moodle-an-hochschulen/moodle-theme_boost_union#1500 ·
Maintainers usually reply within 1 day