CVE-2026-58198
Python vulnerability analysis and mitigation

Overview

CVE-2026-58198 is a symlink-following arbitrary write vulnerability in ChatterBot's UbuntuCorpusTrainer.extract() method, allowing a local attacker to redirect tar archive extraction to an attacker-chosen directory. It affects all ChatterBot versions prior to 1.2.14 (pip package by gunthercox). The vulnerability was disclosed on June 19, 2026, via a GitHub Security Advisory, and published to NVD on July 9, 2026. It carries a CVSS v3.1 base score of 5.5 (Medium) (GitHub Advisory).

Technical details

The root cause is a combination of CWE-59 (Improper Link Resolution Before File Access / Link Following) and CWE-367 (TOCTOU Race Condition). The extract() method uses a predictable, home-rooted output directory (~/ubuntu_data/ubuntu_dialogs) and checks for its existence with os.path.exists() before calling os.makedirs() — but os.path.exists() follows symlinks, so if an attacker pre-plants a symlink at that path, the existence check returns True, makedirs is skipped, and the subsequent tar.extractall(path=self.data_path) writes archive contents through the symlink to the attacker's chosen target directory. The existing safe_extract function validated tar member names against path traversal (zip-slip) using os.path.abspath(), but this resolves symlinks, meaning all clean-named members trivially pass the check while still writing to the attacker-controlled location. A public proof-of-concept exploit is included in the advisory (GitHub Advisory, Fix Commit).

Impact

Successful exploitation allows a local attacker with low privileges to write arbitrary files to any directory writable by the ChatterBot process, including sensitive system or application directories. The primary impact is high confidentiality loss (CVSS C:H), as an attacker could overwrite configuration files, inject malicious scripts (e.g., config.py with OS command execution), or plant files in locations that enable privilege escalation or persistence. Integrity and availability are not directly impacted per the CVSS scoring, but the ability to write attacker-controlled files to arbitrary paths creates significant secondary risk (GitHub Advisory).

Exploitation steps

  1. Reconnaissance: Identify a target system running ChatterBot <= 1.2.13 with the UbuntuCorpusTrainer in use, and confirm local access with at least low-privilege user rights.
  2. Identify predictable path: Determine the target user's home directory and the predictable extraction path (~/ubuntu_data/ubuntu_dialogs).
  3. Plant symlink: Before the victim process runs UbuntuCorpusTrainer.extract(), create the parent directory (~/ubuntu_data/) if it does not exist, then plant a symlink at ~/ubuntu_data/ubuntu_dialogs pointing to the attacker-chosen target directory (e.g., os.symlink('/attacker/target', '~/ubuntu_data/ubuntu_dialogs')).
  4. Trigger extraction: Wait for or cause the ChatterBot process to invoke UbuntuCorpusTrainer.extract() (e.g., by initiating Ubuntu corpus training). The os.path.exists() check follows the symlink and returns True, skipping makedirs.
  5. Achieve arbitrary write: tar.extractall(path=self.data_path) resolves the symlink and writes all archive members (including attacker-crafted payloads such as malicious Python scripts) into the attacker-chosen target directory.
  6. Leverage written files: If the target directory is a Python package path or cron/startup location, the written files (e.g., config.py with os.system('id > /tmp/chatterbot_rce')) may be executed with elevated privileges (GitHub Advisory).

Indicators of compromise

  • File System: Presence of a symbolic link at ~/ubuntu_data/ubuntu_dialogs pointing to an unexpected directory; unexpected files (e.g., .tsv, .py scripts) appearing in directories outside ~/ubuntu_data/; files named config.py or similar with embedded OS commands in application directories.
  • Logs: Application or system logs showing ChatterBot training activity (UbuntuCorpusTrainer) followed by file creation events in unexpected directories; Python tracebacks related to TrainerInitializationException on patched systems (indicating attempted exploitation).
  • Process: Unexpected child processes spawned from the ChatterBot Python process (e.g., /bin/sh, id, curl) if a malicious payload was successfully written and executed.
  • File System: Artifacts such as /tmp/chatterbot_rce (as demonstrated in the PoC) indicating successful command execution via a written payload (GitHub Advisory).

Mitigation and workarounds

Upgrade ChatterBot to version 1.2.14 or later, which adds an explicit symlink check (os.path.islink()) before extraction, raises a TrainerInitializationException if a symlink is detected at data_path, switches is_within_directory to use os.path.realpath() instead of os.path.abspath(), and rejects symlink and hard link members within tar archives. As a workaround for those unable to upgrade immediately, ensure that the ~/ubuntu_data/ directory is created with correct permissions before any training run, and monitor for unexpected symlinks at ~/ubuntu_data/ubuntu_dialogs (GitHub Advisory, Release 1.2.14, Fix Commit).

Community reactions

The vulnerability was reported by researcher "AAtomical" and addressed promptly by the ChatterBot maintainer (gunthercox), who merged the fix on the same day as the advisory (June 19, 2026) via pull request #2445. No significant broader media coverage or notable community commentary beyond the GitHub advisory and standard CVE aggregator pickups has been identified (GitHub Advisory, Fix PR).

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-hmj8-5xmh-5573HIGH7.5
  • Python logoPython
  • libp2p
NoNoJul 24, 2026
GHSA-94p4-4cq8-9g67HIGH7.5
  • Python logoPython
  • gitpython
NoYesJul 24, 2026
GHSA-47w6-gwp4-w6vcHIGH7.1
  • Python logoPython
  • vantage6
NoNoJul 24, 2026
CVE-2026-59714HIGH7.1
  • Python logoPython
  • open-webui
NoYesJul 24, 2026
GHSA-464c-974j-9xm6LOW3.3
  • JavaScript logoJavaScript
  • @aws-cdk/aws-codebuild
NoYesJul 24, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management