Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 889878 (CVE-2022-3715) - app-shells/bash: heap buffer overflow yielding "memory problems"
Summary: app-shells/bash: heap buffer overflow yielding "memory problems"
Alias: CVE-2022-3715
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Security
Whiteboard: ?? [upstream]
Depends on:
Reported: 2023-01-05 18:55 UTC by John Helmert III
Modified: 2023-03-20 21:30 UTC (History)
2 users (show)

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


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

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:
Comment 1 Allen Webb 2023-03-07 14:59:02 UTC
Red hat is tracking this here:

And links to the mailing list thread with the fix:

   1. Build bash with asan 2. Run with AFL++ crafted input (in attachment)
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:

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.