Skip to content

Commit 0a9b478

Browse files
committed
handbook/security: document mdo(1) for privilege escalation
Add a new section covering mdo(1), the built-in FreeBSD utility for executing commands as a different user via the mac_do(4) MAC module. The section covers loading the kernel module, configuring rules via sysctl, and basic usage examples. mdo requires no package installation unlike sudo or doas, and is part of the base system's MAC framework. PR: 293535
1 parent 92fca98 commit 0a9b478

1 file changed

Lines changed: 56 additions & 1 deletion

File tree

  • documentation/content/en/books/handbook/security

documentation/content/en/books/handbook/security/_index.adoc

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ part: Part III. System Administration
44
prev: books/handbook/boot
55
next: books/handbook/jails
66
description: Hundreds of standard practices have been authored about how to secure systems and networks, and as a user of FreeBSD, understanding how to protect against attacks and intruders is a must
7-
tags: ["security", "TCP Wrappers", "Kerberos", "OpenSSL", "OpenSSH", "ACL", "NFSv4 ACLs", "advisories", "sudo", "doas", "capsicum", "monitoring"]
7+
tags: ["security", "TCP Wrappers", "Kerberos", "OpenSSL", "OpenSSH", "ACL", "NFSv4 ACLs", "advisories", "sudo", "doas", "mdo", "capsicum", "monitoring"]
88
showBookMenu: true
99
weight: 20
1010
params:
@@ -410,6 +410,61 @@ $ doas vi /etc/rc.conf
410410

411411
For more configuration examples, please read man:doas.conf[5].
412412

413+
[[security-mdo]]
414+
=== Shared Administration with mdo
415+
416+
man:mdo[1] is a built-in FreeBSD utility for executing commands as a different user.
417+
Unlike man:sudo[8] and man:doas[1], mdo requires no additional package installation.
418+
It uses the man:mac_do[4] kernel module, which is part of the FreeBSD Mandatory Access Control (MAC) framework.
419+
420+
To use mdo, first load the man:mac_do[4] kernel module:
421+
422+
[source,shell]
423+
....
424+
# kldload mac_do
425+
....
426+
427+
To load the module at boot, add it to [.filename]#/etc/rc.conf#:
428+
429+
[source,shell]
430+
....
431+
kld_list="${kld_list} mac_do"
432+
....
433+
434+
Rules are configured via man:sysctl[8].
435+
Add the following to [.filename]#/etc/sysctl.conf# to enable mdo and define transition rules:
436+
437+
[.programlisting]
438+
....
439+
security.mac.do.enabled=1
440+
security.mac.do.rules=gid=0>uid=0
441+
....
442+
443+
The rule `gid=0>uid=0` allows members of the `wheel` group (GID 0) to execute commands as `root` (UID 0).
444+
Multiple rules are separated by semicolons.
445+
For example, to also allow user with UID 1000 to run commands as the `www` user:
446+
447+
[.programlisting]
448+
....
449+
security.mac.do.rules=gid=0>uid=0;uid=1000>uid=80,gid=80
450+
....
451+
452+
After configuration, commands can be executed with elevated privileges:
453+
454+
[source,shell]
455+
....
456+
$ mdo vi /etc/rc.conf
457+
....
458+
459+
To start an interactive root shell:
460+
461+
[source,shell]
462+
....
463+
$ mdo -i
464+
....
465+
466+
For more information, see man:mdo[1] and man:mac_do[4].
467+
413468
[[security-ids]]
414469
== Intrusion Detection System (IDS)
415470

0 commit comments

Comments
 (0)