Bug 14125

Summary: busybox wget ssl is exposed to MitM attack due to CVE-2018-1000500
Product: [Runtime] Security Reporter: Shachar Menashe <shachar>
Component: securityAssignee: Randy MacLeod <randy.macleod>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: akuster808, randy.macleod, richard.purdie, ross.burton, shachar, tgamblin
Version: unspecified   
Target Milestone: 5.1 M2   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Shachar Menashe 2020-11-12 15:45:28 UTC
The version of busybox shipped with Yocto builds (which is 1.31.1) is exposed to a severe CVE which easily allows for SSL MitM attacks (when using busybox wget)

To remediate, the following steps need to be done:
1. Update busybox to version 1.32.0

2. Change busybox build configuration (ex. https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta-poky/recipes-core/busybox/busybox/poky-tiny/defconfig?h=dunfell) to:

CONFIG_FEATURE_WGET_OPENSSL=y
# CONFIG_FEATURE_WGET_HTTPS is not set
Comment 1 akuster 2020-12-03 15:26:18 UTC
Master and gatesgarth are both at 1.32.0.

1) action to send config change

Dunfell is at 1.31.1 an may or may not be able to be updated. 

It will need #1 and a source change patch or otherwise.
Comment 2 Ross Burton 2020-12-10 15:54:40 UTC
Either way we might want to apply this patch from Alpine which prints a big warning when using the insecure codepaths:

https://github.com/alpinelinux/aports/commit/a93da0e814c542ff3a76cba0b557ee51c8124d1e

I'd say that telling the user that their connection isn't being verified is enough to mitigate the CVE, as the issue is that MitM can happen without your knowledge.
Comment 3 akuster 2020-12-11 23:43:31 UTC
As this is a team effort, i will take the next step and send a patch to move us to the next step of resolving this issue.

I have a few options to select from.
Comment 4 Shachar Menashe 2020-12-12 14:37:10 UTC
I sent the patch a few weeks ago, but got pushback because it required building the "openssl" binary and not just the library (that's just how the busybox team chose to use openssl unfortunately... not through the library but by calling the binary)
Comment 5 akuster 2021-01-14 16:17:21 UTC
This is the patch.

https://lists.yoctoproject.org/g/yocto-security/message/229

sent to the security-list.
Comment 7 akuster 2021-01-14 16:33:26 UTC
I think this can be marked as fixed.
Comment 8 Randy MacLeod 2021-01-14 17:05:41 UTC
Are the backports done or going to happen?
Comment 9 akuster 2021-01-21 15:32:39 UTC
(In reply to comment #8)
> Are the backports done or going to happen?

Its not obvious in the commit that its addressing a CVE so a backport request needs to be sent to the list.
Comment 10 Shachar Menashe 2021-01-23 20:55:30 UTC
I think there's been a bit of a mixup
The patch referenced in this thread before (this one - https://lists.yoctoproject.org/g/yocto-security/message/229) DOESN'T resolve the CVE. It's related to a different issue.

Resolving the CVE requires:
1. Changing the busybox config to use OpenSSL by enabling CONFIG_FEATURE_WGET_OPENSSL

2. Building the openssl executable (today it's being built as a library only, but busybox uses openssl as an executable when CONFIG_FEATURE_WGET_OPENSSL is enabled)

So I wrote the patch for #1 a while back, but then got pushback regarding point #2, and didn't submit it, since I thought we're going with Ross' suggestion of just including a warning, the alpine patch - https://github.com/alpinelinux/aports/commit/a93da0e814c542ff3a76cba0b557ee51c8124d1e
Comment 11 Randy MacLeod 2021-03-18 14:37:53 UTC
Shakar, Can you send a patch to at least issue a warning?
Comment 12 Randy MacLeod 2021-04-15 18:28:01 UTC
The discussion  on the email list wasn't conclusive. Do you want to drop the issue or add a PACKAGECONFIG to make busybox wget secure using openssl. I suspect that making it secure by default will not be viable due to pulling in some of openssl but that's just my opinion.
Comment 13 akuster 2021-04-15 21:24:42 UTC
(In reply to comment #12)
> The discussion  on the email list wasn't conclusive. Do you want to drop the
> issue or add a PACKAGECONFIG to make busybox wget secure using openssl. I
> suspect that making it secure by default will not be viable due to pulling
> in some of openssl but that's just my opinion.

I have been wondering if something like defining something at the DISTRO level to enable mitigation of this CVE so folks can OPT in knowing the affects of doing so then we could have Busybox and openssl do the appropriate things based on that OPT in directive?

I know the kernel has done this from time to time. The early Meltdown & Sepectra come to mind.
Comment 14 Shachar Menashe 2021-04-17 11:26:10 UTC
Hey guys, I looked into it further and it seems the "issue" with openssl and the yocto build is not that it's compiled without the binary part, but rather that in "core-image-base" and "core-image-minimal" openssl is not getting compiled at all, and thus busybox wget will not be able to rely on it

I think that adding openssl to minimal builds will cause a lot of friction in the community, so I'd rather not go that path

I suggest that to cause the least amount of friction, I will submit a patch that enables busybox's CONFIG_FEATURE_WGET_OPENSSL for all builds

This means that in builds WITH openssl (ex. sato) the issue will be completely fixed, and in builds WITHOUT openssl, busybox will fallback to using the internal (insecure) client which will print out a message "note: TLS certificate validation not implemented"

Also note that busybox does not rely in any way on the OpenSSL library (it just executes the standalone binary, if it is found) so we shouldn't have linkage issues is CONFIG_FEATURE_WGET_OPENSSL is enabled but OpenSSL is not getting built

WDYT? Makes sense?
Comment 16 Randy MacLeod 2021-04-20 01:27:42 UTC
Makes sense to me. Thanks Shachar.
Comment 17 Randy MacLeod 2021-04-20 01:29:50 UTC
I don't see the patch yet (21:30 ET). Maybe it's in the mail! ;-)
Comment 18 Shachar Menashe 2021-04-20 06:03:55 UTC
Oh, just look at the link I sent -
https://lists.yoctoproject.org/g/yocto-security/topic/patch_busybox_use_openssl/82166345?p=,,,20,0,0,0::recentpostdate%2Fsticky,,,20,2,0,82166345

Again, in this case the patch really comes out as minimal (just enabling CONFIG_FEATURE_WGET_OPENSSL for all builds)
Comment 19 Shachar Menashe 2021-04-20 18:49:44 UTC
Some extra information about the patch I submitted - 

By enabling the busybox feature CONFIG_FEATURE_WGET_OPENSSL, in builds WITH openssl (ex. "sato" build) 
the issue will be completely fixed, and in builds WITHOUT openssl, busybox will fallback 
to using the internal (insecure) client which will print out a message 
"note: TLS certificate validation not implemented" 

Note that busybox does not rely in any way on the OpenSSL library 
(it just executes the standalone binary, if it is found) so 
we shouldn't have linkage issues if CONFIG_FEATURE_WGET_OPENSSL is enabled but OpenSSL is not getting built in this particular build (ex. "minimal" build)
Comment 20 Randy MacLeod 2021-04-29 14:37:26 UTC
Shachar, it seems like you have agreement with Andre so I'm moving this to 3.4-M1.
Comment 21 akuster 2021-08-12 22:19:15 UTC
the busybox fix to address this is:
https://git.busybox.net/busybox/commit/?id=45fa3f18adf57ef9d743038743d9c90573aeeb91
Comment 22 Randy MacLeod 2021-08-12 23:29:45 UTC
Thanks Armin.

$ cd .../busybox.git && git pull
$ git branch -a --contains 45fa3f18adf57ef9d743038743d9c90573aeeb91
* 1_33_stable
  master
  remotes/origin/1_32_stable
  remotes/origin/1_33_stable
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
$ git tag --contains 45fa3f18adf57ef9d743038743d9c90573aeeb91
1_32_0
1_32_1
1_33_0
1_33_1

and we have 1.33.1:
http://cgit.openembedded.org/openembedded-core/commit/meta/recipes-core/busybox/busybox_1.33.1.bb?id=544236b12a72ee5be5ef0147249ead112082b871

so the questions I have are:
1. is the code is enabled for YP by default and
2. do we want to backport the fix to previous releases?
Comment 23 akuster 2021-08-26 14:31:46 UTC
(In reply to comment #22)
> Thanks Armin.
> 
> $ cd .../busybox.git && git pull
> $ git branch -a --contains 45fa3f18adf57ef9d743038743d9c90573aeeb91
> * 1_33_stable
>   master
>   remotes/origin/1_32_stable
>   remotes/origin/1_33_stable
>   remotes/origin/HEAD -> origin/master
>   remotes/origin/master
> $ git tag --contains 45fa3f18adf57ef9d743038743d9c90573aeeb91
> 1_32_0
> 1_32_1
> 1_33_0
> 1_33_1
> 
> and we have 1.33.1:
> http://cgit.openembedded.org/openembedded-core/commit/meta/recipes-core/
> busybox/busybox_1.33.1.bb?id=544236b12a72ee5be5ef0147249ead112082b871
> 
> so the questions I have are:
> 1. is the code is enabled for YP by default and
> 2. do we want to backport the fix to previous releases?
Hardknott 1.32.0
Dunfell 1.31.1 so dunfell needs this. I can send a patch for dunfell
Comment 24 Randy MacLeod 2021-10-21 14:35:39 UTC
Shakjar, Armin,

Do we have consensus about how to handle this bug?
I'm reluctant to keep moving the bug to newer releases...
Comment 25 Shachar Menashe 2021-10-21 21:42:23 UTC
Armin, do you think it makes sense to replace BusyBox's wget with GNU wget? (I see there's already a recipe for that)
This should solve the issue and retain compatibility
Comment 26 Randy MacLeod 2022-06-02 14:34:42 UTC
We think this is fixed in newer busybox releases. Armin to look into it.
Comment 27 Randy MacLeod 2022-10-20 14:33:46 UTC
This may have been fixed. I just have to find the time to confirm.
Comment 28 Randy MacLeod 2023-04-13 14:27:11 UTC
From a recent poky build:
$ grep WGET_OPENSSL tmp/work/core2-64-poky-linux/busybox/1.36.0-r0/busybox-1.36.0/.config
# CONFIG_FEATURE_WGET_OPENSSL is not set

I'll enable it and send a patch.
Comment 29 Richard Purdie 2024-07-12 13:52:15 UTC
Patch sent for master to switch to the openssl option.