bash: Fix shellshock vulnerability
PATCH v2 1/1 bash: Fix shellshock vulnerability
CVE-2014-6271
--- .../bash/bash-3.2.48/shellshock.patch | 84 +++++++++++++++++ meta/recipes-extended/bash/bash/shellshock.patch | 101 +++++++++++++++++++++ meta/recipes-extended/bash/bash_3.2.48.bb | 1 + meta/recipes-extended/bash/bash_4.3.bb | 1 + 4 files changed, 187 insertions(+) create mode 100644 meta/recipes-extended/bash/bash-3.2.48/shellshock.patch create mode 100644 meta/recipes-extended/bash/bash/shellshock.patch
meta/recipes-extended/bash/bash-3.2.48/shellshock.patch new file +84 -0
@@ -0,0 +1,84 @@ +Fix CVE-2014-6271 + +specially-crafted environment variables can be used to inject shell commands +taken from +https://bugzilla.redhat.com/show_bug.cgi?id=1141597 + +Upstream-Status: Submitted + +Signed-off-by: Khem Raj <[email protected]> + +Index: bash-3.2.48/variables.c +=================================================================== +--- bash-3.2.48.orig/variables.c 2008-11-18 05:14:57.000000000 -0800 ++++ bash-3.2.48/variables.c 2014-09-26 09:12:58.700080056 -0700 +@@ -318,12 +318,10 @@ + temp_string[char_index] = ' '; + strcpy (temp_string + char_index + 1, string); + +- parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST); +- +- /* Ancient backwards compatibility. Old versions of bash exported +- functions like name()=() {...} */ +- if (name[char_index - 1] == ')' && name[char_index - 2] == '(') +- name[char_index - 2] = '\0'; ++ /* Don't import function names that are invalid identifiers from the ++ environment. */ ++ if (legal_identifier (name)) ++ parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD); + + if (temp_var = find_function (name)) + { +@@ -332,10 +330,6 @@ + } + else + report_error (_("error importing function definition for `%s'"), name); +- +- /* ( */ +- if (name[char_index - 1] == ')' && name[char_index - 2] == '\0') +- name[char_index - 2] = '('; /* ) */ + } + #if defined (ARRAY_VARS) + # if 0 +Index: bash-3.2.48/builtins/common.h +=================================================================== +--- bash-3.2.48.orig/builtins/common.h 2006-03-06 06:38:44.000000000 -0800 ++++ bash-3.2.48/builtins/common.h 2014-09-26 09:12:58.700080056 -0700 +@@ -33,6 +33,8 @@ + #define SEVAL_RESETLINE 0x010 + + /* Flags for describe_command, shared between type.def and command.def */ ++#define SEVAL_FUNCDEF 0x080 /* only allow function definitions */ ++#define SEVAL_ONECMD 0x100 /* only allow a single command */ + #define CDESC_ALL 0x001 /* type -a */ + #define CDESC_SHORTDESC 0x002 /* command -V */ + #define CDESC_REUSABLE 0x004 /* command -v */ +Index: bash-3.2.48/builtins/evalstring.c +=================================================================== +--- bash-3.2.48.orig/builtins/evalstring.c 2008-11-18 05:15:12.000000000 -0800 ++++ bash-3.2.48/builtins/evalstring.c 2014-09-26 09:12:58.700080056 -0700 +@@ -234,6 +234,14 @@ + { + struct fd_bitmap *bitmap; + ++ if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def) ++ { ++ internal_warning ("%s: ignoring function definition attempt", from_file); ++ should_jump_to_top_level = 0; ++ last_result = last_command_exit_value = EX_BADUSAGE; ++ break; ++ } ++ + bitmap = new_fd_bitmap (FD_BITMAP_SIZE); + begin_unwind_frame ("pe_dispose"); + add_unwind_protect (dispose_fd_bitmap, bitmap); +@@ -291,6 +299,9 @@ + dispose_command (command); + dispose_fd_bitmap (bitmap); + discard_unwind_frame ("pe_dispose"); ++ ++ if (flags & SEVAL_ONECMD) ++ break; + } + } + else
meta/recipes-extended/bash/bash/shellshock.patch new file +101 -0
101 lines not on this page · raw message
meta/recipes-extended/bash/bash_3.2.48.bb +1 -0
@@ -12,6 +12,7 @@ SRC_URI = "${GNU_MIRROR}/bash/bash-${PV}.tar.gz;name=tarball \ file://mkbuiltins_have_stringize.patch \ file://build-tests.patch \ file://test-output.patch \ + file://shellshock.patch \ file://run-ptest \ "
meta/recipes-extended/bash/bash_4.3.bb +1 -0
@@ -9,6 +9,7 @@ SRC_URI = "${GNU_MIRROR}/bash/${BPN}-${PV}.tar.gz;name=tarball \ file://mkbuiltins_have_stringize.patch \ file://build-tests.patch \ file://test-output.patch \ + file://shellshock.patch \ file://run-ptest \ "
Signature · 1 line
2.1.0
Quoted 1 line · Khem Raj
CVE-2014-6271
Is this meant to replace the patch I sent last night, or did you not notice that? It's been a funny day here, but I was about to send the C-Pull with that integrated.
Ross
Quoted 5 lines · Ross
Quoted 1 line · Khem Raj
CVE-2014-6271
Is this meant to replace the patch I sent last night, or did you not notice that?
I did not notice that
It's been a funny day here, but I was about to send the
Quoted 5 lines
C-Pull with that integrated.
Ross
Quoted 6 lines · Ross
Quoted 1 line · Khem Raj
CVE-2014-6271
Is this meant to replace the patch I sent last night, or did you not notice that? It's been a funny day here, but I was about to send the C-Pull with that integrated.
Now that I see, you posted half fix like my first set. So either way the second patch I sent
it needed to complete this vulnerability. I dont care whichever goes in for the first one.
Quoted 2 lines
Ross
Quoted 4 lines · Khem Raj
Now that I see, you posted half fix like my first set. So either way the second patch I sent
it needed to complete this vulnerability. I dont care whichever goes in for the first one.
I've rebased your second patch onto what I already had in mut, thanks Khem.
Ross