Project

General

Profile

Actions

Bug #8686

open

IPsec VTI: Assigned interface firewall rules are never parsed

Added by Steve Wheeler over 5 years ago. Updated 8 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
IPsec
Target version:
-
Start date:
07/24/2018
Due date:
% Done:

0%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
2.4.4
Affected Architecture:
All

Description

Traffic entering an assigned VTI interface never hits firewall rules on that specific interface tab even if they are present.
Traffic must still be passed on the main IPsec tab.
This is potentially confusing, it's not the expected behavior that other interface types exhibit.


Files

ipsec_filtermode.diff (6.21 KB) ipsec_filtermode.diff Jim Pingle, 02/04/2021 01:15 PM

Related issues

Related to Bug #4479: Firewall rules won't match GRE interface after applying IPSEC transport encryption on GRE tunnelNewLuiz Souza02/27/2015

Actions
Actions #1

Updated by Jim Pingle over 5 years ago

  • Subject changed from IPSec VTI: Assigned interface firewall rules are never parsed to IPsec VTI: Assigned interface firewall rules are never parsed
  • Description updated (diff)
  • Assignee deleted (Jim Pingle)

Issue #8685 will work around this for now, but we can use this issue to track the longer-term problem of how these rules interact. We may have to wait for FreeBSD to solve this one since it appears to be an issue in how pf and if_ipsec interact, and how traffic shows up both on enc0 and the specific ipsecXXXX interface.

Actions #2

Updated by Jim Pingle almost 4 years ago

Re-tested this since we have a new base OS on 2.5.0. Unfortunately, this still behaves the same way on 12.1-STABLE:

Adding a pf rule on a VTI interface, it does not function as expected. With no rules on enc0, and a pass all rule on ipsec4000, no traffic is passed.

@145(1528159274) pass in quick on ipsec4000 reply-to (ipsec4000 10.6.106.2) inet all flags S/SA keep state label "USER_RULE: VTI Test Rule" 
  [ Evaluations: 16050     Packets: 0         Bytes: 0           States: 0     ]
  [ Inserted: pid 21034 State Creations: 0     ]

Note that the evaluations counter increases, but it never matches.

tcpdump does not show any packets arriving on the ipsec4000 interface with this rule present.

If you add a rule to enc0 to pass the traffic, it works and then traffic also appears in tcpdump captures on ipsec4000 as it flows.

Packets are always visible in tcpdump on enc0.

Actions #3

Updated by Ari Suutari almost 4 years ago

Is this related:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=232522

filtertunnel sysctls seem to be 0 in pfsense.

Actions #4

Updated by Jim Pingle almost 4 years ago

That is certainly worth testing but we've had problems flipping that in the past (See #2993, #2636, and several forum threads) so it may not be a general solution.

If it works, we can document it at least. But we'd also have to check for regressions in behavior of tunneled (non-VTI) IPsec, transport mode IPsec, and general IPsec throughput/performance.

Actions #5

Updated by Jim Pingle almost 4 years ago

It doesn't appear to be related. Setting that sysctl to 1, the traffic still arrives on enc0 and is blocked by pf inbound on enc0.

Actions #6

Updated by Jim Pingle over 3 years ago

I thought it was noted here but I don't see it. There is another FreeBSD issue at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248474 in which they recommend disabling pfil for if_enc and setting filtertunnel similar to the above:

net.enc.out.ipsec_filter_mask=0
net.enc.in.ipsec_filter_mask=0
net.inet.ipsec.filtertunnel=1
net.inet6.ipsec6.filtertunnel=1

However, that cripples policy-based tunnels since there would now be no way to filter their traffic.

There is still no acceptable solution that allows both to work at once.

Actions #7

Updated by Jim Pingle about 3 years ago

In addition to the above, the BPF mask also needs changed.

The complete set of required sysctl values are:

sysctl net.inet.ipsec.filtertunnel=1
sysctl net.inet6.ipsec6.filtertunnel=1
sysctl net.enc.out.ipsec_bpf_mask=0
sysctl net.enc.in.ipsec_bpf_mask=0
sysctl net.enc.out.ipsec_filter_mask=0
sysctl net.enc.in.ipsec_filter_mask=0

And then change source:src/etc/inc/filter.inc#L101 to:

$filter_interface_blacklist = array();

With that in place, rules on assigned VTI interface tabs are respected and rules on the IPsec tab (enc0) are ignored. Since it's default deny, no traffic on enc0 will pass. (Meaning that policy-based tunnels cannot pass traffic no matter what, only assigned VTI w/rules on tabs can)

Actions #8

Updated by Jim Pingle about 3 years ago

I made patch (attached) that adds a GUI option to toggle between the two behaviors: Filtering on enc0 (tunnel+vti), and filtering on the assigned VTI interfaces (but blocks all tunnel mode traffic). With the option set, firewall rule tabs are visible for the assigned VTI interfaces, the IPsec tab is hidden. NAT rules on VTI interfaces work.

It works, but obviously it's a big trade-off.

It's better than not having a choice, though, at least until a solution can be found in FreeBSD.

Actions #9

Updated by Jim Pingle about 3 years ago

I'm moving the option I mentioned above to a separate issue: #11395

This can remain open for the longer term question of whether or not it is possible in FreeBSD to have both behaviors at the same time, rather than forcing the user to choose.

Actions #10

Updated by Jim Pingle over 2 years ago

  • Related to Bug #4479: Firewall rules won't match GRE interface after applying IPSEC transport encryption on GRE tunnel added
Actions #11

Updated by beermount beermount 8 months ago

Could the ipsec interface be enabled for inclusion to an interface group when the advanced ipsec filter mode is set to "Filter IPsec VTI and Transport on assigned interfaces, block all tunnel mode traffic"?

The reason would be to easily apply all filter rules for a typical hub-spoke setup.

Actions

Also available in: Atom PDF