Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 889878 (CVE-2022-3715) - <app-shells/bash-5.2_p15-r2: heap buffer overflow yielding "memory problems"
Summary: <app-shells/bash-5.2_p15-r2: heap buffer overflow yielding "memory problems"
Status: IN_PROGRESS
Alias: CVE-2022-3715
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Security
URL: https://bugzilla.redhat.com/show_bug....
Whiteboard: ?? [stable?]
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-05 18:55 UTC by John Helmert III
Modified: 2023-04-30 23:49 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2023-01-05 18:55:43 UTC
CVE-2022-3715:

A flaw was found in the bash package, where a heap-buffer overflow can occur in valid parameter_transform. This issue may lead to memory problems.

No idea about a patch. Reported upstream at: https://lists.gnu.org/archive/html/bug-bash/2022-08/msg00147.html
Comment 1 Allen Webb 2023-03-07 14:59:02 UTC
Red hat is tracking this here:
https://bugzilla.redhat.com/show_bug.cgi?id=2126720

And links to the mailing list thread with the fix:
https://lists.gnu.org/archive/html/bug-bash/2022-08/msg00147.html

```
   Repeat-By:
   1. Build bash with asan 2. Run with AFL++ crafted input (in attachment)
   Fix:
diff -uprN bash-5.1-orig/subst.c bash-5.1/subst.c
--- bash-5.1-orig/subst.c       2022-08-29 18:56:11.071802865 +0000
+++ bash-5.1/subst.c    2022-08-29 18:56:48.187435415 +0000
@@ -7916,7 +7916,7 @@ static int
 valid_parameter_transform (xform)
      char *xform;
 {
-  if (xform[1])
+  if (xform[0] && xform[1])
     return 0;

   /* check for valid values of xform[0] */

   Kind regards, Ivan Kapranov.
```
Comment 2 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2023-03-11 04:37:32 UTC
Thanks! Any idea about impact?
Comment 3 Allen Webb 2023-03-16 18:22:41 UTC
It is hard to say without seeing what the repro case looks like. Since it is in a shell, it probably already requires significant access in order to reach the bug. In other words an attacker who can already run shell doesn't have much to gain by exploiting a memory bug in the shell interpreter.

Some notable exceptions are
* the potential for a noexec bypasses
* the potential a privileged process already uses shell in a way that could be tricked into matching a repro case

I would consider this worth fixing, but not urgent. It is surprising to me that upstream didn't take the fix (yet).
Comment 4 Mike Gilbert gentoo-dev 2023-03-16 20:52:16 UTC
After reading the message thread, it sounds like the reporter has failed to sufficiently demonstrate that a problem even exists. I suspect they just submitted some fuzzer output without reviewing it for context.
Comment 5 Allen Webb 2023-03-20 20:21:36 UTC
I took a look to see if I could find a way to reach it and the only way seems to be here:
https://github.com/bminor/bash/blob/ec8113b9861375e4e17b3307372569d429dec814/subst.c#L8679


```
if (xform[0] == 0 || valid_parameter_transform (xform) == 0)
```

So the check in the patch is already performed before the only call site for valid_parameter_transform. It could easily become an issue in the future, but I think it is safe to close this.
Comment 6 Mike Gilbert gentoo-dev 2023-03-20 21:28:29 UTC
The `xform[0] == 0 ||` check was added in bash-5.2, which was released a few weeks after the issue was reported on the bash mailing list.
Comment 7 Allen Webb 2023-03-20 21:30:44 UTC
In that case we should either pick that commit or upgrade past the fix.
Comment 8 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2023-04-20 02:20:19 UTC
(In reply to Mike Gilbert from comment #6)
> The `xform[0] == 0 ||` check was added in bash-5.2, which was released a few
> weeks after the issue was reported on the bash mailing list.

So, we have fixed versions in tree? >5.2?
Comment 9 Allen Webb 2023-04-20 13:46:58 UTC
I checked and bash-5.2_p15-r2 has the fix (but it is still not marked stable).
Comment 10 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2023-04-30 23:49:18 UTC
(In reply to Allen Webb from comment #9)
> I checked and bash-5.2_p15-r2 has the fix (but it is still not marked
> stable).

Thanks!