Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Bug] Heap Buffer Overflow in FinSH `msh_auto_complete_path` via Oversized Input

Đang mở
#11,839 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@Acen28 đang làm issue này rồi.

Từ ngày 26/9/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

Arch: ARM/AArch64 BSP BSP: STM32 bug Component component: finsh in progress
RT-Thread Version

v5.3.0/git-hash: cda0a63

Affected area

FinSH

Hardware/BSP vendor

STM32

Architecture

ARM / AArch64

Board and hardware details

bsp/stm32/stm32f407-atk-explorer

Develop Toolchain

GCC

Describe the bug

Description
A critical Heap Out-of-Bounds (OOB) Write vulnerability (CWE-122) exists within the RT-Thread FinSH component, specifically in the path auto-completion logic (msh_auto_complete_path or related directory parsing functions).

When a user interacts with the msh shell (e.g., via a serial terminal or a remote network console) and attempts to trigger path auto-completion (typically using the <Tab> key) on an excessively long or deeply nested directory string, the underlying string manipulation routine fails to enforce strict boundary checks.

The function allocates a fixed-size buffer on the heap (often bounded by macros like RT_PATH_MAX or a hardcoded 256 bytes, e.g., full_path). During the concatenation of the current working directory and the user-supplied input, a while loop or strcpy/memcpy equivalent copies the oversized input string past the allocated bounds of the heap buffer.

This silent memory corruption overwrites adjacent heap metadata. The system does not crash immediately upon the OOB write. However, during the next memory allocation or deallocation cycle, the corrupted heap metadata is dereferenced, leading to an immediate HardFault or offering an attacker the potential for Heap-based Arbitrary Code Execution.

Prerequisites to Reproduce

  1. The FinSH/msh component is enabled and accessible to the user/attacker.
  2. The RT_USING_DFS (Device Virtual File System) and RT_USING_DFS_DEVFS are enabled, allowing directory traversal and path completion.

Steps to Reproduce

  1. Boot the RT-Thread system and connect to the FinSH interactive shell (via UART or Telnet).
  2. Input an excessively long string intended as a directory path. For example, input cd / followed by a payload of over 256 'A' characters:
    msh > cd /AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...
  3. Trigger the auto-complete function (usually by sending the \t (Tab) character via the input stream).
  4. The msh_auto_complete_path function attempts to parse and concatenate the path. The oversized string silently overflows the full_path heap buffer.
  5. Execute any subsequent command that requires dynamic memory allocation (e.g., ls or running a network task).
  6. The system throws a HardFault (or MemManage fault) due to corrupted heap metadata during rt_malloc or rt_free.
Other additional context

No response

Ngôn ngữ chính
C
Star
12.3k
Fork
5.5k
Merge trung bình
3 ngày 8 giờ
Pull request đã merge (30 ngày)
27

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của RT-Thread/rt-thread

Tất cả issue của RT-Thread/rt-thread

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.