Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2023-28617

CVE-2023-28617: GNU Org Mode RCE Vulnerability

CVE-2023-28617 is a remote code execution vulnerability in GNU Org Mode for Emacs that allows attackers to execute arbitrary commands via shell metacharacters. This article covers technical details, affected versions, and mitigations.

Updated:

CVE-2023-28617 Overview

CVE-2023-28617 is a command injection vulnerability in org-babel-execute:latex within ob-latex.el in Org Mode through version 9.6.1 for GNU Emacs. The flaw allows attackers to execute arbitrary shell commands by crafting a file name or directory name containing shell metacharacters. When a user evaluates a LaTeX source block through Org Babel, the unsanitized path is passed to a shell, triggering execution of the embedded commands. The vulnerability is classified under [CWE-78] (OS Command Injection) and affects GNU Org Mode bundled with GNU Emacs.

Critical Impact

A user opening a malicious Org file or working within an attacker-controlled directory can trigger arbitrary command execution with the privileges of the Emacs process.

Affected Products

  • GNU Org Mode versions up to and including 9.6.1
  • GNU Emacs distributions bundling vulnerable Org Mode releases
  • Debian LTS distributions tracking Org Mode and Emacs packages

Discovery Timeline

  • 2023-03-19 - CVE-2023-28617 published to NVD
  • 2023-05 - Debian LTS advisory released for affected packages
  • 2023-10 - Additional Debian LTS advisory released
  • 2025-02 - Further Debian LTS advisory issued for related packages
  • 2025-11-03 - Last updated in NVD database

Technical Details for CVE-2023-28617

Vulnerability Analysis

The vulnerability resides in the org-babel-execute:latex function inside ob-latex.el, the Org Babel backend for LaTeX source blocks. When Org Mode processes a LaTeX block destined for PDF or image output, it constructs shell commands that reference the current file or output directory. The function fails to properly quote or escape these path values before passing them to a shell. An attacker who controls the file name, buffer name, or working directory can embed shell metacharacters such as backticks, $(), or ; to inject commands.

Exploitation requires local access and user interaction, as the victim must evaluate a LaTeX source block within the malicious context. The impact spans confidentiality, integrity, and availability because injected commands run with the full permissions of the Emacs user. Fixes were committed upstream in commits 8f8ec2cc and a8006ea5 to the Org Mode repository.

Root Cause

The root cause is improper neutralization of special elements used in an OS command [CWE-78]. The LaTeX execution path interpolates file and directory names directly into shell command strings without applying shell-quote-argument or equivalent escaping. Any metacharacter present in the path is interpreted by the shell.

Attack Vector

An attacker delivers an Org file with a crafted file name, or convinces the user to place an Org file inside a directory whose name contains shell metacharacters. When the user invokes org-babel-execute-src-block on a LaTeX source block, the malicious path is expanded into the constructed shell command and the injected payload runs immediately.

No synthetic exploitation code is provided. Refer to the Org Mode Mailing List Update for the original technical discussion.

Detection Methods for CVE-2023-28617

Indicators of Compromise

  • Org Mode or Emacs files stored under directories whose names contain backticks, $(...), semicolons, or pipe characters
  • Unexpected child processes spawned by emacs such as /bin/sh, bash, curl, wget, or nc
  • Shell history or audit logs showing commands executed from within an Emacs session immediately after evaluating a LaTeX source block

Detection Strategies

  • Audit endpoint telemetry for emacs parent processes spawning shells or network utilities, which is atypical for normal editor usage
  • Inspect file system paths for Org files whose names or parent directories contain shell metacharacters
  • Review Org Babel evaluation logs and *Messages* buffers for malformed LaTeX export commands

Monitoring Recommendations

  • Enable process-creation auditing on developer workstations and forward events to a central analytics pipeline
  • Alert on emacs invoking interpreters such as sh, bash, python, or perl with non-standard arguments
  • Monitor package inventory for Org Mode versions at or below 9.6.1 across Linux developer fleets

How to Mitigate CVE-2023-28617

Immediate Actions Required

  • Upgrade Org Mode to a release containing upstream commits 8f8ec2cc and a8006ea5 or later
  • Apply distribution security updates, including the Debian LTS advisories referenced by GNU Emacs maintainers
  • Avoid opening untrusted Org files or working within directories whose names contain shell metacharacters

Patch Information

The upstream fix is available in the Org Mode repository through the GNU Emacs Commit 8f8ec2cc and GNU Emacs Commit a8006ea5. Debian users should apply the updates from the Debian LTS Advisory May 2023, Debian LTS Advisory October 2023, and Debian LTS Advisory February 2025.

Workarounds

  • Set org-confirm-babel-evaluate to a non-nil value so Emacs prompts before executing any Babel source block
  • Disable LaTeX evaluation by removing latex from org-babel-load-languages until patches are applied
  • Store Org files only in paths free of shell metacharacters and refuse to evaluate code blocks in untrusted files
bash
# Configuration example
;; In ~/.emacs or init.el — require confirmation before evaluating Babel blocks
(setq org-confirm-babel-evaluate t)

;; Remove LaTeX from the list of languages Org Babel will execute
(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (latex . nil)))

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

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

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.