CVE-2024-39331 Code injection in n/a

Critical 9.8 Published Updated

Attackers can execute arbitrary code via malicious Org Mode link abbreviations that invoke unsafe functions like shell-command-to-string.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-39331?

CVE-2024-39331 is a critical code injection vulnerability in n/a, published on 23 Jun 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

In Emacs before 29.4, org-link-expand-abbrev in lisp/ol.el expands a %(...) link abbrev even when it specifies an unsafe function, such as shell-command-to-string. This affects Org Mode before 9.7.5.

Weakness: CWE-94

Which versions are affected by CVE-2024-39331?

It affects 1 product.

Linux distribution packages (40)
emacs AlmaLinux:9All versions1:27.2-10.el9_4
emacs-common AlmaLinux:9All versions1:27.2-10.el9_4
emacs-filesystem AlmaLinux:9All versions1:27.2-10.el9_4
emacs-lucid AlmaLinux:9All versions1:27.2-10.el9_4
emacs-nox AlmaLinux:9All versions1:27.2-10.el9_4
emacs Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-common Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-common-debuginfo Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-debuginfo Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-debugsource Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-filesystem Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-lucid Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-lucid-debuginfo Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-nox Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs-nox-debuginfo Red Hat:enterprise_linux:9::appstreamAll versions1:27.2-10.el9_4
emacs Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-common Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-common-debuginfo Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-debuginfo Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-debugsource Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-lucid Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-lucid-debuginfo Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-nox Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-nox-debuginfo Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-terminal Red Hat:rhel_aus:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs Red Hat:rhel_aus:8.6::baseosAll versions1:26.1-7.el8_6.5
emacs-filesystem Red Hat:rhel_aus:8.6::baseosAll versions1:26.1-7.el8_6.5
emacs Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-common Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-common-debuginfo Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-debuginfo Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-debugsource Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-lucid Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-lucid-debuginfo Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-nox Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-nox-debuginfo Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs-terminal Red Hat:rhel_e4s:8.6::appstreamAll versions1:26.1-7.el8_6.5
emacs Red Hat:rhel_e4s:8.6::baseosAll versions1:26.1-7.el8_6.5
emacs-filesystem Red Hat:rhel_e4s:8.6::baseosAll versions1:26.1-7.el8_6.5
emacs Red Hat:rhel_eus:8.8::appstreamAll versions1:26.1-10.el8_8.6

Products include Gnu Emacs.

How do I fix CVE-2024-39331?

Upgrade to a fixed version.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2024-39331 being exploited?

There is no known exploitation of CVE-2024-39331 in the wild and no public exploit code.

Sources

Also known as ALSA-2024:6510, AZL-42868, AZL-42925, CLSA-2024-1728934930, CLSA-2025-1752088235, DEBIAN-CVE-2024-39331 and 16 more.

Is CVE-2024-39331 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free