From 7e8e195c6ada1ec3e6ec08b6382e0a2b93d52a72 Mon Sep 17 00:00:00 2001 From: "danila.leontiev" Date: Wed, 23 Jul 2014 13:11:37 +0400 Subject: [PATCH] Security fix --- 107.patch | 33 +++++++++++++++++++++++++++++++++ pam-CVE-2014-2583.patch | 33 +++++++++++++++++++++++++++++++++ pam.spec | 2 ++ 3 files changed, 68 insertions(+) create mode 100644 107.patch create mode 100644 pam-CVE-2014-2583.patch diff --git a/107.patch b/107.patch new file mode 100644 index 0000000..a5c3221 --- /dev/null +++ b/107.patch @@ -0,0 +1,33 @@ + +diff --git a/modules/pam_timestamp/pam_timestamp.c b/modules/pam_timestamp/pam_timestamp.c +index 5193733..b3f08b1 100644 +--- a/modules/pam_timestamp/pam_timestamp.c ++++ b/modules/pam_timestamp/pam_timestamp.c +@@ -158,7 +158,7 @@ check_tty(const char *tty) + tty = strrchr(tty, '/') + 1; + } + /* Make sure the tty wasn't actually a directory (no basename). */ +- if (strlen(tty) == 0) { ++ if (!strlen(tty) || !strcmp(tty, ".") || !strcmp(tty, "..")) { + return NULL; + } + return tty; +@@ -243,6 +243,17 @@ get_ruser(pam_handle_t *pamh, char *ruserbuf, size_t ruserbuflen) + if (pwd != NULL) { + ruser = pwd->pw_name; + } ++ } else { ++ /* ++ * This ruser is used by format_timestamp_name as a component ++ * of constructed timestamp pathname, so ".", "..", and '/' ++ * are disallowed to avoid potential path traversal issues. ++ */ ++ if (!strcmp(ruser, ".") || ++ !strcmp(ruser, "..") || ++ strchr(ruser, '/')) { ++ ruser = NULL; ++ } + } + if (ruser == NULL || strlen(ruser) >= ruserbuflen) { + *ruserbuf = '\0'; + diff --git a/pam-CVE-2014-2583.patch b/pam-CVE-2014-2583.patch new file mode 100644 index 0000000..a5c3221 --- /dev/null +++ b/pam-CVE-2014-2583.patch @@ -0,0 +1,33 @@ + +diff --git a/modules/pam_timestamp/pam_timestamp.c b/modules/pam_timestamp/pam_timestamp.c +index 5193733..b3f08b1 100644 +--- a/modules/pam_timestamp/pam_timestamp.c ++++ b/modules/pam_timestamp/pam_timestamp.c +@@ -158,7 +158,7 @@ check_tty(const char *tty) + tty = strrchr(tty, '/') + 1; + } + /* Make sure the tty wasn't actually a directory (no basename). */ +- if (strlen(tty) == 0) { ++ if (!strlen(tty) || !strcmp(tty, ".") || !strcmp(tty, "..")) { + return NULL; + } + return tty; +@@ -243,6 +243,17 @@ get_ruser(pam_handle_t *pamh, char *ruserbuf, size_t ruserbuflen) + if (pwd != NULL) { + ruser = pwd->pw_name; + } ++ } else { ++ /* ++ * This ruser is used by format_timestamp_name as a component ++ * of constructed timestamp pathname, so ".", "..", and '/' ++ * are disallowed to avoid potential path traversal issues. ++ */ ++ if (!strcmp(ruser, ".") || ++ !strcmp(ruser, "..") || ++ strchr(ruser, '/')) { ++ ruser = NULL; ++ } + } + if (ruser == NULL || strlen(ruser) >= ruserbuflen) { + *ruserbuf = '\0'; + diff --git a/pam.spec b/pam.spec index 8516029..5e80a85 100644 --- a/pam.spec +++ b/pam.spec @@ -71,6 +71,7 @@ Patch702: Linux-PAM-1.1.4-add-now-missing-nis-constant.patch # (akdengi> add user to default group users which need for Samba Patch801: Linux-PAM-1.1.4-group_add_users.patch +Patch802: pam-CVE-2014-2583.patch BuildRequires: selinux-devel >= 2.1.6-7 BuildRequires: bison @@ -175,6 +176,7 @@ mv pam-redhat-%{pam_redhat_version}/* modules %patch701 -p1 -b .nopermsd %patch702 -p1 -b .nis_const~ %patch801 -p1 -b .group_users +%patch802 -p1 # 08/08/2008 - vdanen - make pam provide pam_unix until we can work out all the issues in pam_tcb; this # just makes things easier but is not meant to be a permanent solution