From owner-svn-ports-all@freebsd.org Fri Feb 7 19:40:13 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 04A0822C4AE; Fri, 7 Feb 2020 19:40:13 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48Dly46N6Dz3wZF; Fri, 7 Feb 2020 19:40:12 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D59AF9990; Fri, 7 Feb 2020 19:40:12 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 017JeCLV024361; Fri, 7 Feb 2020 19:40:12 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 017JeCFI024360; Fri, 7 Feb 2020 19:40:12 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202002071940.017JeCFI024360@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Fri, 7 Feb 2020 19:40:12 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r525502 - head/shells/ksh93/files X-SVN-Group: ports-head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: head/shells/ksh93/files X-SVN-Commit-Revision: 525502 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Feb 2020 19:40:13 -0000 Author: cy Date: Fri Feb 7 19:40:12 2020 New Revision: 525502 URL: https://svnweb.freebsd.org/changeset/ports/525502 Log: Add patch missed from r525497. Added: head/shells/ksh93/files/patch-ksh-2020.0.0-cve-2019-14868.patch (contents, props changed) Added: head/shells/ksh93/files/patch-ksh-2020.0.0-cve-2019-14868.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/shells/ksh93/files/patch-ksh-2020.0.0-cve-2019-14868.patch Fri Feb 7 19:40:12 2020 (r525502) @@ -0,0 +1,78 @@ +diff --git a/src/cmd/ksh93/sh/arith.c b/src/cmd/ksh93/sh/arith.c +--- src/cmd/ksh93/sh/arith.c ++++ src/cmd/ksh93/sh/arith.c +@@ -567,19 +567,32 @@ Sfdouble_t sh_strnum(Shell_t *shp, const char *str, char **ptr, int mode) { + char *last; + + if (*str == 0) { +- if (ptr) *ptr = (char *)str; +- return 0; +- } +- errno = 0; +- d = number(str, &last, shp->inarith ? 0 : 10, NULL); +- if (*last) { +- if (*last != '.' || last[1] != '.') { +- d = strval(shp, str, &last, arith, mode); +- Varsubscript = true; ++ d = 0.0; ++ last = (char *)str; ++ } else { ++ d = number(str, &last, shp->inarith ? 0 : 10, NULL); ++ if (*last && !shp->inarith && sh_isstate(shp, SH_INIT)) { ++ // This call is to handle "base#value" literals if we're importing untrusted env vars. ++ d = number(str, &last, 0, NULL); ++ } ++ if (*last) { ++ if (sh_isstate(shp, SH_INIT)) { ++ // Initializing means importing untrusted env vars. Since the string does not appear ++ // to be a recognized numeric literal give up. We can't safely call strval() since ++ // that allows arbitrary expressions which would create a security vulnerability. ++ d = 0.0; ++ } else { ++ if (*last != '.' || last[1] != '.') { ++ d = strval(shp, str, &last, arith, mode); ++ Varsubscript = true; ++ } ++ if (!ptr && *last && mode > 0) { ++ errormsg(SH_DICT, ERROR_exit(1), e_lexbadchar, *last, str); ++ } ++ } ++ } else if (d == 0.0 && *str == '-') { ++ d = -0.0; + } +- if (!ptr && *last && mode > 0) errormsg(SH_DICT, ERROR_exit(1), e_lexbadchar, *last, str); +- } else if (!d && *str == '-') { +- d = -0.0; + } + if (ptr) *ptr = last; + return d; +diff --git a/src/cmd/ksh93/tests/subshell.sh b/src/cmd/ksh93/tests/subshell.sh +--- src/cmd/ksh93/tests/subshell.sh ++++ src/cmd/ksh93/tests/subshell.sh +@@ -856,3 +856,26 @@ for exp in 65535 65536 + do got=$($SHELL -c 'x=$(printf "%.*c" '$exp' x); print ${#x}' 2>&1) + [[ $got == $exp ]] || log_error "large command substitution failed" "$exp" "$got" + done ++ ++# ========== ++# Verify that importing untrusted env vars does not allow evaluating arbitrary expressions but does ++# recognize all integer literals recognized by ksh. ++expect=8 ++actual=$(env SHLVL='7' $SHELL -c 'echo $SHLVL') ++[[ $actual == $expect ]] || log_error "decimal int literal not recognized" "$expect" "$actual" ++ ++expect=14 ++actual=$(env SHLVL='013' $SHELL -c 'echo $SHLVL') ++[[ $actual == $expect ]] || log_error "leading zeros int literal not recognized" "$expect" "$actual" ++ ++expect=4 ++actual=$(env SHLVL='2#11' $SHELL -c 'echo $SHLVL') ++[[ $actual == $expect ]] || log_error "base#value int literal not recognized" "$expect" "$actual" ++ ++expect=12 ++actual=$(env SHLVL='16#B' $SHELL -c 'echo $SHLVL') ++[[ $actual == $expect ]] || log_error "base#value int literal not recognized" "$expect" "$actual" ++ ++expect=1 ++actual=$(env SHLVL="2#11+x[\$($bin_echo DANGER WILL ROBINSON >&2)0]" $SHELL -c 'echo $SHLVL') ++[[ $actual == $expect ]] || log_error "expression allowed on env var import" "$expect" "$actual"