Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 934736 (CVE-2024-39331) - <app-editors/emacs-{26.3-r19,27.2-r17,28.2-r13,29.3-r3} <app-emacs/org-mode-9.7.5: org-mode command execution vulnerability
Summary: <app-editors/emacs-{26.3-r19,27.2-r17,28.2-r13,29.3-r3} <app-emacs/org-mode-9...
Status: IN_PROGRESS
Alias: CVE-2024-39331
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Security
URL:
Whiteboard: A2 [glsa+]
Keywords:
: 934738 934741 (view as bug list)
Depends on: 934744 934746
Blocks:
  Show dependency tree
 
Reported: 2024-06-22 16:43 UTC by Sam James
Modified: 2024-11-28 00:00 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Larry the Git Cow gentoo-dev 2024-06-22 19:11:21 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1517a3daa51dfa707d64365fb681e15ae7c90a1d

commit 1517a3daa51dfa707d64365fb681e15ae7c90a1d
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2024-06-22 19:02:41 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2024-06-22 19:10:41 +0000

    app-editors/emacs: Backport org-mode fix from Emacs 29.4
    
    Bug: https://bugs.gentoo.org/934736
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 app-editors/emacs/Manifest              |   3 +
 app-editors/emacs/emacs-26.3-r19.ebuild | 382 ++++++++++++++++++++++
 app-editors/emacs/emacs-27.2-r17.ebuild | 449 ++++++++++++++++++++++++++
 app-editors/emacs/emacs-28.2-r13.ebuild | 544 ++++++++++++++++++++++++++++++++
 4 files changed, 1378 insertions(+)

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1da683c58980d2309322d6e4a6a8dc4791dca923

commit 1da683c58980d2309322d6e4a6a8dc4791dca923
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2024-06-22 17:57:48 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2024-06-22 19:10:39 +0000

    app-editors/emacs: add 29.4
    
    Bug: https://bugs.gentoo.org/934736
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 app-editors/emacs/Manifest          |   2 +
 app-editors/emacs/emacs-29.4.ebuild | 631 ++++++++++++++++++++++++++++++++++++
 2 files changed, 633 insertions(+)
Comment 2 Larry the Git Cow gentoo-dev 2024-06-23 10:14:13 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4554e0e224b1a967661ebb5b63b1d35b544617c5

commit 4554e0e224b1a967661ebb5b63b1d35b544617c5
Author:     Ulrich Müller <ulm@gentoo.org>
AuthorDate: 2024-06-23 10:09:36 +0000
Commit:     Ulrich Müller <ulm@gentoo.org>
CommitDate: 2024-06-23 10:13:15 +0000

    app-editors/emacs: Backport org-mode fix from Emacs 29.4
    
    Bug: https://bugs.gentoo.org/934736
    Signed-off-by: Ulrich Müller <ulm@gentoo.org>

 app-editors/emacs/Manifest             |   1 +
 app-editors/emacs/emacs-29.3-r3.ebuild | 631 +++++++++++++++++++++++++++++++++
 2 files changed, 632 insertions(+)
Comment 3 Ulrich Müller gentoo-dev 2024-06-29 20:11:20 UTC
*** Bug 934738 has been marked as a duplicate of this bug. ***
Comment 4 Ulrich Müller gentoo-dev 2024-06-29 20:12:30 UTC
*** Bug 934741 has been marked as a duplicate of this bug. ***
Comment 5 John Helmert III archtester Gentoo Infrastructure gentoo-dev Security 2024-09-22 02:23:41 UTC
Doing a GLSA since the remaining arch stabilizations aren't primaries.
Comment 6 Larry the Git Cow gentoo-dev 2024-09-22 09:04:24 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/data/glsa.git/commit/?id=c5244efc38e02f2f0af5af93f3b49a15bf368da2

commit c5244efc38e02f2f0af5af93f3b49a15bf368da2
Author:     GLSAMaker <glsamaker@gentoo.org>
AuthorDate: 2024-09-22 09:04:08 +0000
Commit:     Hans de Graaff <graaff@gentoo.org>
CommitDate: 2024-09-22 09:04:22 +0000

    [ GLSA 202409-19 ] Emacs, org-mode: Command Execution Vulnerability
    
    Bug: https://bugs.gentoo.org/934736
    Signed-off-by: GLSAMaker <glsamaker@gentoo.org>
    Signed-off-by: Hans de Graaff <graaff@gentoo.org>

 glsa-202409-19.xml | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
Comment 7 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-11-28 00:00:28 UTC
https://news.ycombinator.com/item?id=40768225 has some interesting discussion which I meant to link at the time about the vulnerability. 

https://news.ycombinator.com/item?id=40769363 especially is notable:
"""
What's of greater importance here is not this specific security issue, but the default configuration of MIME handling in Emacs which can turn any unexpected evaluation bug -which we are likely to see more of- into remote code execution. We've had a previous Org security issue in exactly the same vein [1] and the Emacs MIME defaults are still unsafe. Of course, one can change them (non-trivial and related documentation is extremely confusing, see [2] for a possible solution) but really Emacs should not come with these defaults.

The loss of on-by-default functionality such as Org fontification in email message buffers is in no way as important as being wide open to trivial remote code execution.

[1] https://github.com/emacs-mirror/emacs/commit/befa9fcaae29a6c...

[2] https://xristos.sdf.org/fix-gnus-mime.el.txt
"""

Their fix-gnus-mime.el.txt is:
```
;; See: https://www.gnu.org/software/emacs/manual/html_node/emacs-mime/Display-Customization.html#Display-Customization
(setq
 gnus-inhibit-images t
 mm-html-inhibit-images t
 mm-enable-external 'ask
 mm-discouraged-alternatives '("text/html" "text/richtext" "text/enriched" "image/.*")
 mailcap-download-directory "/tmp")

;; See: https://github.com/emacs-mirror/emacs/commit/befa9fcaae29a6c9a283ba371c3c5234c7f644eb

;; Gnus ignores `mm-automatic-display' for text/ derived MIME types, this is not mentioned
;; in the docstring. Ideally, Gnus would default to dumb display of inline text and allow
;; the user to explicitly enable fancy MIME-based major-mode auto-triggering / fontification.
;; The default fail-open model that turns any unexpected evaluation bug into a remote exploit
;; triggered by the user simply opening an email is a disaster.

;; This is the only way I found to stop Gnus from enabling major modes on arbitrary input.
;; I'm keeping text/plain, text/html and disabling everything else.
;; TODO: Write my own `mm-inline-text' replacement.
(setq
 mm-automatic-display '("text/plain")
 mm-inlined-types '("text/plain" "text/html")
 mm-inline-media-tests
 `(("text/plain" mm-inline-text identity)
   ("text/html"
    mm-inline-text-html
    ,(lambda (_handle)
       mm-text-html-renderer))
   (".*" ignore identity)))

;; Show buttonized UI elements for PGP signed messages
(setq gnus-buttonized-mime-types
      '("multipart/alternative" "multipart/encrypted" "multipart/signed" ".*/signed"
        "text/x-org" "text/richtext" "text/enriched"))
```