CVE-2026-138162 in Gammu
Summary
by MITRE • 11/28/2026
Gammu before 1.45.2 contains a stack-based buffer overflow vulnerability in ALCATEL_EncodeString() that allows attackers to overwrite stack memory via oversized encoded phonebook text. Attackers can supply a crafted backup restored with gammu restore or addnew to an attached Alcatel phone, using GSM extension characters to crash Gammu or potentially execute code.
If you want to get the best quality for vulnerability data then you always have to consider VulDB.
Analysis
by VulDB Data Team • 11/28/2026
The vulnerability identified in versions of the Gammu library prior to 1.45.2 represents a critical stack-based buffer overflow within the ALCATEL_EncodeString function. This flaw arises from insufficient boundary checking when processing encoded phonebook data destined for Alcatel mobile devices connected via GSM interfaces. The core technical deficiency lies in the failure of the application to validate the length of input strings against the allocated stack memory buffers before copying them into fixed-size arrays. When an attacker supplies a crafted backup file containing oversized text fields, particularly those utilizing specific GSM extension characters that may expand or alter expected byte lengths during encoding, the function writes data beyond the bounds of the designated buffer space on the call stack. This out-of-bounds write operation corrupts adjacent memory locations, including critical control data such as return addresses and saved frame pointers.
From an operational perspective, this vulnerability poses a severe risk to both system stability and security integrity. The immediate impact is often observed as a denial of service condition where the Gammu process crashes due to stack corruption triggering segmentation faults or similar fatal errors. However, the implications extend far beyond simple application instability. By carefully crafting the overflow payload, an attacker can overwrite the return address on the stack with a pointer to malicious shellcode injected into the same memory space. This technique allows for arbitrary code execution under the privileges of the user running the Gammu process. Given that mobile device management tools often run with elevated permissions or have access to sensitive contact data and communication logs, successful exploitation could lead to full system compromise, allowing attackers to exfiltrate personal information, install persistent malware, or pivot into broader network segments if the host machine is part of a larger infrastructure.
The attack vector typically involves social engineering or supply chain manipulation where an attacker provides a maliciously constructed backup file intended for restoration via gammu restore or addnew commands. The reliance on GSM extension characters adds complexity to detection and mitigation efforts, as these character sets are standard in international telecommunication standards but can be manipulated to bypass naive length checks that do not account for multi-byte encodings or expansion factors inherent in certain encoding schemes. This aligns with common weaknesses found in legacy communication protocols where input validation is often secondary to functional compatibility.
Mitigation strategies must prioritize immediate software updates and robust defensive coding practices. The primary remediation step is upgrading the Gammu library to version 1.45.2 or later, which includes patches for this specific buffer overflow issue by implementing proper bounds checking within the ALCATEL_EncodeString function. For environments where updating is not immediately feasible, administrators should enforce strict input validation policies on any backup files processed through the tool, rejecting entries with unusually large text fields before they reach the encoding layer. Additionally, enabling stack protection mechanisms such as Stack Canaries (stack smashing protector) in compiler configurations can help detect and abort execution when buffer overflows occur, thereby preventing code execution even if the overflow is attempted.
This vulnerability maps directly to CWE-121, which defines a stack-based buffer overflow resulting from writing data beyond the boundary of a fixed-size buffer on the call stack. It also relates to CWE-787, an out-of-bounds write that occurs when memory access exceeds allocated limits without necessarily specifying the exact mechanism like stack vs heap. In terms of adversarial tactics, this exploitation technique corresponds to MITRE ATT&CK techniques related to privilege escalation and command-line interface abuse, specifically leveraging local application vulnerabilities for initial access or lateral movement within a managed device ecosystem. Security teams should treat such legacy library vulnerabilities with high priority due to their potential for remote code execution through seemingly benign administrative actions like restoring phonebook backups.