aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2025-01-26 14:53:49 +0100
committerStefan Kangas2025-01-31 01:50:22 +0100
commit5485ea6aef91c65a0ce300347db3c0ac138ad550 (patch)
tree27d026d71c3aed9a01c05c906fd0a1bfb2f3bfe3
parentd11488fd6fb72acd9f9356b95b2f905c59a1095d (diff)
downloademacs-5485ea6aef91c65a0ce300347db3c0ac138ad550.tar.gz
emacs-5485ea6aef91c65a0ce300347db3c0ac138ad550.zip
Do not set `trusted-content` in major modes
* lisp/progmodes/elisp-mode.el (lisp-interaction-mode): * lisp/ielm.el (inferior-emacs-lisp-mode): Do not set `trusted-content. * lisp/ielm.el (ielm): * lisp/simple.el (get-scratch-buffer-create): Set `trusted-content` here instead. * lisp/files.el (trusted-content): Doc fix; warn against setting this option to :all in a major or mode mode. Problem reported by Max Nikulin <manikulin@gmail.com>.
-rw-r--r--etc/NEWS3
-rw-r--r--lisp/files.el5
-rw-r--r--lisp/ielm.el4
-rw-r--r--lisp/progmodes/elisp-mode.el3
-rw-r--r--lisp/simple.el4
5 files changed, 12 insertions, 7 deletions
diff --git a/etc/NEWS b/etc/NEWS
index fbfb9086430..da3a1d670e7 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -193,6 +193,9 @@ For example, Flymake's backend for Emacs Lisp consults this option
193and disables itself with an "untrusted content" warning if the file 193and disables itself with an "untrusted content" warning if the file
194is not listed. 194is not listed.
195 195
196Emacs Lisp authors should note that a major or minor mode must never set
197this variable to the ':all' value.
198
196This option is used to fix CVE-2024-53920. See below for details. 199This option is used to fix CVE-2024-53920. See below for details.
197 200
198** Emacs now supports Unicode Standard version 15.1. 201** Emacs now supports Unicode Standard version 15.1.
diff --git a/lisp/files.el b/lisp/files.el
index b64935e8d9e..380721f1fe2 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -724,11 +724,12 @@ enabled (for example, when it is added to a mode hook).
724Each element of the list should be a string: 724Each element of the list should be a string:
725- If it ends in \"/\", it is considered as a directory name and means that 725- If it ends in \"/\", it is considered as a directory name and means that
726 Emacs should trust all the files whose name has this directory as a prefix. 726 Emacs should trust all the files whose name has this directory as a prefix.
727- else it is considered as a file name. 727- Otherwise, it is considered a file name.
728Use abbreviated file names. For example, an entry \"~/mycode/\" means 728Use abbreviated file names. For example, an entry \"~/mycode/\" means
729that Emacs will trust all the files in your directory \"mycode\". 729that Emacs will trust all the files in your directory \"mycode\".
730This variable can also be set to `:all', in which case Emacs will trust 730This variable can also be set to `:all', in which case Emacs will trust
731all files, which opens a gaping security hole." 731all files, which opens a gaping security hole. Emacs Lisp authors
732should note that this value must never be set by a major or minor mode."
732 :type '(choice (repeat :tag "List" file) 733 :type '(choice (repeat :tag "List" file)
733 (const :tag "Trust everything (DANGEROUS!)" :all)) 734 (const :tag "Trust everything (DANGEROUS!)" :all))
734 :version "30.1") 735 :version "30.1")
diff --git a/lisp/ielm.el b/lisp/ielm.el
index 561185a738a..b3cd02b4dc0 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -580,7 +580,6 @@ Customized bindings may be defined in `ielm-map', which currently contains:
580 ielm-fontify-input-enable 580 ielm-fontify-input-enable
581 (comint-fontify-input-mode)) 581 (comint-fontify-input-mode))
582 582
583 (setq-local trusted-content :all)
584 (setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt))) 583 (setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt)))
585 (setq-local paragraph-separate "\\'") 584 (setq-local paragraph-separate "\\'")
586 (setq-local paragraph-start comint-prompt-regexp) 585 (setq-local paragraph-start comint-prompt-regexp)
@@ -684,7 +683,8 @@ See `inferior-emacs-lisp-mode' for details."
684 (unless (comint-check-proc buf-name) 683 (unless (comint-check-proc buf-name)
685 (with-current-buffer (get-buffer-create buf-name) 684 (with-current-buffer (get-buffer-create buf-name)
686 (unless (zerop (buffer-size)) (setq old-point (point))) 685 (unless (zerop (buffer-size)) (setq old-point (point)))
687 (inferior-emacs-lisp-mode))) 686 (inferior-emacs-lisp-mode)
687 (setq-local trusted-content :all)))
688 (pop-to-buffer-same-window buf-name) 688 (pop-to-buffer-same-window buf-name)
689 (when old-point (push-mark old-point)))) 689 (when old-point (push-mark old-point))))
690 690
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 59c33c09f0f..a573d9ef864 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1337,8 +1337,7 @@ Semicolons start comments.
1337 1337
1338\\{lisp-interaction-mode-map}" 1338\\{lisp-interaction-mode-map}"
1339 :abbrev-table nil 1339 :abbrev-table nil
1340 (setq-local lexical-binding t) 1340 (setq-local lexical-binding t))
1341 (setq-local trusted-content :all))
1342 1341
1343;;; Emacs Lisp Byte-Code mode 1342;;; Emacs Lisp Byte-Code mode
1344 1343
diff --git a/lisp/simple.el b/lisp/simple.el
index da4d20e4f78..152a8c451ac 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -11154,7 +11154,9 @@ too short to have a dst element.
11154 (when initial-scratch-message 11154 (when initial-scratch-message
11155 (insert (substitute-command-keys initial-scratch-message)) 11155 (insert (substitute-command-keys initial-scratch-message))
11156 (set-buffer-modified-p nil)) 11156 (set-buffer-modified-p nil))
11157 (funcall initial-major-mode)) 11157 (funcall initial-major-mode)
11158 (when (eq initial-major-mode 'lisp-interaction-mode)
11159 (setq-local trusted-content :all)))
11158 scratch))) 11160 scratch)))
11159 11161
11160(defun scratch-buffer () 11162(defun scratch-buffer ()