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