CVE-2022-27943 Overview
A stack consumption vulnerability exists in the libiberty/rust-demangle.c component of GNU GCC 11.2. The flaw resides in the demangle_const function and can be triggered when processing specially crafted input, as demonstrated through the nm-new utility. This vulnerability allows an attacker to cause a denial of service condition through excessive stack consumption.
Critical Impact
Attackers can craft malicious input that triggers uncontrolled recursion in the Rust demangling functionality, leading to stack exhaustion and application crashes.
Affected Products
- GNU GCC 11.2
- Fedora 36
Discovery Timeline
- 2022-03-26 - CVE-2022-27943 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2022-27943
Vulnerability Analysis
The vulnerability is classified as CWE-674 (Uncontrolled Recursion), which occurs when the demangle_const function in libiberty/rust-demangle.c processes certain input patterns without adequate recursion depth controls. When parsing Rust-mangled symbols, the demangler can enter a recursive call pattern that consumes stack memory until the process runs out of stack space. This condition is exploitable through tools that invoke the demangling functionality, such as nm-new, when processing maliciously crafted object files or symbol names.
The attack requires local access and user interaction to open or process a malicious file. While the vulnerability does not lead to data confidentiality or integrity impacts, it can cause complete denial of service to the affected application.
Root Cause
The root cause is uncontrolled recursion in the demangle_const function. The function lacks proper bounds checking on recursion depth when processing nested or deeply structured Rust-mangled symbol names. This allows specially crafted input to trigger excessive recursive calls, ultimately exhausting the available stack space and crashing the application.
Attack Vector
The attack vector is local, requiring an attacker to either provide a malicious file for processing or trick a user into opening a crafted binary or object file with a tool that uses the libiberty demangling functionality. The vulnerability can be triggered through utilities like nm, objdump, or other binutils that process symbol names. An attacker could embed malicious symbol names in object files that, when processed, cause stack exhaustion.
The vulnerability mechanism involves recursive parsing of specially constructed Rust-mangled names. When the demangle_const function encounters certain patterns, it recursively calls itself without adequate depth limiting, causing the call stack to grow until system limits are reached.
Detection Methods for CVE-2022-27943
Indicators of Compromise
- Unexpected crashes of binutils tools (nm, objdump, addr2line) when processing object files
- Segmentation faults related to stack overflow in processes using libiberty
- Abnormal memory consumption patterns in development toolchains
- Core dumps indicating stack exhaustion in demangling functions
Detection Strategies
- Monitor for crashes in development toolchains with stack-related error messages
- Implement resource limits (ulimit) on processes that handle untrusted binary files
- Use application crash monitoring to detect patterns of stack exhaustion
- Deploy process sandboxing for tools processing untrusted input
Monitoring Recommendations
- Enable crash reporting and analysis for development environment tools
- Monitor system logs for repeated segmentation faults in binutils processes
- Track unusual resource consumption in build and analysis pipelines
- Review any automated processing of external or untrusted binary artifacts
How to Mitigate CVE-2022-27943
Immediate Actions Required
- Update GNU GCC and binutils to the latest available versions
- Restrict processing of untrusted object files and binaries
- Apply stack size limits to processes handling potentially malicious input
- Review the GCC Bug Report #105039 for specific patch information
Patch Information
The vulnerability has been tracked in the GNU GCC Bugzilla system. System administrators should consult their distribution's package repositories for updated versions. Fedora users should review the Fedora Package Announcement for patched packages. Additional technical details are available in the Sourceware Bug Report #28995.
Workarounds
- Set strict stack size limits using ulimit -s before running tools that process untrusted files
- Sandbox binutils operations using containerization or process isolation
- Avoid processing untrusted or unverified object files with vulnerable versions
- Use alternative demangling tools that implement recursion depth limits
# Configuration example
# Set stack size limit to prevent complete system resource exhaustion
ulimit -s 8192
# Run nm with limited resources on untrusted files
ulimit -s 8192 && nm suspicious_file.o
# Alternative: Use timeout to limit execution time
timeout 30s nm suspicious_file.o
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

