aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2016-01-31 15:50:51 -0800
committerPaul Eggert2016-01-31 15:51:19 -0800
commitc90e1b4da89b3cb24a72ee201b83976cc5a3e630 (patch)
tree0cf71d66b1a6c0324ac6a27a7a00f1de2885e8d4
parentcedd7cad092809a97c1ed7fb883b68fa844cea58 (diff)
downloademacs-c90e1b4da89b3cb24a72ee201b83976cc5a3e630.tar.gz
emacs-c90e1b4da89b3cb24a72ee201b83976cc5a3e630.zip
Improve elisp “Security Considerations” doc
* doc/lispref/os.texi (Security Considerations): Mention call-process and rename-file as opposed to shell commands. Add some more cross-references.
-rw-r--r--doc/lispref/os.texi27
1 files changed, 17 insertions, 10 deletions
diff --git a/doc/lispref/os.texi b/doc/lispref/os.texi
index 8e3720eb947..c5e3672a35a 100644
--- a/doc/lispref/os.texi
+++ b/doc/lispref/os.texi
@@ -2959,34 +2959,40 @@ Buffers}.
2959 2959
2960@item Authentication 2960@item Authentication
2961Emacs has several functions that deal with passwords, e.g., 2961Emacs has several functions that deal with passwords, e.g.,
2962@code{password-read}. Although these functions do not attempt to 2962@code{read-passwd}. @xref{Reading a Password}.
2963Although these functions do not attempt to
2963broadcast passwords to the world, their implementations are not proof 2964broadcast passwords to the world, their implementations are not proof
2964against determined attackers with access to Emacs internals. For 2965against determined attackers with access to Emacs internals. For
2965example, even if Elisp code attempts to scrub a password from 2966example, even if Elisp code uses @code{clear-string} to scrub a password from
2966its memory after using it, remnants of the password may still reside 2967its memory after using it, remnants of the password may still reside
2967in the garbage-collected free list. 2968in the garbage-collected free list. @xref{Modifying Strings}.
2968 2969
2969@item Code injection 2970@item Code injection
2970Emacs can send commands to many other applications, and applications 2971Emacs can send commands to many other applications, and applications
2971should take care that strings sent as operands of these commands are 2972should take care that strings sent as operands of these commands are
2972not misinterpreted as directives. For example, when sending a shell 2973not misinterpreted as directives. For example, when using a shell
2973command to rename a file @var{a} to @var{b}, do not simply use the 2974command to rename a file @var{a} to @var{b}, do not simply use the
2974string @code{mv @var{a} @var{b}}, because either file name might start 2975string @code{mv @var{a} @var{b}}, because either file name might start
2975with @samp{-}, or might contain shell metacharacters like @samp{;}. 2976with @samp{-}, or might contain shell metacharacters like @samp{;}.
2976Although functions like @code{shell-quote-argument} can help avoid 2977Although functions like @code{shell-quote-argument} can help avoid
2977this sort of problem, they are not panaceas; for example, on a POSIX 2978this sort of problem, they are not panaceas; for example, on a POSIX
2978platform @code{shell-quote-argument} quotes shell metacharacters but 2979platform @code{shell-quote-argument} quotes shell metacharacters but
2979not leading @samp{-}. @xref{Shell Arguments}. 2980not leading @samp{-}. @xref{Shell Arguments}. Typically it is safer
2981to use @code{call-process} than a subshell. @xref{Synchronous
2982Processes}. And it is safer yet to use builtin Emacs functions; for
2983example, use @code{(rename-file "@var{a}" "@var{b}" t)} instead of
2984invoking @command{mv}. @xref{Changing Files}.
2980 2985
2981@item Coding systems 2986@item Coding systems
2982Emacs attempts to infer the coding systems of the files and network 2987Emacs attempts to infer the coding systems of the files and network
2983connections it accesses. If it makes a mistake, or if the other 2988connections it accesses. @xref{Coding Systems}.
2984parties to the network connection disagree with Emacs's deductions, 2989If Emacs infers incorrectly, or if the other
2990parties to the network connection disagree with Emacs's inferences,
2985the resulting system could be unreliable. Also, even when it infers 2991the resulting system could be unreliable. Also, even when it infers
2986correctly, Emacs often can use bytes that other programs cannot. For 2992correctly, Emacs often can use bytes that other programs cannot. For
2987example, although to Emacs the NUL (all bits zero) byte is just a 2993example, although to Emacs the null byte is just a
2988character like any other, many other applications treat it as a string 2994character like any other, many other applications treat it as a string
2989terminator and mishandle strings or files containing NUL bytes. 2995terminator and mishandle strings or files containing null bytes.
2990 2996
2991@item Environment and configuration variables 2997@item Environment and configuration variables
2992POSIX specifies several environment variables that can affect how 2998POSIX specifies several environment variables that can affect how
@@ -2998,7 +3004,7 @@ environment variables (e.g., @env{PATH}, @env{POSIXLY_CORRECT},
2998@env{SHELL}, @env{TMPDIR}) need to have properly-configured values in 3004@env{SHELL}, @env{TMPDIR}) need to have properly-configured values in
2999order to get standard behavior for any utility Emacs might invoke. 3005order to get standard behavior for any utility Emacs might invoke.
3000Even seemingly-benign variables like @env{TZ} may have security 3006Even seemingly-benign variables like @env{TZ} may have security
3001implications. 3007implications. @xref{System Environment}.
3002 3008
3003Emacs has customization and other variables with similar 3009Emacs has customization and other variables with similar
3004considerations. For example, if the variable @code{shell-file-name} 3010considerations. For example, if the variable @code{shell-file-name}
@@ -3025,6 +3031,7 @@ other applications do. For example, even when
3025@code{(file-readable-p "foo.txt")} returns @code{t}, it could be that 3031@code{(file-readable-p "foo.txt")} returns @code{t}, it could be that
3026@file{foo.txt} is unreadable because some other program changed the 3032@file{foo.txt} is unreadable because some other program changed the
3027file's permissions between the call to @code{file-readable-p} and now. 3033file's permissions between the call to @code{file-readable-p} and now.
3034@xref{Testing Accessibility}.
3028 3035
3029@item Resource limits 3036@item Resource limits
3030When Emacs exhausts memory or other operating system resources, its 3037When Emacs exhausts memory or other operating system resources, its