diff options
| author | Eli Zaretskii | 2017-09-16 12:45:24 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2017-09-16 12:45:24 +0300 |
| commit | a103dbe36022cd2454eaeed96def1c777c049762 (patch) | |
| tree | a3455f3e0ef50b9bbc1085c3199b4434851ebf35 /lisp | |
| parent | 6d6dc246f93486fc8370399b6e1af8a17f371e4f (diff) | |
| download | emacs-a103dbe36022cd2454eaeed96def1c777c049762.tar.gz emacs-a103dbe36022cd2454eaeed96def1c777c049762.zip | |
Disable execution of unsafe Lisp by Enriched Text mode
* src/xdisp.c (handle_display_spec): If the display property is
wrapped in 'disable-eval' form, disable Lisp evaluation while
processing this property.
(handle_single_display_spec): Accept new argument ENABLE_EVAL_P.
If that argument is false, don't evaluate Lisp while processing
display properties.
* lisp/textmodes/enriched.el
(enriched-allow-eval-in-display-props): New defcustom.
(enriched-decode-display-prop): If
enriched-allow-eval-in-display-props is nil, wrap the display
property with 'disable-eval' to disable Lisp evaluation when the
display property is processed for display. (Bug#28350)
* lisp/gnus/mm-view.el (mm-inline-text): Re-enable processing of
enriched text.
* doc/lispref/display.texi (Display Property): Document the
'disable-eval' wrapping of 'display' properties.
* doc/emacs/text.texi (Enriched Properties): Document
'enriched-allow-eval-in-display-props'.
* etc/NEWS: Describe the security issues with Enriched Text mode
and their solution.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/gnus/mm-view.el | 10 | ||||
| -rw-r--r-- | lisp/textmodes/enriched.el | 23 |
2 files changed, 23 insertions, 10 deletions
diff --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index 86e217131ac..d7a41b84930 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el | |||
| @@ -362,12 +362,10 @@ | |||
| 362 | (goto-char (point-max)))) | 362 | (goto-char (point-max)))) |
| 363 | (save-restriction | 363 | (save-restriction |
| 364 | (narrow-to-region b (point)) | 364 | (narrow-to-region b (point)) |
| 365 | ;; Disabled in Emacs 25.3 to avoid execution of arbitrary Lisp | 365 | (when (member type '("enriched" "richtext")) |
| 366 | ;; forms in display properties supported by enriched.el. | 366 | (set-text-properties (point-min) (point-max) nil) |
| 367 | ;; (when (member type '("enriched" "richtext")) | 367 | (ignore-errors |
| 368 | ;; (set-text-properties (point-min) (point-max) nil) | 368 | (enriched-decode (point-min) (point-max)))) |
| 369 | ;; (ignore-errors | ||
| 370 | ;; (enriched-decode (point-min) (point-max)))) | ||
| 371 | (mm-handle-set-undisplayer | 369 | (mm-handle-set-undisplayer |
| 372 | handle | 370 | handle |
| 373 | `(lambda () | 371 | `(lambda () |
diff --git a/lisp/textmodes/enriched.el b/lisp/textmodes/enriched.el index d90c207575b..be5cd6b7310 100644 --- a/lisp/textmodes/enriched.el +++ b/lisp/textmodes/enriched.el | |||
| @@ -147,6 +147,22 @@ them and their old values to `enriched-old-bindings'." | |||
| 147 | :type 'hook | 147 | :type 'hook |
| 148 | :group 'enriched) | 148 | :group 'enriched) |
| 149 | 149 | ||
| 150 | (defcustom enriched-allow-eval-in-display-props nil | ||
| 151 | "If non-nil allow to evaluate arbitrary forms in display properties. | ||
| 152 | |||
| 153 | Enriched mode recognizes display properties of text stored using | ||
| 154 | an extension command to the text/enriched format, \"x-display\". | ||
| 155 | These properties must not, by default, include evaluation of | ||
| 156 | Lisp forms, otherwise they are not applied. Customize this option | ||
| 157 | to t to turn off this safety feature, and allow Enriched mode to | ||
| 158 | apply display properties which evaluate arbitrary Lisp forms. | ||
| 159 | Note, however, that applying unsafe display properties could | ||
| 160 | execute malicious Lisp code, if that code came from an external source." | ||
| 161 | :risky t | ||
| 162 | :type 'boolean | ||
| 163 | :version "26.1" | ||
| 164 | :group 'enriched) | ||
| 165 | |||
| 150 | (defvar enriched-old-bindings nil | 166 | (defvar enriched-old-bindings nil |
| 151 | "Store old variable values that we change when entering mode. | 167 | "Store old variable values that we change when entering mode. |
| 152 | The value is a list of \(VAR VALUE VAR VALUE...).") | 168 | The value is a list of \(VAR VALUE VAR VALUE...).") |
| @@ -503,9 +519,8 @@ the range of text to assign text property SYMBOL with value VALUE." | |||
| 503 | (error nil))))) | 519 | (error nil))))) |
| 504 | (unless prop | 520 | (unless prop |
| 505 | (message "Warning: invalid <x-display> parameter %s" param)) | 521 | (message "Warning: invalid <x-display> parameter %s" param)) |
| 506 | ;; Disabled in Emacs 25.3 to avoid execution of arbitrary Lisp | 522 | (if enriched-allow-eval-in-display-props |
| 507 | ;; forms in display properties stored within enriched text. | 523 | (list start end 'display prop) |
| 508 | ;; (list start end 'display prop))) | 524 | (list start end 'display (list 'disable-eval prop))))) |
| 509 | (list start end))) | ||
| 510 | 525 | ||
| 511 | ;;; enriched.el ends here | 526 | ;;; enriched.el ends here |