-
Notifications
You must be signed in to change notification settings - Fork 807
security/acme-client: fix IPv6 support #5281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| # FreeBSD! | ||
| server.event-handler = "freebsd-kqueue" | ||
| server.network-backend = "writev" | ||
| #server.use-ipv6 = "enable" | ||
| server.use-ipv6 = "{{ 'enable' if OPNsense.Interfaces.settings.disableipv6 == "0" else 'disable' }}" | ||
|
|
||
| # modules to load | ||
| server.modules = ( "mod_access", "mod_expire", "mod_deflate", "mod_redirect", | ||
|
|
@@ -60,13 +60,10 @@ mimetype.assign = ( | |
| url.access-deny = ( "~", ".inc" ) | ||
|
|
||
| # bind to port | ||
| server.bind = "127.0.0.1" | ||
| server.port = {{OPNsense.AcmeClient.settings.challengePort}} | ||
| $SERVER["socket"] == "127.0.0.1:{{OPNsense.AcmeClient.settings.challengePort}}" { } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you removing this? It's there for a reason.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that this was added to have the web server only bind to localhost (::1 and 127.0.0.1). However, as stated in the commit message, we cannot do this for IPv6 because ::1 is a scope that doesn't allow traffic coming from another interface. Removing this reverts binding to the default behavior, namely, binding to all interfaces. I could try to only bind to specific addresses but this seems a bit pointless. It would require to generate this config for every Challenge Type. Addresses my differ between them. I also looked at some other services running on OPNsense and binding to all interfaces and then using the firewall to restrict access seems the norm:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually found some issues with this while testing with IPv6 disabled and I ended up readding explicit binding for IPv4 and IPv6.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This would represent a fundamental change in behavior. Initially, the Acme web service was designed to run only on localhost and to be exposed solely via (temporary) port redirection or through internal HTTP requests (e.g. via HAProxy). You are now proposing to run this service on all interfaces, which could potentially conflict with other services running on the OPNsense system and might accidentally (and permanently) expose this service to the public. I strongly oppose this change in behavior. Please ensure that the service binds only to 127.0.0.1 for IPv4 and propose a solution for IPv6.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how to respond here. Redirecting to ::1 is obviously not a possibility, it does not work. So, the one alternative here I can think of is to officially not support IPv6, at least not when using the ACME web service. The web server running is running on dedicated port and traffic is redirected there. I find it unlikely that it would conflict with some other service listening on a different IP/interface that just happens to use the same (probably random) port. Even if, such a service would likely conflict anyway, because it would want to listen to localhost too. Arguably, it's easier to expose the service by accident, as you mentioned. However, all critical services are listening on all interfaces, including the web interface and SSH. If you don't take care of restricting access properly, you probably have bigger problems than this web server.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Why not introduce a new field and let the user specify the IPv6 address? Or use the IPv6 address of the selected interface?
I disagree. You just cannot know this and there are ways to circumvent this potential issue.
We are talking about changing the behaviour of an existing service that was supposedly already secured by the user/admin. So that's definitely something we must avoid. It's violating POLA. Please let's just move on from this discussion and let's work on a solution. |
||
|
|
||
| {% if helpers.exists('system.ipv6allow') and system.ipv6allow|default("0") == "1" %} | ||
| # IPv6 | ||
| $SERVER["socket"] == "[::1]:{{OPNsense.AcmeClient.settings.challengePort}}" { } | ||
| $SERVER["socket"] == "0.0.0.0:{{OPNsense.AcmeClient.settings.challengePort}}" { } | ||
| {% if OPNsense.Interfaces.settings.disableipv6 == "1" %} | ||
| $SERVER["socket"] == "[::]:{{OPNsense.AcmeClient.settings.challengePort}}" { } | ||
| {% endif %} | ||
|
|
||
| # to help the rc.scripts | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you hardcoding
wanhere? The interface is specified in$this->config->tlsalpn_acme_interface. It's not always wan, the IP might be configured on a different interface.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redirecting to ::1 isn't possible, as described in the commit message. This is simply an attempt find any address in the right scope. Any address really, on any interface, that belongs to this host. I could use tlsalpn_acme_interface but, to my knowledge, there is no guarantee that this interface is set.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use
$this->config->tlsalpn_acme_interface. This way it remains configurable. Hard-coding a specific interface name is not going to work. You may log an error iftlsalpn_acme_interfaceis empty.And also update the "found IPv6 on WAN interface" log messages accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
$this->config->tlsalpn_acme_interfaceis set, it likely has a suitable (=in the right scope) IPv6 address, which is good. How do you feel about checking if$this->config->tlsalpn_acme_interfaceis set, and if not, as last resort, just trywan. I do feel like a lot of setups havewanand we don't lose anything by trying that interface.Again, the right solution here is probably to go through all interfaces and find suitable IPv6 address but I feel like that will take me too much time to figure out and this is a solution which should already work for the majority of cases. We can always improve this later, if I or someone else finds time.