Blame SOURCES/0002-zsh-5.8-CVE-2021-45444.patch

1582ce
From 02e0f94fff27cad2ba4e65bdc4b21146b3bd9a97 Mon Sep 17 00:00:00 2001
1582ce
From: Oliver Kiddle <opk@zsh.org>
1582ce
Date: Wed, 15 Dec 2021 01:56:40 +0100
1582ce
Subject: [PATCH 1/2] security/41: Don't perform PROMPT_SUBST evaluation on
1582ce
 %F/%K arguments
1582ce
1582ce
Mitigates CVE-2021-45444
1582ce
1582ce
Upstream-commit: c187154f47697cdbf822c2f9d714d570ed4a0fd1
1582ce
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
1582ce
---
1582ce
 Src/prompt.c | 10 ++++++++++
1582ce
 1 file changed, 10 insertions(+)
1582ce
1582ce
diff --git a/Src/prompt.c b/Src/prompt.c
1582ce
index b65bfb8..91e21c8 100644
1582ce
--- a/Src/prompt.c
1582ce
+++ b/Src/prompt.c
1582ce
@@ -244,6 +244,12 @@ parsecolorchar(zattr arg, int is_fg)
1582ce
 	bv->fm += 2; /* skip over F{ */
1582ce
 	if ((ep = strchr(bv->fm, '}'))) {
1582ce
 	    char oc = *ep, *col, *coll;
1582ce
+	    int ops = opts[PROMPTSUBST], opb = opts[PROMPTBANG];
1582ce
+	    int opp = opts[PROMPTPERCENT];
1582ce
+
1582ce
+	    opts[PROMPTPERCENT] = 1;
1582ce
+	    opts[PROMPTSUBST] = opts[PROMPTBANG] = 0;
1582ce
+
1582ce
 	    *ep = '\0';
1582ce
 	    /* expand the contents of the argument so you can use
1582ce
 	     * %v for example */
1582ce
@@ -252,6 +258,10 @@ parsecolorchar(zattr arg, int is_fg)
1582ce
 	    arg = match_colour((const char **)&coll, is_fg, 0);
1582ce
 	    free(col);
1582ce
 	    bv->fm = ep;
1582ce
+
1582ce
+	    opts[PROMPTSUBST] = ops;
1582ce
+	    opts[PROMPTBANG] = opb;
1582ce
+	    opts[PROMPTPERCENT] = opp;
1582ce
 	} else {
1582ce
 	    arg = match_colour((const char **)&bv->fm, is_fg, 0);
1582ce
 	    if (*bv->fm != '}')
1582ce
-- 
1582ce
2.34.1
1582ce
1582ce
1582ce
From 6102afb5dfd7c704f9cf99bedb9c3ec3c7dbe8e3 Mon Sep 17 00:00:00 2001
1582ce
From: dana <dana@dana.is>
1582ce
Date: Tue, 21 Dec 2021 13:13:33 -0600
1582ce
Subject: [PATCH 2/2] CVE-2021-45444: Update NEWS/README
1582ce
1582ce
Upstream-commit: bdc4d70a7e033b754e68a8659a037ea0fc5f38de
1582ce
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
1582ce
---
1582ce
 NEWS   | 20 ++++++++++++++++++++
1582ce
 README |  6 ++++++
1582ce
 2 files changed, 26 insertions(+)
1582ce
1582ce
diff --git a/NEWS b/NEWS
1582ce
index 964e163..327b449 100644
1582ce
--- a/NEWS
1582ce
+++ b/NEWS
1582ce
@@ -4,6 +4,26 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH
1582ce
 
1582ce
 Note also the list of incompatibilities in the README file.
1582ce
 
1582ce
+Changes since 5.8
1582ce
+-----------------
1582ce
+
1582ce
+CVE-2021-45444: Some prompt expansion sequences, such as %F, support
1582ce
+'arguments' which are themselves expanded in case they contain colour
1582ce
+values, etc. This additional expansion would trigger PROMPT_SUBST
1582ce
+evaluation, if enabled. This could be abused to execute code the user
1582ce
+didn't expect. e.g., given a certain prompt configuration, an attacker
1582ce
+could trick a user into executing arbitrary code by having them check
1582ce
+out a Git branch with a specially crafted name.
1582ce
+
1582ce
+This is fixed in the shell itself by no longer performing PROMPT_SUBST
1582ce
+evaluation on these prompt-expansion arguments.
1582ce
+
1582ce
+Users who are concerned about an exploit but unable to update their
1582ce
+binaries may apply the partial work-around described in the file
1582ce
+Etc/CVE-2021-45444-VCS_Info-workaround.patch included with the shell
1582ce
+source. [ Reported by RyotaK <security@ryotak.me>. Additional thanks to
1582ce
+Marc Cornellà <hello@mcornella.com>. ]
1582ce
+
1582ce
 Changes since 5.7.1-test-3
1582ce
 --------------------------
1582ce
 
1582ce
diff --git a/README b/README
1582ce
index 7f1dd5f..c9e994a 100644
1582ce
--- a/README
1582ce
+++ b/README
1582ce
@@ -31,6 +31,12 @@ Zsh is a shell with lots of features.  For a list of some of these, see the
1582ce
 file FEATURES, and for the latest changes see NEWS.  For more
1582ce
 details, see the documentation.
1582ce
 
1582ce
+Incompatibilities since 5.8
1582ce
+---------------------------
1582ce
+
1582ce
+PROMPT_SUBST expansion is no longer performed on arguments to prompt-
1582ce
+expansion sequences such as %F.
1582ce
+
1582ce
 Incompatibilities since 5.7.1
1582ce
 -----------------------------
1582ce
 
1582ce
-- 
1582ce
2.34.1
1582ce