]> granicus.if.org Git - sudo/commitdiff
Make sudoedit_checkdir the default and update the documentation accordingly.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 19 Jan 2016 21:16:25 +0000 (14:16 -0700)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Tue, 19 Jan 2016 21:16:25 +0000 (14:16 -0700)
doc/sudo.cat
doc/sudo.man.in
doc/sudo.mdoc.in
doc/sudoers.cat
doc/sudoers.man.in
doc/sudoers.mdoc.in
plugins/sudoers/defaults.c
src/sudo.c

index 90b061b8db7cea9b57bde597237ed5f3464d8072..27bdd5ce4c504e4cc7a9c5b1cb0ebc51f1636d4e 100644 (file)
@@ -126,12 +126,23 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
                        copied back to their original location and the
                        temporary versions are removed.
 
-                 Unless explicitly allowed by the security policy, symbolic
-                 links will not be opened.  This helps prevent the editing of
-                 unauthorized files when the file is located in a user-
-                 writable directory.  Versions of s\bsu\bud\bdo\bo prior to 1.8.15 do not
-                 have this restriction.  Users are never allowed to edit
-                 device special files.
+                 To help prevent the editing of unauthorized files, the
+                 following restrictions are enforced unless explicitly allowed
+                 by the security policy:
+
+                  +\b+\bo\bo   Symbolic links may not be edited (version 1.8.15 and
+                      higher).
+
+                  +\b+\bo\bo   Symbolic links along the path to be edited are not
+                      followed when the parent directory is writable by the
+                      invoking user unless that user is root (version 1.8.16
+                      and higher).
+
+                  +\b+\bo\bo   Files located in a directory that is writable by the
+                      invoking user may not be edited unless that user is root
+                      (version 1.8.16 and higher).
+
+                 Users are never allowed to edit device special files.
 
                  If the specified file does not exist, it will be created.
                  Note that unlike most commands run by _\bs_\bu_\bd_\bo, the editor is run
@@ -440,14 +451,7 @@ S\bSE\bEC\bCU\bUR\bRI\bIT\bTY\bY N\bNO\bOT\bTE\bES\bS
      Users should _\bn_\be_\bv_\be_\br be granted s\bsu\bud\bdo\bo privileges to execute files that are
      writable by the user or that reside in a directory that is writable by
      the user.  If the user can modify or replace the command there is no way
-     to limit what additional commands they can run.  Likewise, users should
-     _\bn_\be_\bv_\be_\br be granted s\bsu\bud\bdo\boe\bed\bdi\bit\bt permission to edit a file that resides in a
-     directory the user has write access to.  A user with directory write
-     access could replace the legitimate file with a link to some other,
-     arbitrary, file.  Starting with version 1.8.15, s\bsu\bud\bdo\boe\bed\bdi\bit\bt will refuse to
-     open a symbolic link unless the security policy explicitly permits it.
-     However, it is still possible to create a hard link if the directory is
-     writable and the link target resides on the same file system.
+     to limit what additional commands they can run.
 
      Please note that s\bsu\bud\bdo\bo will normally only log the command it explicitly
      runs.  If a user runs a command such as sudo su or sudo sh, subsequent
@@ -617,4 +621,4 @@ D\bDI\bIS\bSC\bCL\bLA\bAI\bIM\bME\bER\bR
      file distributed with s\bsu\bud\bdo\bo or https://www.sudo.ws/license.html for
      complete details.
 
-Sudo 1.8.16                    November 20, 2015                   Sudo 1.8.16
+Sudo 1.8.16                    January 19, 2016                    Sudo 1.8.16
index 6350b0566b36ba393d54834d18995dcb965b047c..0cc566a2ddace337fd3e9ae97e8b3d65188ec7b1 100644 (file)
@@ -1,7 +1,7 @@
 .\" DO NOT EDIT THIS FILE, IT IS NOT THE MASTER!
 .\" IT IS GENERATED AUTOMATICALLY FROM sudo.mdoc.in
 .\"
-.\" Copyright (c) 1994-1996, 1998-2005, 2007-2015
+.\" Copyright (c) 1994-1996, 1998-2005, 2007-2016
 .\"    Todd C. Miller <Todd.Miller@courtesan.com>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
@@ -21,7 +21,7 @@
 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
 .\"
-.TH "SUDO" "8" "November 20, 2015" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
+.TH "SUDO" "8" "January 19, 2016" "Sudo @PACKAGE_VERSION@" "System Manager's Manual"
 .nh
 .if n .ad l
 .SH "NAME"
@@ -296,13 +296,23 @@ their original location and the temporary versions are removed.
 .RE
 .RS 12n
 .sp
-Unless explicitly allowed by the security policy, symbolic links
-will not be opened.
-This helps prevent the editing of unauthorized files when the file
-is located in a user-writable directory.
-Versions of
-\fBsudo\fR
-prior to 1.8.15 do not have this restriction.
+To help prevent the editing of unauthorized files, the following
+restrictions are enforced unless explicitly allowed by the security policy:
+.RS 16n
+.TP 4n
+\fB\(bu\fR
+Symbolic links may not be edited (version 1.8.15 and higher).
+.TP 4n
+\fB\(bu\fR
+Symbolic links along the path to be edited are not followed when the
+parent directory is writable by the invoking user unless that user
+is root (version 1.8.16 and higher).
+.TP 4n
+\fB\(bu\fR
+Files located in a directory that is writable by the invoking user may
+not be edited unless that user is root (version 1.8.16 and higher).
+.RE
+.sp
 Users are never allowed to edit device special files.
 .sp
 If the specified file does not exist, it will be created.
@@ -883,20 +893,6 @@ privileges to execute files that are writable by the user or
 that reside in a directory that is writable by the user.
 If the user can modify or replace the command there is no way
 to limit what additional commands they can run.
-Likewise, users should
-\fInever\fR
-be granted
-\fBsudoedit\fR
-permission to edit a file that resides in a directory the user has
-write access to.
-A user with directory write access could replace the legitimate
-file with a link to some other, arbitrary, file.
-Starting with version 1.8.15,
-\fBsudoedit\fR
-will refuse to open a symbolic link unless the security policy
-explicitly permits it.
-However, it is still possible to create a hard link if the directory
-is writable and the link target resides on the same file system.
 .PP
 Please note that
 \fBsudo\fR
index f2cb8d9fe71e00ec88102ae72b626861be89c599..7f4a7fa39e612a275d6ab86dabef9a45bf549311 100644 (file)
@@ -1,5 +1,5 @@
 .\"
-.\" Copyright (c) 1994-1996, 1998-2005, 2007-2015
+.\" Copyright (c) 1994-1996, 1998-2005, 2007-2016
 .\"    Todd C. Miller <Todd.Miller@courtesan.com>
 .\"
 .\" Permission to use, copy, modify, and distribute this software for any
@@ -19,7 +19,7 @@
 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
 .\"
-.Dd November 20, 2015
+.Dd January 19, 2016
 .Dt SUDO @mansectsu@
 .Os Sudo @PACKAGE_VERSION@
 .Sh NAME
@@ -269,13 +269,20 @@ If they have been modified, the temporary files are copied back to
 their original location and the temporary versions are removed.
 .El
 .Pp
-Unless explicitly allowed by the security policy, symbolic links
-will not be opened.
-This helps prevent the editing of unauthorized files when the file
-is located in a user-writable directory.
-Versions of
-.Nm
-prior to 1.8.15 do not have this restriction.
+To help prevent the editing of unauthorized files, the following
+restrictions are enforced unless explicitly allowed by the security policy:
+.Bl -bullet -offset 4
+.It
+Symbolic links may not be edited (version 1.8.15 and higher).
+.It
+Symbolic links along the path to be edited are not followed when the
+parent directory is writable by the invoking user unless that user
+is root (version 1.8.16 and higher).
+.It
+Files located in a directory that is writable by the invoking user may
+not be edited unless that user is root (version 1.8.16 and higher).
+.El
+.Pp
 Users are never allowed to edit device special files.
 .Pp
 If the specified file does not exist, it will be created.
@@ -818,20 +825,6 @@ privileges to execute files that are writable by the user or
 that reside in a directory that is writable by the user.
 If the user can modify or replace the command there is no way
 to limit what additional commands they can run.
-Likewise, users should
-.Em never
-be granted
-.Nm sudoedit
-permission to edit a file that resides in a directory the user has
-write access to.
-A user with directory write access could replace the legitimate
-file with a link to some other, arbitrary, file.
-Starting with version 1.8.15,
-.Nm sudoedit
-will refuse to open a symbolic link unless the security policy
-explicitly permits it.
-However, it is still possible to create a hard link if the directory
-is writable and the link target resides on the same file system.
 .Pp
 Please note that
 .Nm
index 4eda3319f941c92dc58c8593e6631f0092394431..05fb4a942213bc8c36132b0f0b84a879e7dcce80 100644 (file)
@@ -614,9 +614,9 @@ S\bSU\bUD\bDO\bOE\bER\bRS\bS F\bFI\bIL\bLE\bE F\bFO\bOR\bRM\bMA\bAT\bT
        See the _\bP_\br_\be_\bv_\be_\bn_\bt_\bi_\bn_\bg _\bs_\bh_\be_\bl_\bl _\be_\bs_\bc_\ba_\bp_\be_\bs section below for more details on how
        NOEXEC works and whether or not it will work on your system.
 
-     _\bF_\bO_\bL_\bL_\bO_\bW and _\bN_\bO_\bF_\bO_\bL_\bL_\bO_\bW Starting with version 1.8.15, s\bsu\bud\bdo\boe\bed\bdi\bit\bt will not
-       follow symbolic links when opening files unless the _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt_\b__\bf_\bo_\bl_\bl_\bo_\bw
-       option is enabled.  The _\bF_\bO_\bL_\bL_\bO_\bW and _\bN_\bO_\bF_\bO_\bL_\bL_\bO_\bW tags override the value of
+     _\bF_\bO_\bL_\bL_\bO_\bW and _\bN_\bO_\bF_\bO_\bL_\bL_\bO_\bW Starting with version 1.8.15, s\bsu\bud\bdo\boe\bed\bdi\bit\bt will not open
+       a file that is a symbolic link unless the _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt_\b__\bf_\bo_\bl_\bl_\bo_\bw option is
+       enabled.  The _\bF_\bO_\bL_\bL_\bO_\bW and _\bN_\bO_\bF_\bO_\bL_\bL_\bO_\bW tags override the value of
        _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt_\b__\bf_\bo_\bl_\bl_\bo_\bw and can be used to permit (or deny) the editing of
        symbolic links on a per-command basis.  These tags are only effective
        for the _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt command and are ignored for all other commands.
@@ -1257,15 +1257,20 @@ S\bSU\bUD\bDO\bOE\bER\bRS\bS O\bOP\bPT\bTI\bIO\bON\bNS\bS
                        system call.  This flag is _\bo_\bf_\bf by default.
 
      sudoedit_checkdir
-                       If set, s\bsu\bud\bdo\boe\bed\bdi\bit\bt will check directories in the path to
-                       be edited for writability by the invoking user.
-                       Symbolic links will not be followed in writable
-                       directories and s\bsu\bud\bdo\boe\bed\bdi\bit\bt will also refuse to edit a
-                       file located in a writable directory.  Theses
-                       restrictions are not enforced when s\bsu\bud\bdo\boe\bed\bdi\bit\bt is invoked
-                       as root.  On many systems, this option requires that
-                       all directories in the path to be edited be readable by
-                       the target user.  This flag is _\bo_\bf_\bf by default.
+                       If set, s\bsu\bud\bdo\boe\bed\bdi\bit\bt will check all directory components of
+                       the path to be edited for writability by the invoking
+                       user.  Symbolic links will not be followed in writable
+                       directories and s\bsu\bud\bdo\boe\bed\bdi\bit\bt will refuse to edit a file
+                       located in a writable directory.  These restrictions
+                       are not enforced when s\bsu\bud\bdo\boe\bed\bdi\bit\bt is run by root.  On some
+                       systems, if all directory components of the path to be
+                       edited are not readable by the target user, s\bsu\bud\bdo\boe\bed\bdi\bit\bt
+                       will be unable to edit the file.  This flag is _\bo_\bn by
+                       default.
+
+                       This setting was first introduced in version 1.8.15.
+                       The check for symbolic links in writable intermediate
+                       directories was added in version 1.8.16.
 
      sudoedit_follow   By default, s\bsu\bud\bdo\boe\bed\bdi\bit\bt will not follow symbolic links
                        when opening files.  The _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt_\b__\bf_\bo_\bl_\bl_\bo_\bw option can be
@@ -2378,12 +2383,14 @@ S\bSE\bEC\bCU\bUR\bRI\bIT\bTY\bY N\bNO\bOT\bTE\bES\bS
      resides in a directory the user has write access to, either directly or
      via a wildcard.  If the user has write access to the directory it is
      possible to replace the legitimate file with a link to another file,
-     allowing the editing of arbitrary files.  Starting with version 1.8.15,
+     allowing the editing of arbitrary files.  To prevent this, starting with
+     version 1.8.16, symbolic links will not be followed in writable
+     directories and s\bsu\bud\bdo\boe\bed\bdi\bit\bt will refuse to edit a file located in a writable
+     directory unless the _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt_\b__\bc_\bh_\be_\bc_\bk_\bd_\bi_\br option has been disabled or the
+     invoking user is root.  Additionally, in version 1.8.15 and higher,
      s\bsu\bud\bdo\boe\bed\bdi\bit\bt will refuse to open a symbolic link unless either the
-     _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt_\b__\bf_\bo_\bl_\bl_\bo_\bw Defaults option is enabled or the _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt command is
-     prefixed with the FOLLOW tag.  However, it is still possible to create a
-     hard link if the directory is writable and the link target resides on the
-     same file system.
+     _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt_\b__\bf_\bo_\bl_\bl_\bo_\bw option is enabled or the _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt command is prefixed
+     with the FOLLOW tag in the _\bs_\bu_\bd_\bo_\be_\br_\bs file.
 
    T\bTi\bim\bme\be s\bst\bta\bam\bmp\bp f\bfi\bil\ble\be c\bch\bhe\bec\bck\bks\bs
      s\bsu\bud\bdo\boe\ber\brs\bs will check the ownership of its time stamp directory
@@ -2524,4 +2531,4 @@ D\bDI\bIS\bSC\bCL\bLA\bAI\bIM\bME\bER\bR
      file distributed with s\bsu\bud\bdo\bo or https://www.sudo.ws/license.html for
      complete details.
 
-Sudo 1.8.16                    January 16, 2016                    Sudo 1.8.16
+Sudo 1.8.16                    January 19, 2016                    Sudo 1.8.16
index 2ff876ed81c15cc2d383ce2ab76129a6f0d0fa09..b3fac918145cbbffeb465e604c3c2366eac308c1 100644 (file)
@@ -21,7 +21,7 @@
 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
 .\"
-.TH "SUDOERS" "5" "January 16, 2016" "Sudo @PACKAGE_VERSION@" "File Formats Manual"
+.TH "SUDOERS" "5" "January 19, 2016" "Sudo @PACKAGE_VERSION@" "File Formats Manual"
 .nh
 .if n .ad l
 .SH "NAME"
@@ -1298,7 +1298,7 @@ works and whether or not it will work on your system.
 \fIFOLLOW\fR and \fINOFOLLOW\fR
 Starting with version 1.8.15,
 \fBsudoedit\fR
-will not follow symbolic links when opening files unless the
+will not open a file that is a symbolic link unless the
 \fIsudoedit_follow\fR
 option is enabled.
 The
@@ -2687,19 +2687,25 @@ sudoedit_checkdir
 .br
 If set,
 \fBsudoedit\fR
-will check directories in the path to be edited for writability
+will check all directory components of the path to be edited for writability
 by the invoking user.
 Symbolic links will not be followed in writable directories and
 \fBsudoedit\fR
-will also refuse to edit a file located in a writable directory.
-Theses restrictions are not enforced when
+will refuse to edit a file located in a writable directory.
+These restrictions are not enforced when
 \fBsudoedit\fR
-is invoked as root.
-On many systems, this option requires that all directories
-in the path to be edited be readable by the target user.
+is run by root.
+On some systems, if all directory components of the path to be edited
+are not readable by the target user,
+\fBsudoedit\fR
+will be unable to edit the file.
 This flag is
-\fIoff\fR
+\fIon\fR
 by default.
+.sp
+This setting was first introduced in version 1.8.15.
+The check for symbolic links in writable intermediate directories
+was added in version 1.8.16.
 .TP 18n
 sudoedit_follow
 By default,
@@ -4847,17 +4853,24 @@ has write access to, either directly or via a wildcard.
 If the user has write access to the directory it is possible to
 replace the legitimate file with a link to another file,
 allowing the editing of arbitrary files.
-Starting with version 1.8.15,
+To prevent this, starting with version 1.8.16, symbolic links will
+not be followed in writable directories and
+\fBsudoedit\fR
+will refuse to edit a file located in a writable directory
+unless the
+\fIsudoedit_checkdir\fR
+option has been disabled or the invoking user is root.
+Additionally, in version 1.8.15 and higher,
 \fBsudoedit\fR
 will refuse to open a symbolic link unless either the
 \fIsudoedit_follow\fR
-Defaults option is enabled or the
+option is enabled or the
 \fIsudoedit\fR
 command is prefixed with the
 \fRFOLLOW\fR
-tag.
-However, it is still possible to create a hard link if the directory
-is writable and the link target resides on the same file system.
+tag in the
+\fIsudoers\fR
+file.
 .SS "Time stamp file checks"
 \fBsudoers\fR
 will check the ownership of its time stamp directory
index c305563256af83e18330cd841032bd779a5cf524..3d4f8de240a2e1522de452d1542e65ec39b2aa48 100644 (file)
@@ -19,7 +19,7 @@
 .\" Agency (DARPA) and Air Force Research Laboratory, Air Force
 .\" Materiel Command, USAF, under agreement number F39502-99-1-0512.
 .\"
-.Dd January 16, 2016
+.Dd January 19, 2016
 .Dt SUDOERS @mansectform@
 .Os Sudo @PACKAGE_VERSION@
 .Sh NAME
@@ -1215,7 +1215,7 @@ works and whether or not it will work on your system.
 .It Em FOLLOW No and Em NOFOLLOW
 Starting with version 1.8.15,
 .Nm sudoedit
-will not follow symbolic links when opening files unless the
+will not open a file that is a symbolic link unless the
 .Em sudoedit_follow
 option is enabled.
 The
@@ -2517,19 +2517,25 @@ by default.
 .It sudoedit_checkdir
 If set,
 .Nm sudoedit
-will check directories in the path to be edited for writability
+will check all directory components of the path to be edited for writability
 by the invoking user.
 Symbolic links will not be followed in writable directories and
 .Nm sudoedit
-will also refuse to edit a file located in a writable directory.
-Theses restrictions are not enforced when
+will refuse to edit a file located in a writable directory.
+These restrictions are not enforced when
 .Nm sudoedit
-is invoked as root.
-On many systems, this option requires that all directories
-in the path to be edited be readable by the target user.
+is run by root.
+On some systems, if all directory components of the path to be edited
+are not readable by the target user,
+.Nm sudoedit
+will be unable to edit the file.
 This flag is
-.Em off
+.Em on
 by default.
+.Pp
+This setting was first introduced in version 1.8.15.
+The check for symbolic links in writable intermediate directories
+was added in version 1.8.16.
 .It sudoedit_follow
 By default,
 .Nm sudoedit
@@ -4468,17 +4474,24 @@ has write access to, either directly or via a wildcard.
 If the user has write access to the directory it is possible to
 replace the legitimate file with a link to another file,
 allowing the editing of arbitrary files.
-Starting with version 1.8.15,
+To prevent this, starting with version 1.8.16, symbolic links will
+not be followed in writable directories and
+.Nm sudoedit
+will refuse to edit a file located in a writable directory
+unless the
+.Em sudoedit_checkdir
+option has been disabled or the invoking user is root.
+Additionally, in version 1.8.15 and higher,
 .Nm sudoedit
 will refuse to open a symbolic link unless either the
 .Em sudoedit_follow
-Defaults option is enabled or the
+option is enabled or the
 .Em sudoedit
 command is prefixed with the
 .Li FOLLOW
-tag.
-However, it is still possible to create a hard link if the directory
-is writable and the link target resides on the same file system.
+tag in the
+.Em sudoers
+file.
 .Ss Time stamp file checks
 .Nm sudoers
 will check the ownership of its time stamp directory
index 2309c64c40283784692d94bb47112799e8445c09..16ee782b1ff57ca239c7c5d2ba538137c92794de 100644 (file)
@@ -440,6 +440,7 @@ init_defaults(void)
     def_use_netgroups = true;
 #endif
     def_netgroup_tuple = false;
+    def_sudoedit_checkdir = true;
 
     /* Syslog options need special care since they both strings and ints */
 #if (LOGGING & SLOG_SYSLOG)
index 8fc564e0e079f0102fde5092a365f92b04f3c8f9..eaf05db8f3db063369b078a65c153d94143eee94 100644 (file)
@@ -586,6 +586,7 @@ command_info_to_details(char * const info[], struct command_details *details)
     memset(details, 0, sizeof(*details));
     details->closefrom = -1;
     details->execfd = -1;
+    details->flags = CD_SUDOEDIT_CHECKDIR;
     TAILQ_INIT(&details->preserved_fds);
 
 #define SET_STRING(s, n) \