CVE-2026-131959

Arbitrary Emacs Lisp Execution via Crafted .dir‑locals.el

Published Nov 18, 2026 CVSS 3.1 · 7.8 High EPSS < 1% KEV · Not listed
Description
GNU Emacs 31.1 contains a code injection vulnerability in its handling of directory-local variables. A crafted .dir-locals.el can supply a (REGEXP FUNCTION t) entry in auto-mode-alist; when a matching file is opened, Emacs calls FUNCTION before set-auto-mode--dir-local-valid-p validates it, executing arbitrary Emacs Lisp with the privileges of the Emacs process. (Emacs 30.2 is unaffected.)

Analysis

AI-generated

Technical impact

GNU Emacs 31.1 contains a code injection flaw in the handling of directory-local variables. A malicious .dir-locals.el file can include a (REGEXP FUNCTION t) entry in auto-mode-alist, causing Emacs to call FUNCTION before the entry is validated, which runs arbitrary Emacs Lisp code with the privileges of the running Emacs instance.

Affected Systems

GNU Emacs version 31.1 is affected. Emacs 30.2 is not affected. No other versions are indicated as vulnerable in this CVE.

Risk and Exploitability

The vulnerability has a CVSS score of 7.8 and an EPSS score of less than 1 %. It is not listed in the CISA KEV catalog. Exploitation requires a user to open a file in a directory that contains a crafted .dir-locals.el; therefore the attack vector is inferred to be local and relies on untrusted file placement. If successful, an attacker can execute arbitrary Emacs Lisp code in the context of the running Emacs instance.

Remediation

Vendor Solution

Apply the fix from commit 205ae0b0583dbfe09e258164adbc49e130645221 (emacs-31 branch), or upgrade to Emacs 31.2 or later when released.


Vendor Workaround

Do not open files in untrusted directories that contain a .dir-locals.el. Setting enable-dir-local-variables to nil disables directory-local variables.


OpenCVE Recommended Actions

  • Apply the fix from commit 205ae0b0583dbfe09e258164adbc49e130645221 to the Emacs source or install the patched version
  • Upgrade to Emacs 31.2 or later when it becomes available
  • As a temporary workaround, disable directory‑local variables by setting enable‑dir‑local‑variables to nil or avoid opening files in directories that contain a .dir‑locals.el

Generated by OpenCVE AI on November 18, 2026 at 22:06 UTC.

Tracking

Sign in to view the affected projects.

Advisories

No advisories available
History
Type Values Removed Values Added
Title Arbitrary Emacs Lisp Execution via Crafted .dir‑locals.el
Type Values Removed Values Added
Description GNU Emacs 31.1 contains a code injection vulnerability in its handling of directory-local variables. A crafted .dir-locals.el can supply a (REGEXP FUNCTION t) entry in auto-mode-alist; when a matching file is opened, Emacs calls FUNCTION before set-auto-mode--dir-local-valid-p validates it, executing arbitrary Emacs Lisp with the privileges of the Emacs process. (Emacs 30.2 is unaffected.)
First Time appeared Gnu
Gnu emacs
Weaknesses CWE-829
CPEs cpe:2.3:a:gnu:emacs:*:*:*:*:*:*:*:*
Vendors & Products Gnu
Gnu emacs
References
Metrics cvssV3_1

{'score': 7.8, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H'}

Weaknesses
  • CWE-829

    Inclusion of Functionality from Untrusted Control Sphere

Sources

Status
PUBLISHED
Assigner
mitre
Published
Updated
Nov 18, 2026, 3:38 PM
Reserved
Nov 18, 2026, 7:34 AM
Status
Received
Published
Nov 18, 2026, 8:17 AM
Modified
Nov 18, 2026, 4:18 PM