opnsense / src

OPNsense operating system on top of FreeBSD
https://opnsense.org/
Other
351 stars 149 forks source link

Enabling syncookies breaks traffic that both originates and terminates on the firewall #206

Open no-usernames-left opened 3 months ago

no-usernames-left commented 3 months ago

Important notices

Describe the bug Enabling syncookies breaks traffic both originating and terminating on the firewall (such as when you put Caddy in front of the OPNsense web GUI).

To Reproduce

  1. Set up Caddy to proxy the OPNsense web GUI according to the tutorial
  2. SSH into the firewall
  3. openssl s_client -connect 127.0.0.1:443 (or :8443; both are affected, showing it's neither a Caddy nor a lighttpd issue)
  4. See your certificate and be happy
  5. Firewall - Settings - Advanced, change Enable syncookies from never (default) to always, click Save
  6. openssl s_client -connect 127.0.0.1:443 (or :8443)
  7. After connection and a delay of many seconds, see write:errno=54 and be sad

Expected behavior Not this.

Additional context Discovered while troubleshooting this issue.

Environment OPNsense Business 24.4_8 (amd64) os-caddy 1.5.4_1

AdSchellevis commented 3 months ago

I'm not sure this is supposed to work to be honest, local traffic should already have syncookies enabled (net.inet.tcp.syncookies), which might make these two options incompatible. Since pf's syncookies don't have any toggles, it might not be possible to exclude part of the traffic for this specific protection.

no-usernames-left commented 3 months ago

That sounds like a bug to me. It took hours to troubleshoot why Caddy was working fine for all subdomains except OPNsense's web GUI.

Monviech commented 3 months ago

I tried it too and it really happens.

I would have never thought it would be this option. Very obscure. Subscribing to this here.

If its not something that can be fixed I'll add a hint to the docs.

AdSchellevis commented 3 months ago

If it's a bug or a feature really depends on the specifications, which aren't very detailed on this particular subject, I'll move this to src and label it upstream.

At a first glance FreeBSD 14.1 behaves the same in these matters. If pf's syncookies are the right tool to use when the termination point of the traffic is the firewall itself might be a valid question as well (since the tcp stack itself does offer syncookie support anyway). A non stateful inbound rule to prevent state table depletion for a service that terminates on the box might even be more logical choice anyway.

fichtner commented 2 months ago

FWIW, my first thought was upstream bug here as well.

muratbalaban43 commented 1 month ago

Let's check with the upstream and see if they can fix it.