opnsense-src/sys/security
Olivier Certner 89958992b6
MAC/do: Check executable path from the current jail's root
Contrary to my initial belief, vn_fullpath() does return a vnode's path
from the current chroot, and not from the global root (which would have
been a bug also, but without security consequences).  This enables
a "confused deputy"-like scenario where a chroot(2) can change which
executable can be authorized by MAC/do, which is even more problematic
for unprivileged chroot(2).

This was found by re-examining the code following two close events:
1. Shawn Webb sent a mail to freebsd-hackers@ on 08/05 saying that in
   HardenedBSD they had added a check on P2_NO_NEW_PRIVS (in
   mac_do_priv_grant()), which I responded to on 08/20 saying that
   P2_NO_NEW_PRIVS was not necessary for mac_do(4), with a correct
   reasoning but based on the wrong above-mentioned assumption about
   vn_fullpath().
2. I reviewed some code by Kushagra Srivastava (GSoC 2025 student
   working on mac_do(4)/mdo(1)) adding the ability to specify which
   executables can spawn processes that mac_do(4) may decide to
   authorize (others are simply ignored), which currently is hardcoded
   to '/usr/bin/mdo'.

MFC after:      3 days
Event:          EuroBSDCon 2025
Sponsored by:   The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D52758

(cherry picked from commit 9f269a0a771aff4f0a735211907a52c52fc0661b)
2025-10-02 18:57:19 +02:00
..
audit jail: Optionally allow audit session state to be configured in a jail 2025-09-30 09:43:08 +00:00
mac mac: Remove uses of DEBUG_VFS_LOCKS 2025-08-03 21:52:23 +00:00
mac_biba MAC: mac_biba, mac_lomac: Fix setting loader tunables 2025-02-09 23:53:29 +08:00
mac_bsdextended MAC/bsdextended: Restore matching subjects' effective GID 2025-09-23 14:02:43 +02:00
mac_ddb
mac_do MAC/do: Check executable path from the current jail's root 2025-10-02 18:57:19 +02:00
mac_grantbylabel grantbylabel_syscall check p_textvp != NULL 2025-05-16 15:19:06 -07:00
mac_ifoff MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_ipacl MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_lomac MAC: mac_biba, mac_lomac: Fix setting loader tunables 2025-02-09 23:53:29 +08:00
mac_mls MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_none
mac_ntpd MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_partition MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_pimd MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_portacl MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_priority MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_seeotheruids MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_stub New setcred() system call and associated MAC hooks 2024-12-16 15:42:39 +01:00
mac_test New setcred() system call and associated MAC hooks 2024-12-16 15:42:39 +01:00
mac_veriexec MAC: mac_policy.h: Declare common MAC sysctl and jail parameters' nodes 2024-12-16 15:42:28 +01:00
mac_veriexec_parser mac_veriexec_parser: Fix open_file error handling 2024-09-20 09:22:56 -06:00