Regression #16672
closedFirewall rules matching and tagging across distinct anchors are ignored by subsequent tagged rule
100%
Description
Starting at pfSense Plus 25.11 our team noticed a bug occurring on x86 hardware such as the Netgate 4200/6100.
I've tested on Netgate 2100 (aarch64) and Netgate 3100 (armv7) and the issue does not occur there.
The bug gets triggered when two same or similar match rules (attaching a tag) under two distinct anchors (depth 1 and 2 tested) match a packet. In this scenario any remaining rules that would match such packet by tag get ignored and a default rule applies.
Basic Reproduction in pf¶
block in inet all anchor "first" { match from <ip_address_or_table> to <ip_address_or_table> tag "allow" } anchor "second" { match from <ip_address_or_table> to <ip_address_or_table> tag "allow" } pass in quick on <interface> inet from any to any tagged "allow" keep state
Meanwhile this works:
block in inet all
anchor "firstandonly" {
match from <ip_address_or_table> to <ip_address_or_table> tag "allow"
}
pass in quick on <interface> inet from any to any tagged "allow" keep state
Steps to Reproduce on pfSense¶
- Delete all firewall rules on the LAN interface, and create a single allow any rule that allows traffic tagged with
example_tag. - Run the attached script
matching-anchor-bug.shon the pfSense appliance. It creates the test match rules under theuserrules/*anchor. - From an endpoint on the LAN, try to ping
208.123.73.78. - Notice in
/var/log/filter.logthat the match rules get hit, but the pass rule you created in the LAN interface does not. - Now re-run the script as follows:
./matching-anchor-bug.sh single-anchor - Notice how the ping immediately starts to be passed as it's now hitting your pass rule.
Files
Updated by Arthur Wiebe about 2 months ago
It appears this may be resolved in freebsd as of this commit https://github.com/freebsd/freebsd-src/commit/4616481212302b5d875cfc7a00766af017318f7f
Updated by Jim Pingle about 1 month ago
- Project changed from pfSense Plus to pfSense
- Subject changed from pf: Rules matching and tagging across distinct anchors are ignored by subsequent tagged rule to Firewall rules matching and tagging across distinct anchors are ignored by subsequent tagged rule
- Category changed from packetfilter to Rules / NAT
- Assignee set to Kristof Provost
- Target version set to 2.9.0
- Affected Plus Version deleted (
25.11.1) - Plus Target Version set to 26.03
That should get picked up in our next upstream src merge here shortly.
Updated by Marcos M about 1 month ago
- Status changed from New to Feedback
- % Done changed from 0 to 100
- Affected Version set to 2.9.0
- Affected Architecture All added
- Affected Architecture deleted (
4100, 4200, 6100, amd64)
Updated by Georgiy Tyutyunnik 17 days ago
- Status changed from Feedback to Resolved
fixed
tested on:
26.03-BETA (amd64)
built on Fri Feb 27 6:00:00 UTC 2026
FreeBSD 16.0-CURRENT
can't reproduce using the provided sequence anymore