unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: charles@aurox.ch (Charles A. Roelli)
To: 28350@debbugs.gnu.org
Subject: bug#28350: enriched.el code execution
Date: Mon, 04 Sep 2017 21:24:42 +0200	[thread overview]
Message-ID: <m2k21e9shx.fsf@aurox.ch> (raw)

[-- Attachment #1: Type: text/plain, Size: 1658 bytes --]

Enriched mode implements an extension command to the text/enriched
format called "x-display", which stores "display" text properties.
It was added awhile ago:

  commit d9e28c1ca1d95f51a05d052dcf1fe06888d52476
  Author: Gerd Moellmann <gerd@gnu.org>
  Date:   Wed Jul 21 21:43:03 1999 +0000

  (enriched-translations): Add `display' and "x-display".
  (enriched-handle-display-prop): New.
  (enriched-decode-display-prop): New.

It's possible to use this extension command to transparently execute
arbitrary code in an Emacs process that opens a text/enriched file.
For example, if you open a file containing the following contents:

Content-Type: text/enriched
Text-Width: 70

<x-display><param>(when (message "hello world") nil)</param>test</x-display>

Then "hello world" will be printed in the echo area whenever the
"test" text is displayed (which is immediate).  Note that the
s-expression between the <param> tags needs to conform to a "display"
spec: but since there are a few display specs that can execute code,
it's not difficult to craft a file that could have bad effects (shell
commands work, for example).  Additionally, such a file can be
compressed with gzip (thus hiding the contents), and when it is
opened, Emacs will automatically decompress it and apply the display
properties.  Attached is an example file (enriched-bug-example.txt)
that turns the mode line red as soon as you open it.  It works in
23.4, 24.5, 25.2 and master (and possibly earlier versions -- I
haven't tested).

Other extensions in `enriched-translations' of enriched.el may have
similar issues (I don't understand them all, so I hope somebody else
can make sure).


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: enriched-bug-example.txt --]
[-- Type: text/enriched, Size: 157 bytes --]

Content-Type: text/enriched
Text-Width: 70

<x-display><param>(when (set-face-attribute (quote mode-line) nil :background "red") nil)</param>test</x-display>

             reply	other threads:[~2017-09-04 19:24 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-04 19:24 Charles A. Roelli [this message]
2017-09-06 19:25 ` bug#28350: enriched.el code execution Charles A. Roelli
2017-09-07  2:34   ` Eli Zaretskii
2017-09-09 12:23     ` Charles A. Roelli
2017-09-09 13:45       ` Eli Zaretskii
2017-09-09 15:57         ` Charles A. Roelli
2017-09-09 16:55           ` Eli Zaretskii
2017-09-09 20:37             ` Charles A. Roelli
2017-09-10 17:01               ` Eli Zaretskii
2017-09-11 16:32             ` Glenn Morris
2017-09-11 17:01               ` Eli Zaretskii
2017-09-09 22:43 ` Paul Eggert
2017-09-10 18:54   ` Charles A. Roelli
2017-09-10 21:46     ` Paul Eggert
2017-09-11  2:39       ` Eli Zaretskii
2017-09-11 14:22         ` Eli Zaretskii
2017-09-11 15:18     ` Eli Zaretskii
2017-09-11 18:44       ` Charles A. Roelli
2017-09-11 19:07         ` Eli Zaretskii
2017-09-16  9:48           ` Eli Zaretskii
2017-09-11 15:33   ` Glenn Morris
2017-09-11 16:38     ` Paul Eggert
2017-09-11 21:16       ` Glenn Morris
2017-09-12 19:59         ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2k21e9shx.fsf@aurox.ch \
    --to=charles@aurox.ch \
    --cc=28350@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).