This adds a comment to Tomi's previous version, and a test. I've
tested the test by commenting out Tomi's fix and running it under
emacs24 ("exploit" runs) and debian emacs 25.2 (which includes the
relevant fix. In the latter case, the test passes with the notmuch
code commented out, because emacs mime-rendering has been fixed. I
consider this reasonable, since it test success means this particular
exploit is blocked.
Dynamically bind enriched-decode-display-prop when inserting
text/enriched part. This complements commit 9b0582383833 for
emacs versions before 24.4 which do not have advice-add
Since emacs 25.3 this particular bug is fixed.
emacs/notmuch-show.el | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 99390277..43debb26 100644
@@ -773,14 +773,19 @@ will return nil if the CID is unknown or cannot be retrieved."
(defun notmuch-show-insert-part-text/x-vcalendar (msg part content-type nth depth button)
(notmuch-show-insert-part-text/calendar msg part content-type nth depth button))
-;; https://bugs.gnu.org/28350 -(defun notmuch-show--enriched-decode-display-prop (start end &optional param)
- (list start end))
-(defun notmuch-show-insert-part-text/enriched (msg part content-type nth depth button)
- (advice-add 'enriched-decode-display-prop :override
+(if (version< emacs-version "25.3")
+ ;; https://bugs.gnu.org/28350 + ;;
+ ;; For newer emacs, we fall back to notmuch-show-insert-part-*/*
+ ;; (see notmuch-show-handlers-for)
+ (defun notmuch-show-insert-part-text/enriched (msg part content-type nth depth button)
+ ;; By requiring enriched below, we ensure that the function enriched-decode-display-prop
+ ;; is defined before it will be shadowed by the letf below. Otherwise the version
+ ;; in enriched.el may be loaded a bit later and used instead (for the first time).
+ (require 'enriched)
+ (letf (((symbol-function 'enriched-decode-display-prop)
+ (lambda (start end &optional param) (list start end))))
+ (notmuch-show-insert-part-*/* msg part content-type nth depth button))))
(defun notmuch-show-get-mime-type-of-application/octet-stream (part)
;; If we can deduce a MIME type from the filename of the attachment,
This test will pass if either the notmuch show mitigation code is
working correctly, or upstream emacs mime handling code has it's own
fix for https://bugs.gnu.org/28350.
test/T450-emacs-show.sh | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh
index d6aa5b41..8db0e49b 100755
@@ -198,5 +198,14 @@ This is an error
This is output"
> This adds a comment to Tomi's previous version, and a test. I've
> tested the test by commenting out Tomi's fix and running it under
> emacs24 ("exploit" runs) and debian emacs 25.2 (which includes the
> relevant fix. In the latter case, the test passes with the notmuch
> code commented out, because emacs mime-rendering has been fixed. I
> consider this reasonable, since it test success means this particular
> exploit is blocked.
Thank you David for doing the work I had in my queue -- and the test!
So, for me was left testing the test:
First I tested on Fedora 27 -- it has emacs 25.3 so the workaround we
provide is not active -- all tests when doing
(cd test && ./T450-emacs-show.sh) PASS.
Next I recompiled the whole stuff on container with Ubuntu 14.04 userspace;
(emacs 23.4.1) With this I had problems breaking the fix so I could get the
test in question FAIL -- I just could not, and finally tested that the
function (read-only-mode) (used in exploit) is not defined in emacs 23.
Since emacs 23 is deprecated IMO it is fine that this test does not test
the behaviour there -- I believe the protection we get testing emacs 24
is good enough here (I've examined the elisp code in question and it is
the same since emacs 23.1 to emacs 24.3 (at least)).
Finally I launched Centos 7.0.1406 based container, now with emacs 24.3.1.
After recompilation and testing that tests PASS normally, I could easily
break the fix and get the test FAIL!