main/busybox: add fix for CVE-2022-30065

Sent upstream:
http://lists.busybox.net/pipermail/busybox/2022-June/089768.html

(cherry picked from commit 4ffd996b3f8298c7dd424b912c245864c816e354)
This commit is contained in:
Natanael Copa 2022-06-21 16:20:34 +02:00
parent bfe41dea01
commit 2fbebc372d
2 changed files with 68 additions and 1 deletions

View File

@ -4,7 +4,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox
pkgver=1.33.1
pkgrel=7
pkgrel=8
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url="https://busybox.net/"
arch="all"
@ -45,6 +45,7 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2
0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch
0002-nslookup-sanitize-all-printed-strings-with-printable.patch
CVE-2022-30065.patch
acpid.logrotate
busyboxconfig
@ -56,6 +57,8 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2
"
# secfixes:
# 1.33.0-r8:
# - CVE-2022-30065
# 1.33.1-r7:
# - ALPINE-13661
# - CVE-2022-28391
@ -279,6 +282,7 @@ d12246f1134bbd3993462d27172c4739cc601b251d57ce8e088745773afa965551236e8cb8b9013d
b7835e85e135a03d21cdc920a222caa1c77f76262e39fc75ec8d8aaa570d32427a9be1f523255e4c55d8d847d51406b46864845a598684cbdfa7234b629c4764 awk-fixes.patch
b52050678e79e4da856956906d07fcb620cbf35f2ef6b5a8ee3b8d244ea63b4b98eef505451184d5b4937740d91eef154ed748c30d329ac485be51b37626f251 0001-libbb-sockaddr2str-ensure-only-printable-characters-.patch
ead4ad65d270d8659e1898fa16f76b6cbcf567d8aba238eacccda3764edb4362240d9359d6389873bedc126d405f805fc6dfce653a7181618ebcc67c94bd08d2 0002-nslookup-sanitize-all-printed-strings-with-printable.patch
22e2fa8f7a6105fd9990f93b71c235980fd4eab62269939a0e3a920fe517ee4f913c6bd0148a554b67fe01d1660bf0fd76a80e9dcac290b4b8b2c304ef6080a9 CVE-2022-30065.patch
aa93095e20de88730f526c6f463cef711b290b9582cdbd8c1ba2bd290019150cbeaa7007c2e15f0362d5b9315dd63f60511878f0ea05e893f4fdfb4a54af3fb1 acpid.logrotate
5b0adc5bbe3d539380007ccc2e90ee1c986d24eae29b5e04b65a1e18988dc18907e7f617c7b3eb66ce131fdcb2de78da8b7653f58f95347d286fe5d17c6118f8 busyboxconfig
470a646505887dbf20dd8c3c3b5c8ab25f363f3a0bfbca577de115b8ec61f28e9843f4f3a7978c634e863dbf28bae987f20e7fa1aa529450ff6c17bc188cae53 busyboxconfig-extras

View File

@ -0,0 +1,63 @@
From 3c284dcb726ff6599d3b87fb366fb04411cf5595 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 17 Jun 2022 09:52:11 +0000
Subject: [PATCH 1/2] awk: fix use after free (CVE-2022-30065)
fixes https://bugs.busybox.net/show_bug.cgi?id=14781
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
editors/awk.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/editors/awk.c b/editors/awk.c
index 079d0bde5..728ee8685 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -3128,6 +3128,9 @@ static var *evaluate(node *op, var *res)
case XC( OC_MOVE ):
debug_printf_eval("MOVE\n");
+ /* make sure that we never return a temp var */
+ if (L.v == TMPVAR0)
+ L.v = res;
/* if source is a temporary string, jusk relink it to dest */
if (R.v == TMPVAR1
&& !(R.v->type & VF_NUMBER)
--
2.36.1
From 30c8f8e69230ef27f116a2c10ca2e4a6cc343dad Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Thu, 16 Jun 2022 21:54:48 +0200
Subject: [PATCH 2/2] awk: add tests for CVE-2022-30065
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
---
testsuite/awk.tests | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/testsuite/awk.tests b/testsuite/awk.tests
index 93e25d8c1..6c3a03c37 100755
--- a/testsuite/awk.tests
+++ b/testsuite/awk.tests
@@ -479,4 +479,15 @@ testing 'awk backslash+newline eaten with no trace' \
"Hello world\n" \
'' ''
+testing 'awk use-after-free (CVE-2022-30065)' \
+ "awk '\$3i\$3in\$9=\$r||\$9=i6/6-9f'" \
+ "" \
+ "" \
+ ""
+
+testing 'awk assign while test' \
+ "awk '\$1==\$1=\"foo\" {print \$1}'" \
+ "foo\n" \
+ "" \
+ "foo"
exit $FAILCOUNT
--
2.36.1