aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2015-10-21 20:22:34 -0700
committerPaul Eggert2015-10-21 20:26:49 -0700
commitf373e812d95e1822833f88db024e011a769998b4 (patch)
tree5cc676ac1723fd2631f356f3c3c2e6c5b5b7105e
parent0bb27cd32e4a6a7fc4485381efc9ff0026e15689 (diff)
downloademacs-f373e812d95e1822833f88db024e011a769998b4.tar.gz
emacs-f373e812d95e1822833f88db024e011a769998b4.zip
New lispref section “Security Considerations”
This attempts to document some of the issues recently discussed on emacs-devel, and to indicate other such issues. The section could be a lot longer. * doc/lispref/os.texi (Security Considerations): New node. * doc/lispref/elisp.texi (Top): * doc/lispref/processes.texi (Shell Arguments): * lisp/subr.el (shell-quote-argument): * src/callproc.c (syms_of_callproc): Reference it.
-rw-r--r--doc/lispref/elisp.texi1
-rw-r--r--doc/lispref/os.texi104
-rw-r--r--doc/lispref/processes.texi2
-rw-r--r--lisp/subr.el3
-rw-r--r--src/callproc.c2
5 files changed, 109 insertions, 3 deletions
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 5ca518ecd5f..2d3548f65ba 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -1487,6 +1487,7 @@ Operating System Interface
1487* Desktop Notifications:: Desktop notifications. 1487* Desktop Notifications:: Desktop notifications.
1488* File Notifications:: File notifications. 1488* File Notifications:: File notifications.
1489* Dynamic Libraries:: On-demand loading of support libraries. 1489* Dynamic Libraries:: On-demand loading of support libraries.
1490* Security Considerations:: Running Emacs in an unfriendly environment.
1490 1491
1491Starting Up Emacs 1492Starting Up Emacs
1492 1493
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 204055d9e78..1925bd544e5 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -37,6 +37,7 @@ terminal and the screen.
37* Desktop Notifications:: Desktop notifications. 37* Desktop Notifications:: Desktop notifications.
38* File Notifications:: File notifications. 38* File Notifications:: File notifications.
39* Dynamic Libraries:: On-demand loading of support libraries. 39* Dynamic Libraries:: On-demand loading of support libraries.
40* Security Considerations:: Running Emacs in an unfriendly environment.
40@end menu 41@end menu
41 42
42@node Starting Up 43@node Starting Up
@@ -2760,3 +2761,106 @@ be loaded through it.
2760This variable is ignored if the given @var{library} is statically 2761This variable is ignored if the given @var{library} is statically
2761linked into Emacs. 2762linked into Emacs.
2762@end defvar 2763@end defvar
2764
2765@node Security Considerations
2766@section Security Considerations
2767@cindex security
2768@cindex hardening
2769
2770Like any application, Emacs can be run in a secure environment, where
2771the operating system enforces rules about access and the like. With
2772some care, Emacs-based applications can also be part of a security
2773perimeter that checks such rules. Although the default settings for
2774Emacs work well for a typical software development environment, they
2775may require adjustment in environments containing untrusted users that
2776may include attackers. Here is a compendium of security issues that
2777may be helpful if you are developing such applications. It is by no
2778means complete; it is intended to give you an idea of the security
2779issues involved, rather than to be a security checklist.
2780
2781@table @asis
2782@item Access control
2783Although Emacs normally respects access permissions of the underlying
2784operating system, in some cases it handles accesses specially. For
2785example, file names can have handlers that treat the files specially,
2786with their own access checking. @xref{Magic File Names}. Also, a
2787buffer can be read-only even if the corresponding file is writeable,
2788and vice versa, which can result in messages such as @samp{File passwd
2789is write-protected; try to save anyway? (yes or no)}. @xref{Read Only
2790Buffers}.
2791
2792@item Authentication
2793Emacs has several functions that deal with passwords, e.g.,
2794@code{password-read}. Although these functions do not attempt to
2795broadcast passwords to the world, their implementations are not proof
2796against determined attackers with access to Emacs internals. For
2797example, even if Elisp code attempts to scrub a password from
2798its memory after using it, remnants of the password may still reside
2799in the garbage-collected free list.
2800
2801@item Code injection
2802Emacs can send commands to many other applications, and applications
2803should take care that strings sent as operands of these commands are
2804not misinterpreted as directives. For example, when sending a shell
2805command to rename a file @var{a} to @var{b}, do not simply use the
2806string @code{mv @var{a} @var{b}}, because either file name might start
2807with @samp{-}, or might contain shell metacharacters like @samp{;}.
2808Although functions like @code{shell-quote-argument} can help avoid
2809this sort of problem, they are not panaceas; for example, on a POSIX
2810platform @code{shell-quote-argument} quotes shell metacharacters but
2811not leading @samp{-}. @xref{Shell Arguments}.
2812
2813@item Coding systems
2814Emacs attempts to infer the coding systems of the files and network
2815connections it accesses. If it makes a mistake, or if the other
2816parties to the network connection disagree with Emacs's deductions,
2817the resulting system could be unreliable. Also, even when it infers
2818correctly, Emacs often can use bytes that other programs cannot. For
2819example, although to Emacs the NUL (all bits zero) byte is just a
2820character like any other, many other applications treat it as a string
2821terminator and mishandle strings or files containing NUL bytes.
2822
2823@item Environment and configuration variables
2824POSIX specifies several environment variables that can affect how
2825Emacs behaves. Any environment variable whose name consists entirely
2826of uppercase ASCII letters, digits, and the underscore may affect the
2827internal behavior of Emacs. Emacs uses several such variables, e.g.,
2828@env{EMACSLOADPATH}. @xref{Library Search}. On some platforms some
2829environment variables (e.g., @env{PATH}, @env{POSIXLY_CORRECT},
2830@env{SHELL}, @env{TMPDIR}) need to have properly-configured values in
2831order to get standard behavior for any utility Emacs might invoke.
2832Even seemingly-benign variables like @env{TZ} may have security
2833implications.
2834
2835Emacs has customization and other variables with similar
2836considerations. For example, if the variable @code{shell-file-name}
2837specifies a shell with nonstandard behavior, an Emacs-based
2838application may misbehave.
2839
2840@item Installation
2841When Emacs is installed, if the installation directory hierarchy can
2842be modified by untrusted users, the application cannot be trusted.
2843This applies also to the directory hierarchies of the programs that
2844Emacs uses, and of the files that Emacs reads and writes.
2845
2846@item Network access
2847Emacs often accesses the network, and you may want to configure it to
2848avoid network accesses that it would normally do. For example, unless
2849you set @code{tramp-mode} to @code{nil}, file names using a certain
2850syntax are interpreted as being network files, and are retrieved
2851across the network. @xref{Top, The Tramp Manual,, tramp, The Tramp
2852Manual}.
2853
2854@item Race conditions
2855Emacs applications have the same sort of race-condition issues that
2856other applications do. For example, even when
2857@code{(file-readable-p "foo.txt")} returns @code{t}, it could be that
2858@file{foo.txt} is unreadable because some other program changed the
2859file's permissions between the call to @code{file-readable-p} and now.
2860
2861@item Resource limits
2862When Emacs exhausts memory or other operating system resources, its
2863behavior can be less reliable, in that computations that ordinarily
2864run to completion may abort back to the top level. This may cause
2865Emacs to neglect operations that it normally would have done.
2866@end table
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 196cb7c1f9b..0ce696ad533 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -180,7 +180,7 @@ and then pass it to a shell for execution.
180Precisely what this function does depends on your operating system. The 180Precisely what this function does depends on your operating system. The
181function is designed to work with the syntax of your system's standard 181function is designed to work with the syntax of your system's standard
182shell; if you use an unusual shell, you will need to redefine this 182shell; if you use an unusual shell, you will need to redefine this
183function. 183function. @xref{Security Considerations}.
184 184
185@example 185@example
186;; @r{This example shows the behavior on GNU and Unix systems.} 186;; @r{This example shows the behavior on GNU and Unix systems.}
diff --git a/lisp/subr.el b/lisp/subr.el
index c903ee3c758..ea926ae1475 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2714,7 +2714,8 @@ Note: :data and :device are currently not supported on Windows."
2714 "Quote ARGUMENT for passing as argument to an inferior shell. 2714 "Quote ARGUMENT for passing as argument to an inferior shell.
2715 2715
2716This function is designed to work with the syntax of your system's 2716This function is designed to work with the syntax of your system's
2717standard shell, and might produce incorrect results with unusual shells." 2717standard shell, and might produce incorrect results with unusual shells.
2718See Info node `(elisp)Security Considerations'."
2718 (cond 2719 (cond
2719 ((eq system-type 'ms-dos) 2720 ((eq system-type 'ms-dos)
2720 ;; Quote using double quotes, but escape any existing quotes in 2721 ;; Quote using double quotes, but escape any existing quotes in
diff --git a/src/callproc.c b/src/callproc.c
index eafd6217c0f..bb21c35dccc 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1660,7 +1660,7 @@ syms_of_callproc (void)
1660 DEFVAR_LISP ("shell-file-name", Vshell_file_name, 1660 DEFVAR_LISP ("shell-file-name", Vshell_file_name,
1661 doc: /* File name to load inferior shells from. 1661 doc: /* File name to load inferior shells from.
1662Initialized from the SHELL environment variable, or to a system-dependent 1662Initialized from the SHELL environment variable, or to a system-dependent
1663default if SHELL is not set. */); 1663default if SHELL is unset. See Info node `(elisp)Security Considerations'. */);
1664 1664
1665 DEFVAR_LISP ("exec-path", Vexec_path, 1665 DEFVAR_LISP ("exec-path", Vexec_path,
1666 doc: /* List of directories to search programs to run in subprocesses. 1666 doc: /* List of directories to search programs to run in subprocesses.