Skip to main content
Vulnerability Database/CVE-2026-54559

CVE-2026-54559: PocketSphinx Buffer Overflow Vulnerability

CVE-2026-54559 is a buffer overflow vulnerability in PocketSphinx that allows attackers to corrupt memory through malicious model files. This post covers technical details, affected versions, and mitigation.

Published:

CVE-2026-54559 Overview

CVE-2026-54559 affects PocketSphinx, a lightweight speech recognition engine maintained by the CMU Sphinx project. Versions prior to 5.1.1 contain memory corruption flaws in the trie language-model loaders in src/lm/ngram_model_trie.c and the acoustic-model loaders in src/mdef.c and src/util/bio.c. The loaders fail to validate boundary conditions in ARPA, DMP, and binary format headers, and use sscanf with unbounded string fields. Loading a corrupted or malicious model triggers stack or heap buffer overflows [CWE-119]. An attacker with write access to a directory referenced by POCKETSPHINX_PATH can plant a malicious model file that PocketSphinx later loads.

Critical Impact

Malicious language or acoustic model files can trigger stack or heap buffer overflows during model loading, leading to memory corruption in any application embedding PocketSphinx.

Affected Products

  • PocketSphinx versions prior to 5.1.1
  • PocketSphinx 5prealpha (no backported patch available)
  • Applications embedding vulnerable PocketSphinx builds

Discovery Timeline

  • 2026-09-14 - CVE-2026-54559 published to NVD
  • 2026-09-15 - Last updated in NVD database

Technical Details for CVE-2026-54559

Vulnerability Analysis

The vulnerability spans two code paths inside PocketSphinx. The trie language-model loaders in src/lm/ngram_model_trie.c parse ARPA, DMP, and binary headers without adequately validating counts, offsets, and section sizes. Malformed header values cause out-of-bounds writes into stack or heap buffers allocated based on those values.

The acoustic-model loaders in src/mdef.c and src/util/bio.c call sscanf with %s format specifiers that lack width limits. Any token in a model file that exceeds the destination buffer size overflows adjacent memory. Because model files are treated as trusted input, no size checks intercept the corruption before it reaches the parser.

Root Cause

Two defects combine to produce the flaw. First, header fields in language-model formats are consumed without cross-checking against the file size or structural invariants. Second, sscanf calls throughout the model parsers omit width specifiers, allowing arbitrary-length tokens to overflow fixed-size character arrays. Both patterns fall under [CWE-119] Improper Restriction of Operations within the Bounds of a Memory Buffer.

Attack Vector

Exploitation requires the attacker to deliver a crafted model file that PocketSphinx loads. The most direct path uses the POCKETSPHINX_PATH environment variable: an attacker able to write to a directory referenced by this variable replaces or adds a model file, and the next PocketSphinx invocation parses the malicious content. Applications that accept user-supplied model paths or ship models fetched from untrusted sources are equally exposed.

c
     }
 
     /* Check for the last non-emitting state N */
-    if ((sscanf(lp, "%s%n", word, &wlen) != 1) || (strcmp(word, "N") != 0))
+    if ((sscanf(lp, "%1023s%n", word, &wlen) != 1) || (strcmp(word, "N") != 0))
         E_FATAL("Missing non-emitting state spec: %s\n", line);
     lp += wlen;
 
     /* Check for end of line */
-    if (sscanf(lp, "%s%n", word, &wlen) == 1)
+    if (sscanf(lp, "%1023s%n", word, &wlen) == 1)
         E_FATAL("Non-empty beyond non-emitting final state: %s\n", line);
     }

Source: GitHub Commit 2a3c0378 — the patch adds %1023s width specifiers to previously unbounded sscanf calls in src/mdef.c, preventing overflow of the 1024-byte word buffer.

Detection Methods for CVE-2026-54559

Indicators of Compromise

  • Unexpected model files (.lm, .lm.bin, .dmp, .mdef) appearing in directories referenced by POCKETSPHINX_PATH
  • Crashes or segmentation faults in processes linked against libpocketsphinx during model load
  • Modifications to acoustic or language model files outside of scheduled deployments

Detection Strategies

  • Inventory hosts and containers that ship PocketSphinx binaries or the libpocketsphinx shared library and compare installed versions against 5.1.1
  • Monitor filesystem writes to directories used as POCKETSPHINX_PATH targets and alert on modifications by non-privileged users
  • Enable core dump collection on services that embed PocketSphinx to catch overflow-induced crashes early

Monitoring Recommendations

  • Track process launches that set or inherit the POCKETSPHINX_PATH environment variable
  • Baseline the hash values of legitimate model files and alert on drift
  • Correlate crash telemetry from voice-enabled applications with recent model file changes

How to Mitigate CVE-2026-54559

Immediate Actions Required

  • Upgrade PocketSphinx to version 5.1.1 or later across all systems and container images
  • Migrate any deployments still running the 5prealpha branch, which has no backported patch
  • Restrict write permissions on directories referenced by POCKETSPHINX_PATH to trusted administrators
  • Audit application supply chains for third-party components that bundle vulnerable PocketSphinx builds

Patch Information

The fix landed in PocketSphinx 5.1.1. The upstream commit 2a3c03788a9973eff548664334fb781e9f4ad4a5 adds width specifiers to sscanf calls in src/mdef.c, src/util/bio.c, and src/feat/feat.c, and tightens boundary validation in the trie language-model loaders. Release notes and downloads are available on the PocketSphinx v5.1.1 release page, and the coordinated disclosure is documented in GitHub Security Advisory GHSA-56r5-2p2f-7cxp.

Workarounds

  • Unset or override POCKETSPHINX_PATH at process start so only vetted model directories are searched
  • Load models exclusively from read-only paths owned by root or an equivalent privileged account
  • Validate model file provenance with cryptographic hashes before invoking recognizer initialization
bash
# Configuration example: pin PocketSphinx to a read-only model directory
sudo install -d -m 0755 -o root -g root /opt/pocketsphinx/models
sudo chmod -R a-w /opt/pocketsphinx/models
export POCKETSPHINX_PATH=/opt/pocketsphinx/models

# Verify installed version is patched
pocketsphinx_batch -help 2>&1 | head -n 1
# Expect: PocketSphinx 5.1.1 or later

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.