Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: Quentin Schulz <foss+buildroot@0leil.net>
Cc: Quentin Schulz <quentin.schulz@theobroma-systems.com>,
	buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] package/busybox: fix CVE-2022-28391
Date: Mon, 19 Sep 2022 21:36:14 +0200	[thread overview]
Message-ID: <20220919193614.GN1419013@scaer> (raw)
In-Reply-To: <20220919123147.1236781-1-foss+buildroot@0leil.net>

Quentin, All,

On 2022-09-19 14:31 +0200, Quentin Schulz spake thusly:
> From: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> 
> The patches have been used by Alpine for 5 months now and they were
> posted on the Busybox mailing list mid-July with no review or comment.
> 
> According to Ariadne Conill[1] - though NVD CVSS 3.x Base Score seems to
> disagree - this has a low security impact so we could probably just wait
> for upstream to merge the patches or implement it the way they want.
> 
> Considering those patches have been public for 5 months and upstream
> hasn't acted until now, let's take the patches from the mailing list
> anyway as there's no indication the CVEs will be fixed upstream soon.
> 
> [1] https://gitlab.alpinelinux.org/alpine/aports/-/issues/13661
> 
> Cc: Quentin Schulz <foss+buildroot@0leil.net>
> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
> 
> Cc'ing Peter for backport to stable releases
> Only build tested
> git context depends on
> https://lore.kernel.org/buildroot/20220919114757.1076737-1-foss+buildroot@0leil.net/
> 
>  ...tr-ensure-only-printable-characters-.patch | 42 +++++++++++
>  ...e-all-printed-strings-with-printable.patch | 69 +++++++++++++++++++
>  package/busybox/busybox.mk                    |  3 +
>  3 files changed, 114 insertions(+)
>  create mode 100644 package/busybox/0004-libbb-sockaddr2str-ensure-only-printable-characters-.patch
>  create mode 100644 package/busybox/0005-nslookup-sanitize-all-printed-strings-with-printable.patch
> 
> diff --git a/package/busybox/0004-libbb-sockaddr2str-ensure-only-printable-characters-.patch b/package/busybox/0004-libbb-sockaddr2str-ensure-only-printable-characters-.patch
> new file mode 100644
> index 0000000000..623b2597a2
> --- /dev/null
> +++ b/package/busybox/0004-libbb-sockaddr2str-ensure-only-printable-characters-.patch
> @@ -0,0 +1,42 @@
> +From 9d825e854ef53ebbe0aea2f1a69f52b763104daf Mon Sep 17 00:00:00 2001
> +From: Ariadne Conill <ariadne@dereferenced.org>
> +Date: Mon, 19 Sep 2022 14:15:12 +0200
> +Subject: [PATCH] libbb: sockaddr2str: ensure only printable characters are
> + returned for the hostname part
> +
> +CVE: CVE-2022-28391
> +Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
> +Tested-by: Radoslav Kolev <radoslav.kolev@suse.com>
> +Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089796.html
> +Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> +---
> + libbb/xconnect.c | 5 +++--
> + 1 file changed, 3 insertions(+), 2 deletions(-)
> +
> +diff --git a/libbb/xconnect.c b/libbb/xconnect.c
> +index 0e0b247b8..02c061e67 100644
> +--- a/libbb/xconnect.c
> ++++ b/libbb/xconnect.c
> +@@ -497,8 +497,9 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
> + 	);
> + 	if (rc)
> + 		return NULL;
> ++	/* ensure host contains only printable characters */
> + 	if (flags & IGNORE_PORT)
> +-		return xstrdup(host);
> ++		return xstrdup(printable_string(host));
> + #if ENABLE_FEATURE_IPV6
> + 	if (sa->sa_family == AF_INET6) {
> + 		if (strchr(host, ':')) /* heh, it's not a resolved hostname */
> +@@ -509,7 +510,7 @@ static char* FAST_FUNC sockaddr2str(const struct sockaddr *sa, int flags)
> + #endif
> + 	/* For now we don't support anything else, so it has to be INET */
> + 	/*if (sa->sa_family == AF_INET)*/
> +-		return xasprintf("%s:%s", host, serv);
> ++		return xasprintf("%s:%s", printable_string(host), serv);
> + 	/*return xstrdup(host);*/
> + }
> + 
> +-- 
> +2.37.3
> +
> diff --git a/package/busybox/0005-nslookup-sanitize-all-printed-strings-with-printable.patch b/package/busybox/0005-nslookup-sanitize-all-printed-strings-with-printable.patch
> new file mode 100644
> index 0000000000..bfa58465e7
> --- /dev/null
> +++ b/package/busybox/0005-nslookup-sanitize-all-printed-strings-with-printable.patch
> @@ -0,0 +1,69 @@
> +From bd463a5564a2c0618317448c3f965d389534c3df Mon Sep 17 00:00:00 2001
> +From: Ariadne Conill <ariadne@dereferenced.org>
> +Date: Mon, 19 Sep 2022 14:15:12 +0200
> +Subject: [PATCH] nslookup: sanitize all printed strings with printable_string
> +
> +Otherwise, terminal sequences can be injected, which enables various terminal injection
> +attacks from DNS results.
> +
> +CVE: CVE-2022-28391
> +Signed-off-by: Ariadne Conill <ariadne@dereferenced.org>
> +Tested-by: Radoslav Kolev <radoslav.kolev@suse.com>
> +Backport from ML: http://lists.busybox.net/pipermail/busybox/2022-July/089795.html
> +Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
> +---
> + networking/nslookup.c | 10 +++++-----
> + 1 file changed, 5 insertions(+), 5 deletions(-)
> +
> +diff --git a/networking/nslookup.c b/networking/nslookup.c
> +index 6da97baf4..4bdcde1b8 100644
> +--- a/networking/nslookup.c
> ++++ b/networking/nslookup.c
> +@@ -407,7 +407,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
> + 				//printf("Unable to uncompress domain: %s\n", strerror(errno));
> + 				return -1;
> + 			}
> +-			printf(format, ns_rr_name(rr), dname);
> ++			printf(format, ns_rr_name(rr), printable_string(dname));
> + 			break;
> + 
> + 		case ns_t_mx:
> +@@ -422,7 +422,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
> + 				//printf("Cannot uncompress MX domain: %s\n", strerror(errno));
> + 				return -1;
> + 			}
> +-			printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, dname);
> ++			printf("%s\tmail exchanger = %d %s\n", ns_rr_name(rr), n, printable_string(dname));
> + 			break;
> + 
> + 		case ns_t_txt:
> +@@ -434,7 +434,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
> + 			if (n > 0) {
> + 				memset(dname, 0, sizeof(dname));
> + 				memcpy(dname, ns_rr_rdata(rr) + 1, n);
> +-				printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), dname);
> ++				printf("%s\ttext = \"%s\"\n", ns_rr_name(rr), printable_string(dname));
> + 			}
> + 			break;
> + 
> +@@ -454,7 +454,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
> + 			}
> + 
> + 			printf("%s\tservice = %u %u %u %s\n", ns_rr_name(rr),
> +-				ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), dname);
> ++				ns_get16(cp), ns_get16(cp + 2), ns_get16(cp + 4), printable_string(dname));
> + 			break;
> + 
> + 		case ns_t_soa:
> +@@ -483,7 +483,7 @@ static NOINLINE int parse_reply(const unsigned char *msg, size_t len)
> + 				return -1;
> + 			}
> + 
> +-			printf("\tmail addr = %s\n", dname);
> ++			printf("\tmail addr = %s\n", printable_string(dname));
> + 			cp += n;
> + 
> + 			printf("\tserial = %lu\n", ns_get32(cp));
> +-- 
> +2.37.3
> +
> diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk
> index 0f887c9734..ef628e90e9 100644
> --- a/package/busybox/busybox.mk
> +++ b/package/busybox/busybox.mk
> @@ -13,6 +13,9 @@ BUSYBOX_CPE_ID_VENDOR = busybox
>  
>  # 0003-awk-fix-use-after-free-CVE-2022-30065.patch
>  BUSYBOX_IGNORE_CVES += CVE-2022-30065
> +# 0004-libbb-sockaddr2str-ensure-only-printable-characters-.patch
> +# 0005-nslookup-sanitize-all-printed-strings-with-printable.patch
> +BUSYBOX_IGNORE_CVES += CVE-2022-28391
>  
>  BUSYBOX_CFLAGS = \
>  	$(TARGET_CFLAGS)
> -- 
> 2.37.3
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2022-09-19 19:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-19 12:31 [Buildroot] [PATCH] package/busybox: fix CVE-2022-28391 Quentin Schulz
2022-09-19 19:36 ` Yann E. MORIN [this message]
2022-09-29 20:21 ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220919193614.GN1419013@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=foss+buildroot@0leil.net \
    --cc=quentin.schulz@theobroma-systems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox