The analysis started by fetching content from the BusyBox bug tracker URL provided in the references. This revealed an ASAN stack trace and a patch for the vulnerability (CVE-2022-48174).
- The ASAN trace clearly indicated a
dynamic-stack-buffer-overflow in the evaluate_string function in shell/math.c. It also showed that evaluate_string was called by ash_arith in shell/ash.c at line 6030.
- The CVE description explicitly states the vulnerability is in
ash.c:6030.
- The fetched patch content (attachment 9446 from the bug report, corresponding to an early fix attempt bf35d8bd) showed a modification to
evaluate_string in shell/math.c. Specifically, it changed the alloca size for numstack. The line removed by this patch, var_or_num_t *const numstack = alloca((expr_len / 2) * sizeof(numstack[0]));, represents the vulnerable code that inadequately allocated space, leading to the overflow.
- A later comment in the bug report mentioned a different commit (
d417193cf) as the final fix, which further modified the allocation in evaluate_string to alloca(expr_len * sizeof(numstack[0])), confirming the allocation size was the core issue.
Based on this, evaluate_string is identified as the function containing the direct memory corruption vulnerability (insufficient alloca). ash_arith is identified as the function in ash.c that processes the potentially malicious input (the arithmetic expression from the shell) and calls evaluate_string, thereby triggering the vulnerability. Both functions would appear in a runtime profile during exploitation.