@@ -366,7 +366,9 @@ parameters.
366
366
367
367
Chdir_Spec ::= \[aq ] CWD=directory\[aq ]
368
368
369
- Tag_Spec ::= (\[aq ] PASSWD:\[aq ] | \[aq ] NOPASSWD:\[aq ] | \[aq ] SETENV:\[aq ] | \[aq ] NOSETENV:\[aq ] )
369
+ Tag_Spec ::= (\[aq ] PASSWD:\[aq ] | \[aq ] NOPASSWD:\[aq ] |
370
+ \[aq ] SETENV:\[aq ] | \[aq ] NOSETENV:\[aq ]
371
+ \[aq ] EXEC:\[aq ] | \[aq ] NOEXEC\[aq ] )
370
372
371
373
AppArmor_Spec ::= \[aq ] APPARMOR_PROFILE=profile\[aq ]
372
374
.EE
@@ -493,6 +495,19 @@ NOSETENV.
493
495
Once a tag is set on a Cmnd, subsequent Cmnds in the Cmnd_Spec_List,
494
496
inherit the tag unless it is overridden by the opposite tag (in other
495
497
words, PASSWD overrides NOPASSWD and NOSETENV overrides SETENV).
498
+ .SS EXEC and NOEXEC
499
+ On Linux systems, the NOEXEC tag can be used to prevent an executable
500
+ from running further commands itself.
501
+ .PP
502
+ In the following example, user aaron may run /usr/bin/more and
503
+ /usr/bin/vi but shell escapes will be disabled.
504
+ .IP
505
+ .EX
506
+ aaron shanty = NOEXEC: /usr/bin/more, /usr/bin/vi
507
+ .EE
508
+ .PP
509
+ See the Preventing shell escapes section below for more details on how
510
+ NOEXEC works and whether or not it suits your purpose.
496
511
.SS PASSWD and NOPASSWD
497
512
By default, sudo requires that a user authenticate before running a
498
513
command.
@@ -697,6 +712,16 @@ A list of all supported Defaults parameters, grouped by type, are listed
697
712
below.
698
713
.SS Boolean Flags:
699
714
.IP \[bu ] 2
715
+ noexec
716
+ .RS 2
717
+ .PP
718
+ If set, all commands run via sudo will behave as if the NOEXEC tag has
719
+ been set, unless overridden by an EXEC tag.
720
+ See the description of EXEC and NOEXEC as well as the Preventing shell
721
+ escapes section at the end of this manual.
722
+ This flag is off by default.
723
+ .RE
724
+ .IP \[bu ] 2
700
725
env_editor
701
726
.RS 2
702
727
.PP
@@ -937,10 +962,23 @@ Common programs that permit shell escapes include shells (obviously),
937
962
editors, paginators (such as \f[I] less \f[ R ] ), mail, and terminal
938
963
programs.
939
964
.PP
940
- sudo\- rs currently doesn\[cq ] t offer Todd Miller\[cq ] s sudo\[cq ] s
941
- protection mechanisms; i.e.\ be very careful that when a user is not
942
- supposed to receive shell access, that the commands that they have
943
- access to does not allow escaping to the shell.
965
+ On Linux, sudo\- rs has sudo\[cq ] s \f[B] noexec* functionality, based on a
966
+ seccomp() filter.
967
+ Programs that are run in \f[ R ] noexec** mode cannot run other programs.
968
+ The implementation in sudo\- rs is different than in Todd Miller\[cq ] s
969
+ sudo, and should also work on statically linked binaries.
970
+ .PP
971
+ Note that restricting shell escapes is not a panacea.
972
+ Programs running as root are still capable of many potentially hazardous
973
+ operations (such as changing or overwriting files) that could lead to
974
+ unintended privilege escalation.
975
+ NOEXEC is also not a protection against malicious programs.
976
+ It doesn\[cq ] t prevent mapping memory as executable, nor does it protect
977
+ against future syscalls that can do an exec() like the proposed
978
+ \f[CR] io_uring \f[ R ] exec feature in Linux.
979
+ And it also doesn\[cq ] t protect against honest programs that
980
+ intentionally or not allow the user to write to /proc/self/mem for the
981
+ same reasons as that it doesn\[cq ] t protect against malicious programs.
944
982
.SS Timestamp file checks
945
983
sudo\- rs will check the ownership of its timestamp directory
946
984
(/run/sudo/ts by default) and ignore the directory\[cq ] s contents if it
0 commit comments