diff options
| author | Paul Eggert | 2016-01-31 15:50:51 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-01-31 15:51:19 -0800 |
| commit | c90e1b4da89b3cb24a72ee201b83976cc5a3e630 (patch) | |
| tree | 0cf71d66b1a6c0324ac6a27a7a00f1de2885e8d4 | |
| parent | cedd7cad092809a97c1ed7fb883b68fa844cea58 (diff) | |
| download | emacs-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.texi | 27 |
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 |
| 2961 | Emacs has several functions that deal with passwords, e.g., | 2961 | Emacs 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}. |
| 2963 | Although these functions do not attempt to | ||
| 2963 | broadcast passwords to the world, their implementations are not proof | 2964 | broadcast passwords to the world, their implementations are not proof |
| 2964 | against determined attackers with access to Emacs internals. For | 2965 | against determined attackers with access to Emacs internals. For |
| 2965 | example, even if Elisp code attempts to scrub a password from | 2966 | example, even if Elisp code uses @code{clear-string} to scrub a password from |
| 2966 | its memory after using it, remnants of the password may still reside | 2967 | its memory after using it, remnants of the password may still reside |
| 2967 | in the garbage-collected free list. | 2968 | in the garbage-collected free list. @xref{Modifying Strings}. |
| 2968 | 2969 | ||
| 2969 | @item Code injection | 2970 | @item Code injection |
| 2970 | Emacs can send commands to many other applications, and applications | 2971 | Emacs can send commands to many other applications, and applications |
| 2971 | should take care that strings sent as operands of these commands are | 2972 | should take care that strings sent as operands of these commands are |
| 2972 | not misinterpreted as directives. For example, when sending a shell | 2973 | not misinterpreted as directives. For example, when using a shell |
| 2973 | command to rename a file @var{a} to @var{b}, do not simply use the | 2974 | command to rename a file @var{a} to @var{b}, do not simply use the |
| 2974 | string @code{mv @var{a} @var{b}}, because either file name might start | 2975 | string @code{mv @var{a} @var{b}}, because either file name might start |
| 2975 | with @samp{-}, or might contain shell metacharacters like @samp{;}. | 2976 | with @samp{-}, or might contain shell metacharacters like @samp{;}. |
| 2976 | Although functions like @code{shell-quote-argument} can help avoid | 2977 | Although functions like @code{shell-quote-argument} can help avoid |
| 2977 | this sort of problem, they are not panaceas; for example, on a POSIX | 2978 | this sort of problem, they are not panaceas; for example, on a POSIX |
| 2978 | platform @code{shell-quote-argument} quotes shell metacharacters but | 2979 | platform @code{shell-quote-argument} quotes shell metacharacters but |
| 2979 | not leading @samp{-}. @xref{Shell Arguments}. | 2980 | not leading @samp{-}. @xref{Shell Arguments}. Typically it is safer |
| 2981 | to use @code{call-process} than a subshell. @xref{Synchronous | ||
| 2982 | Processes}. And it is safer yet to use builtin Emacs functions; for | ||
| 2983 | example, use @code{(rename-file "@var{a}" "@var{b}" t)} instead of | ||
| 2984 | invoking @command{mv}. @xref{Changing Files}. | ||
| 2980 | 2985 | ||
| 2981 | @item Coding systems | 2986 | @item Coding systems |
| 2982 | Emacs attempts to infer the coding systems of the files and network | 2987 | Emacs attempts to infer the coding systems of the files and network |
| 2983 | connections it accesses. If it makes a mistake, or if the other | 2988 | connections it accesses. @xref{Coding Systems}. |
| 2984 | parties to the network connection disagree with Emacs's deductions, | 2989 | If Emacs infers incorrectly, or if the other |
| 2990 | parties to the network connection disagree with Emacs's inferences, | ||
| 2985 | the resulting system could be unreliable. Also, even when it infers | 2991 | the resulting system could be unreliable. Also, even when it infers |
| 2986 | correctly, Emacs often can use bytes that other programs cannot. For | 2992 | correctly, Emacs often can use bytes that other programs cannot. For |
| 2987 | example, although to Emacs the NUL (all bits zero) byte is just a | 2993 | example, although to Emacs the null byte is just a |
| 2988 | character like any other, many other applications treat it as a string | 2994 | character like any other, many other applications treat it as a string |
| 2989 | terminator and mishandle strings or files containing NUL bytes. | 2995 | terminator and mishandle strings or files containing null bytes. |
| 2990 | 2996 | ||
| 2991 | @item Environment and configuration variables | 2997 | @item Environment and configuration variables |
| 2992 | POSIX specifies several environment variables that can affect how | 2998 | POSIX 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 |
| 2999 | order to get standard behavior for any utility Emacs might invoke. | 3005 | order to get standard behavior for any utility Emacs might invoke. |
| 3000 | Even seemingly-benign variables like @env{TZ} may have security | 3006 | Even seemingly-benign variables like @env{TZ} may have security |
| 3001 | implications. | 3007 | implications. @xref{System Environment}. |
| 3002 | 3008 | ||
| 3003 | Emacs has customization and other variables with similar | 3009 | Emacs has customization and other variables with similar |
| 3004 | considerations. For example, if the variable @code{shell-file-name} | 3010 | considerations. 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 |
| 3027 | file's permissions between the call to @code{file-readable-p} and now. | 3033 | file'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 |
| 3030 | When Emacs exhausts memory or other operating system resources, its | 3037 | When Emacs exhausts memory or other operating system resources, its |