@@ -311,6 +311,45 @@ syntax, for example:
311311.Pp
312312Fragments are not selectable since NPF always reassembles packets
313313before further processing.
314+ .Ss User/group ID filtering
315+ .Pp
316+ NPF allows filtering by user or group identity. Packet filtering by user or group
317+ controls data packet flows based on the user or group identity of the process
318+ that generated the traffic, or is waiting to receive traffic,
319+ rather than just traditional parameters like IP address, port number, and protocol.
320+ .Pp
321+ There are many situations where this is useful:
322+ .Bl -bullet -hang
323+ .It Finer-grained access control
324+ One can allow specific destinations to be accessed only by certain users
325+ or groups.
326+ .It Application level security
327+ Two processes are using a specific port, but only one should be allowed to
328+ access packets originating from a particular host.
329+ .It Improves isolation in multi-tenant systems
330+ Prevent an untrusted user from making any network connections
331+ .It Security hardening and containment
332+ A user application that has been exploited can be prevented from making
333+ network connections to a command-and-control server.
334+ .It Compliance and policy enforcement
335+ Can restrict access to particular networks to network administrators only.
336+ .El
337+ This filtering process can be achieved by passing the user or group ID on the rule.
338+ .Pp
339+ .Dl pass out from all user jack group < 1000
340+ .Pp
341+ The above rule only allows sockets of processes owned by user jack
342+ and belonging to a group with an id value of less than 1000.
343+ .Pp
344+ .Dl block in from all user > 100 group wheel
345+ .Pp
346+ The above rule prevents all listening sockets bound by processes owned by any user
347+ with the id value greater than 100 and belonging to the wheel group.
348+ .Pp
349+ A rule can have either a user ID or group ID set. If both are set, both must
350+ agree to be a match to the socket involved in communication.
351+ Numbers or names can be used for the identification of the user or group as they
352+ still resolve to a numeric ID of the user or group.
314353.Ss Stateful
315354NPF supports stateful packet inspection which can be used to bypass
316355unnecessary rule processing as well as to complement NAT.
@@ -620,11 +659,19 @@ proto-opts = "flags" tcp-flags [ "/" tcp-flag-mask ] |
620659 "icmp-type" type [ "code" icmp-code ]
621660proto = "proto" protocol [ proto-opts ]
622661
623- filt-opts = "from" filt-addr [ port-opts ] "to" filt-addr [ port-opts ]
662+ filt-opts = "from" filt-addr [ port-opts ] "to" filt-addr [ port-opts ] user_id group_id
624663filt-addr = [ "!" ] [ interface | addr-mask | table-id | "any" ]
625664
626665port-opts = "port" ( port-num | port-from "-" port-to | var-name )
627666addr-mask = addr [ "/" mask ]
667+
668+ user_id = "user" id_items
669+ group_id = "group" id_items
670+
671+ id_items = [id] | [op_unary id] | [id op_binary id]
672+
673+ op_unary = ["="] | ["!="] | ["<="] | [">="] | [">"] | ["<"]
674+ op_binary = ["<>"] | ["><"]
628675.Ed
629676.\" -----
630677.Sh FILES
0 commit comments