CVE-2026-138164 in Gammu
Summary
by MITRE • 11/28/2026
Gammu before 1.45.2 contains a stack-based buffer overflow vulnerability in SaveBackupText() in backtext.c that allows attackers to corrupt stack memory by supplying long text fields. Attackers can craft a backup with long calendar or note fields that, when converted with gammu convertbackup, writes hex digits past the 10,000-byte stack buffer.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 11/28/2026
The vulnerability identified in Gammu versions prior to 1.45.2 represents a critical memory safety failure rooted in improper boundary checking during data processing operations. Specifically, the flaw resides within the SaveBackupText function located in the backtext.c source file. This component is responsible for handling text-based backup files generated by mobile device synchronization tools. The core technical deficiency involves the lack of rigorous validation on input string lengths before they are copied into a fixed-size stack buffer with a capacity of 10,000 bytes. When an attacker crafts a malicious backup file containing excessively long calendar entries or note fields, the application fails to truncate or validate these inputs against the allocated memory limits. Consequently, during the conversion process executed by the gammu convertbackup utility, hex digits representing the oversized text data are written sequentially past the end of the designated stack buffer. This behavior constitutes a classic stack-based buffer overflow, where the excess data overwrites adjacent memory locations on the call stack, potentially including return addresses and saved frame pointers.
From an operational perspective, this vulnerability poses severe risks to system integrity and availability. By corrupting the stack memory, an attacker can manipulate the control flow of the application. If carefully crafted, such as by aligning the overflowed data with shellcode or using Return Oriented Programming techniques, it may allow for arbitrary code execution under the context of the user running the Gammu utility. Even without achieving remote code execution, the corruption of stack memory typically results in immediate application crashes, leading to denial of service conditions. Since backup conversion is often a privileged operation involving sensitive personal data such as contacts and messages, compromising this process could also lead to information disclosure if the attacker can read overwritten memory contents or exploit side-channel effects resulting from the instability.
This vulnerability aligns with Common Weakness Enumeration identifier CWE-121, which describes stack-based buffer overflow vulnerabilities arising from insufficient bounds checking on user-supplied input that is copied into a fixed-size stack buffer. The exploitation vector corresponds to ATT&CK technique T1059, specifically Command and Scripting Interpreter scenarios where an attacker leverages local application flaws to execute arbitrary commands. Additionally, the mechanism of overwriting memory structures relates to CWE-787, which covers out-of-bounds writes that can lead to code execution or data corruption. The attack requires the victim to open a maliciously crafted backup file and initiate the conversion process, indicating an initial access vector that relies on social engineering or compromised storage media rather than direct network exploitation.
Mitigation strategies primarily involve upgrading Gammu to version 1.45.2 or later, where this specific boundary check issue has been resolved in the backtext.c module. Developers should implement strict input validation routines that verify string lengths against buffer capacities before performing memory copy operations. Utilizing safer standard library functions such as strncpy instead of strcpy can prevent unbounded writes. Furthermore, enabling compiler security features like stack canaries (stack protector), Address Sanitizer during development, and Data Execution Prevention at the operating system level provides additional layers of defense that can detect or mitigate exploitation attempts even if similar vulnerabilities exist in other components. Regular auditing of C/C++ code for memory safety issues is essential to prevent recurrence of such low-level memory corruption bugs.