Kamil Dudka fd470b
From 0aa9b0a92cb61af76b75b57abfd6ea1a7c627367 Mon Sep 17 00:00:00 2001
Kamil Dudka fd470b
From: Michael Orlitzky <michael@orlitzky.com>
Kamil Dudka fd470b
Date: Thu, 28 Dec 2017 15:52:42 -0500
Kamil Dudka fd470b
Subject: [PATCH 1/2] doc: clarify chown/chgrp --dereference defaults
Kamil Dudka fd470b
Kamil Dudka fd470b
* doc/coreutils.texi: the documentation for the --dereference
Kamil Dudka fd470b
  flag of chown/chgrp states that it is the default mode of
Kamil Dudka fd470b
  operation. Document that this is only the case when operating
Kamil Dudka fd470b
  non-recursively.
Kamil Dudka fd470b
Kamil Dudka fd470b
Upstream-commit: 7597cfa482e42a00a69fb9577ee523762980a9a2
Kamil Dudka fd470b
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Kamil Dudka fd470b
---
Kamil Dudka fd470b
 doc/coreutils.texi | 4 ++--
Kamil Dudka fd470b
 1 file changed, 2 insertions(+), 2 deletions(-)
Kamil Dudka fd470b
Kamil Dudka fd470b
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
Kamil Dudka fd470b
index de1f2eb..de06c0f 100644
Kamil Dudka fd470b
--- a/doc/coreutils.texi
Kamil Dudka fd470b
+++ b/doc/coreutils.texi
Kamil Dudka fd470b
@@ -10989,7 +10989,7 @@ chown -h -R --from=OLDUSER NEWUSER /
Kamil Dudka fd470b
 @cindex symbolic links, changing owner
Kamil Dudka fd470b
 @findex lchown
Kamil Dudka fd470b
 Do not act on symbolic links themselves but rather on what they point to.
Kamil Dudka fd470b
-This is the default.
Kamil Dudka fd470b
+This is the default when not operating recursively.
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @item -h
Kamil Dudka fd470b
 @itemx --no-dereference
Kamil Dudka fd470b
@@ -11119,7 +11119,7 @@ changed.
Kamil Dudka fd470b
 @cindex symbolic links, changing owner
Kamil Dudka fd470b
 @findex lchown
Kamil Dudka fd470b
 Do not act on symbolic links themselves but rather on what they point to.
Kamil Dudka fd470b
-This is the default.
Kamil Dudka fd470b
+This is the default when not operating recursively.
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @item -h
Kamil Dudka fd470b
 @itemx --no-dereference
Kamil Dudka fd470b
-- 
Kamil Dudka fd470b
2.13.6
Kamil Dudka fd470b
Kamil Dudka fd470b
Kamil Dudka fd470b
From 3fb331864c718e065804049001b573ff94810772 Mon Sep 17 00:00:00 2001
Kamil Dudka fd470b
From: Michael Orlitzky <michael@orlitzky.com>
Kamil Dudka fd470b
Date: Thu, 4 Jan 2018 11:38:21 -0500
Kamil Dudka fd470b
Subject: [PATCH 2/2] doc: warn about following symlinks recursively in
Kamil Dudka fd470b
 chown/chgrp
Kamil Dudka fd470b
Kamil Dudka fd470b
In both chown and chgrp (which shares its code with chown), operating
Kamil Dudka fd470b
on symlinks recursively has a window of vulnerability where the
Kamil Dudka fd470b
destination user or group can change the target of the operation.
Kamil Dudka fd470b
Warn about combining the --dereference, --recursive, and -L flags.
Kamil Dudka fd470b
Kamil Dudka fd470b
* doc/coreutils.texi (warnOptDerefWithRec): Add macro.
Kamil Dudka fd470b
(node chown invocation): Add it to --dereference and -L.
Kamil Dudka fd470b
(node chgrp invocation): Likewise.
Kamil Dudka fd470b
Kamil Dudka fd470b
See also: CVE-2017-18018
Kamil Dudka fd470b
Kamil Dudka fd470b
Upstream-commit: bc2fd9796403e03bb757b064d44c22fab92e6842
Kamil Dudka fd470b
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Kamil Dudka fd470b
---
Kamil Dudka fd470b
 doc/coreutils.texi | 17 +++++++++++++++++
Kamil Dudka fd470b
 1 file changed, 17 insertions(+)
Kamil Dudka fd470b
Kamil Dudka fd470b
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
Kamil Dudka fd470b
index de06c0f..24cc85b 100644
Kamil Dudka fd470b
--- a/doc/coreutils.texi
Kamil Dudka fd470b
+++ b/doc/coreutils.texi
Kamil Dudka fd470b
@@ -1428,6 +1428,19 @@ a command line argument is a symbolic link to a directory, traverse it.
Kamil Dudka fd470b
 In a recursive traversal, traverse every symbolic link to a directory
Kamil Dudka fd470b
 that is encountered.
Kamil Dudka fd470b
 @end macro
Kamil Dudka fd470b
+
Kamil Dudka fd470b
+@c Append the following warning to -L where appropriate (e.g. chown).
Kamil Dudka fd470b
+@macro warnOptDerefWithRec
Kamil Dudka fd470b
+
Kamil Dudka fd470b
+Combining this dereferencing option with the @option{--recursive} option
Kamil Dudka fd470b
+may create a security risk:
Kamil Dudka fd470b
+During the traversal of the directory tree, an attacker may be able to
Kamil Dudka fd470b
+introduce a symlink to an arbitrary target; when the tool reaches that,
Kamil Dudka fd470b
+the operation will be performed on the target of that symlink,
Kamil Dudka fd470b
+possibly allowing the attacker to escalate privileges.
Kamil Dudka fd470b
+
Kamil Dudka fd470b
+@end macro
Kamil Dudka fd470b
+
Kamil Dudka fd470b
 @choptL
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @macro choptP
Kamil Dudka fd470b
@@ -10990,6 +11003,7 @@ chown -h -R --from=OLDUSER NEWUSER /
Kamil Dudka fd470b
 @findex lchown
Kamil Dudka fd470b
 Do not act on symbolic links themselves but rather on what they point to.
Kamil Dudka fd470b
 This is the default when not operating recursively.
Kamil Dudka fd470b
+@warnOptDerefWithRec
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @item -h
Kamil Dudka fd470b
 @itemx --no-dereference
Kamil Dudka fd470b
@@ -11046,6 +11060,7 @@ Recursively change ownership of directories and their contents.
Kamil Dudka fd470b
 @xref{Traversing symlinks}.
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @choptL
Kamil Dudka fd470b
+@warnOptDerefWithRec
Kamil Dudka fd470b
 @xref{Traversing symlinks}.
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @choptP
Kamil Dudka fd470b
@@ -11120,6 +11135,7 @@ changed.
Kamil Dudka fd470b
 @findex lchown
Kamil Dudka fd470b
 Do not act on symbolic links themselves but rather on what they point to.
Kamil Dudka fd470b
 This is the default when not operating recursively.
Kamil Dudka fd470b
+@warnOptDerefWithRec
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @item -h
Kamil Dudka fd470b
 @itemx --no-dereference
Kamil Dudka fd470b
@@ -11175,6 +11191,7 @@ Recursively change the group ownership of directories and their contents.
Kamil Dudka fd470b
 @xref{Traversing symlinks}.
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @choptL
Kamil Dudka fd470b
+@warnOptDerefWithRec
Kamil Dudka fd470b
 @xref{Traversing symlinks}.
Kamil Dudka fd470b
 
Kamil Dudka fd470b
 @choptP
Kamil Dudka fd470b
-- 
Kamil Dudka fd470b
2.13.6
Kamil Dudka fd470b