CVE Professor
/
All CVEs
CVE-2026-138161

CVE-2026-138161 — Gammu — CWE-120

HIGH CVSS 7.8 ⚡ EPSS 0.2% NVD

Gammu before 1.45.2 contains a buffer overflow vulnerability in LoadBackup() that allows attackers to corrupt memory by supplying an overlong MD5 value in a crafted backup file. Attackers can overwrite adjacent phonebook and calendar entry pointers via strcpy() into MD5Original when files are loaded with convertbackup or restore, causing crashes or potential code execution.

Gammu before 1.45.2 contains a buffer overflow vulnerability in LoadBackup() that allows attackers to corrupt memory by supplying an overlong MD5 value in a crafted backup file. Attackers can overwrite adjacent phonebook and calendar entry pointers via strcpy() into MD5Original when files are loaded with convertbackup or restore, causing crashes or potential code execution.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Attack Vector Local AV:L
Attack Complexity Low AC:L
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 9. percentile of all CVEs — higher exploitation probability than most vulnerabilities.
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CVE‑2026‑138161 is a classic buffer‑copy without bounds checking (CWE‑120) in the Gammu mobile‑device management suite (all releases prior to 1.45.2).
The flaw resides in the LoadBackup() routine that parses a backup file during the convertbackup or restore commands.
The routine copies the MD5 hash field (MD5Original) into a fixed‑size local buffer using strcpy():

char MD5Original[33];          /* 32 hex chars + NUL */
strcpy(MD5Original, md5_from_file);   /* no length check */

If the backup file contains an MD5 string longer than 32 characters, the strcpy() overruns the buffer and corrupts the stack.
Adjacent memory contains pointers to phonebook and calendar entries; the overflow can overwrite those pointers. The result is either:

  • Denial‑of‑Service – the program crashes (segmentation fault, stack smashing).
  • Potential Code Execution – if the attacker can control the overwritten pointers to point to malicious code or a shellcode payload, arbitrary code may run with the privileges of the Gammu process.
  • Authentication / Authorization – The vulnerability is local (AV:L) and requires no privilege (PR:N). The only requirement is that the user runs Gammu with the crafted backup file (UI:R). No network or authentication checks are bypassed.


    ⚡ Attack Chain

    StepDescriptionTechnical Detail
    1. Discovery & ReconnaissanceIdentify that the target system runs Gammu < 1.45.2.• Scan the filesystem for gammu binary (which gammu). <br>• Run gammu --version to confirm the exact release. <br>• Verify that the system has a backup/restore workflow (e.g., a cron job or a user‑initiated gammu --restore).
    2. ExploitationDeliver a crafted backup file that triggers the overflow.Crafting the file – The backup format is a simple text file with key/value pairs. The critical field is MD5Original. An overlong value (e.g., 64 hex characters) will overflow. <br>PoC (illustrative) – The exact format is not public, but the following demonstrates the principle: <br>``bash\n# Create a malicious backup file\ncat > /tmp/malicious.backup <<'EOF'\n# Gammu backup file (simplified)\nMD5Original=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef\n# … other fields …\nEOF\n\n# Run Gammu with the crafted file (local user interaction required)\ngammu --restore /tmp/malicious.backup\n`\n*The above is illustrative; the real backup format may differ, but the key idea is to supply an MD5 string longer than 32 characters.* <br>Execution – When gammu --restore parses the file, LoadBackup() copies the oversized MD5 into MD5Original`, overrunning the stack and corrupting the adjacent pointers.
    3. Post‑exploitationAchieve the desired impact.*If the Gammu process runs as a privileged user (e.g., root or a service account), the attacker can: <br>• Crash the service (Denial‑of‑Service). <br>• Overwrite pointers to point to a shellcode buffer placed earlier in the stack, thereby executing arbitrary code with the same privileges. <br>• Corrupt phonebook/calendar data, causing integrity loss.* <br>Privilege Escalation – If Gammu is executed as root (common in automated backup scripts), the attacker can gain root access. <br>Data Exfiltration – By corrupting the phonebook/calendar pointers, the attacker can read or modify sensitive contact or calendar data.

    🌍 Real World Impact

    ImpactCVSS VectorExplanation
    ConfidentialityC:HOverwritten pointers may expose private phonebook or calendar entries to the attacker.
    IntegrityI:HThe attacker can tamper with or delete entries, corrupting the backup data.
    AvailabilityA:HA single crafted backup file can crash Gammu, potentially stopping automated backup/restore jobs or a service that relies on it.

    Because the vulnerability is local and requires the victim to run Gammu with the malicious file, the attack surface is limited to users who have the ability to execute Gammu. In many deployments, Gammu runs as a dedicated service account or is invoked by a scheduled job; if that account has elevated privileges, the risk escalates to privilege escalation.


    🛡️ Remediation & Mitigation

    Affected Versions

    All Gammu releases before 1.45.2.

    Patch / Upgrade

  • Upgrade to Gammu 1.45.2 or later – the upstream patch replaces strcpy() with a bounds‑checked copy (strncpy()/snprintf()) and validates the MD5 length.
  • # Example (Debian/Ubuntu)
    sudo apt-get update
    sudo apt-get install --only-upgrade gammu
    # Verify
    gammu --version   # should show 1.45.2 or newer

    Workarounds (if upgrade is not immediately possible)

    MitigationHow to Apply
    Disable backup/restoreRemove or comment out the convertbackup/restore commands from any automation scripts. If the feature is not needed, uninstall the gammu package or set file permissions to prevent execution.
    Restrict file accessEnsure that only trusted users can write to the directory where backup files are stored. Use chmod 700 /path/to/backup/dir and chown root:root /path/to/backup/dir.
    File integrity monitoringDeploy a host‑based IDS (e.g., OSSEC, Wazuh) to alert on large MD5 fields or abnormal backup file sizes.
    Runtime protectionEnable stack canaries, ASLR, and non‑executable stack on the host. These mitigations reduce the likelihood that an overflow leads to code execution.

    Detection

    IndicatorLog / System Event
    Segmentation fault / core dump/var/log/syslog, /var/log/messages may contain Segmentation fault (core dumped) or * stack smashing detected *.
    Abnormal exit codegammu may exit with code 139 (SIGSEGV).
    Large MD5 fieldCustom monitoring can flag backup files where MD5Original exceeds 32 characters.
    Unexpected Gammu restartsIf Gammu is run as a service, systemd logs may show frequent restarts.

    ⚠️ Urgency

  • CVSS Score: 7.8 (High) – indicates significant risk if exploited.
  • Exploit Complexity: Low (AC:L) – a simple crafted file is enough.
  • User Interaction: Required (UI:R) – the victim must run Gammu with the malicious file.
  • Privilege Needed: None (PR:N) – but the impact is magnified if Gammu runs with elevated privileges.
Priority: Immediate for any environment where Gammu is used, especially if the process runs as root or a privileged service account. The local nature of the flaw means that an attacker with physical or local console access can trigger it; therefore, patching or disabling the vulnerable functionality should be treated as a high‑priority task.
[🤖 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-138161
Technical reference / advisory repository for CVE-2026-138161
Technical reference / advisory repository for CVE-2026-138161
Technical reference / advisory repository for CVE-2026-138161
Technical reference / advisory repository for CVE-2026-138161
CVSS Score
7.8 / 10 · CVSS HIGH
Weakness Types (CWE)
CWE-120
Affected Products (1)
Gammu:Gammu
Related CVEs
9.2
CVE-2026-144500
ASN1SCC before 4.7.0.1 contains a buffer overflow vulnerability in Xer_DecodePrimitiveElement() in asn1crt/asn
6.3
CVE-2026-144889
A vulnerability was detected in vgmstream r2117. Affected by this vulnerability is the function vgmstream_tags
4.3
CVE-2026-144891
A vulnerability has been found in vgmstream up to r2117. This affects the function acb_cat of the file src/met
4.3
CVE-2026-144892
A vulnerability was found in vgmstream up to r2117. This vulnerability affects the function v_strcat of the fi
10.0
CVE-2026-138718
A stack-based buffer overflow vulnerability in the POP3 proxy inspection driver in WatchGuard Endpoint Securit
9.5
CVE-2026-138717
A stack-based buffer overflow vulnerability in WatchGuard Endpoint Security's POP3 traffic inspection allows a
9.3
CVE-2026-144337
osTicket before 1.17.9 and 1.18.0 before 1.18.5 contains an unauthenticated stored cross-site scripting vulner