diff options
| author | Eli Zaretskii | 2022-01-20 11:04:41 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2022-01-20 11:04:41 +0200 |
| commit | 21e96ce324f2302ee6fb84d387ceed6911aadd04 (patch) | |
| tree | 460f5e4a7d4f6622fb3f46615030cf2492d16339 | |
| parent | 4768657b3118ee115ea5310ec25042049b92f9ac (diff) | |
| download | emacs-21e96ce324f2302ee6fb84d387ceed6911aadd04.tar.gz emacs-21e96ce324f2302ee6fb84d387ceed6911aadd04.zip | |
Improve documentation of textsec
* lisp/international/textsec-check.el (textsec-check): Doc fixes.
* doc/lispref/text.texi (Suspicious Text): Improve wording and
indexing.
| -rw-r--r-- | doc/lispref/text.texi | 58 | ||||
| -rw-r--r-- | etc/NEWS | 4 | ||||
| -rw-r--r-- | lisp/international/textsec-check.el | 30 |
3 files changed, 60 insertions, 32 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi index e94b1112d70..097c1de4449 100644 --- a/doc/lispref/text.texi +++ b/doc/lispref/text.texi | |||
| @@ -4946,9 +4946,12 @@ It should be somewhat more efficient on larger buffers than | |||
| 4946 | 4946 | ||
| 4947 | @node Suspicious Text | 4947 | @node Suspicious Text |
| 4948 | @section Suspicious Text | 4948 | @section Suspicious Text |
| 4949 | @cindex suspicious text | ||
| 4950 | @cindex insecure text | ||
| 4951 | @cindex security vulnerabilities in text | ||
| 4949 | 4952 | ||
| 4950 | Emacs can display data from many external sources, like mail and web | 4953 | Emacs can display text from many external sources, like email and Web |
| 4951 | pages. Attackers may attempt to confuse the user reading this data by | 4954 | sites. Attackers may attempt to confuse the user reading this text by |
| 4952 | using obfuscated @acronym{URL}s or email addresses, and tricking the | 4955 | using obfuscated @acronym{URL}s or email addresses, and tricking the |
| 4953 | user into visiting a web page they didn't intend to visit, or sending | 4956 | user into visiting a web page they didn't intend to visit, or sending |
| 4954 | an email to the wrong address. | 4957 | an email to the wrong address. |
| @@ -4959,11 +4962,13 @@ also other techniques used, like using bidirectional overrides, or | |||
| 4959 | having an @acronym{HTML} link text that says one thing, while the | 4962 | having an @acronym{HTML} link text that says one thing, while the |
| 4960 | underlying @acronym{URL} points somewhere else. | 4963 | underlying @acronym{URL} points somewhere else. |
| 4961 | 4964 | ||
| 4962 | To help identify these @dfn{suspicious strings}, Emacs provides a | 4965 | @cindex suspicious text strings |
| 4963 | library to do a number of checks. (See | 4966 | To help identify these @dfn{suspicious text strings}, Emacs provides a |
| 4964 | @url{https://www.unicode.org/reports/tr39/} for the rationale behind | 4967 | library to do a number of checks on text. (See |
| 4965 | the checks that are available.) Packages that present data that might | 4968 | @url{https://www.unicode.org/reports/tr39/, UTS #39: Unicode Security |
| 4966 | be suspicious should use this library. | 4969 | Mechanisms} for the rationale behind the checks that are available and |
| 4970 | more details about them.) Packages that present data that might be | ||
| 4971 | suspicious should use this library to flag suspicious text on display. | ||
| 4967 | 4972 | ||
| 4968 | @vindex textsec-check | 4973 | @vindex textsec-check |
| 4969 | @defun textsec-check object type | 4974 | @defun textsec-check object type |
| @@ -4971,52 +4976,59 @@ This function is the high-level interface function that packages | |||
| 4971 | should use. It respects the @code{textsec-check} user option, which | 4976 | should use. It respects the @code{textsec-check} user option, which |
| 4972 | allows the user to disable the checks. | 4977 | allows the user to disable the checks. |
| 4973 | 4978 | ||
| 4974 | This function checks @var{object} to see if it looks suspicious when | 4979 | This function checks @var{object} (whose data type depends on |
| 4975 | interpreted as a thing of @var{type}. The available types are: | 4980 | @var{type}) to see if it looks suspicious when interpreted as a thing |
| 4981 | of @var{type}. The available types and the corresponding @var{object} | ||
| 4982 | data types are: | ||
| 4976 | 4983 | ||
| 4977 | @table @code | 4984 | @table @code |
| 4978 | @item domain | 4985 | @item domain |
| 4979 | Check whether a domain (e.g., @samp{www.gnu.org} looks suspicious. | 4986 | Check whether a domain (e.g., @samp{www.gnu.org} looks suspicious. |
| 4987 | @var{object} should be a string, the domain name. | ||
| 4980 | 4988 | ||
| 4981 | @item url | 4989 | @item url |
| 4982 | Check whether an @acronym{URL} (e.g., @samp{http://gnu.org/foo/bar}) | 4990 | Check whether an @acronym{URL} (e.g., @samp{http://gnu.org/foo/bar}) |
| 4983 | looks suspicious. | 4991 | looks suspicious. @var{object} should be a string, the @acronym{URL} |
| 4992 | to check. | ||
| 4984 | 4993 | ||
| 4985 | @item link | 4994 | @item link |
| 4986 | Check whether an @acronym{HTML} link (e.g., @samp{<a | 4995 | Check whether an @acronym{HTML} link (e.g., @samp{<a |
| 4987 | href='http://gnu.org'>fsf.org</a>} looks suspicious. In this case, | 4996 | href='http://gnu.org'>fsf.org</a>} looks suspicious. In this case, |
| 4988 | @var{object} should be a @code{cons} cell where the @code{car} is the | 4997 | @var{object} should be a @code{cons} cell where the @code{car} is the |
| 4989 | @acronym{URL} and the @code{cdr} is the link text. The link is deemed | 4998 | @acronym{URL} string, and the @code{cdr} is the link text. The link |
| 4990 | suspicious if the link text contains a domain name, and that domain | 4999 | is deemed suspicious if the link text contains a domain name, and that |
| 4991 | name points to something other than the @acronym{URL}. | 5000 | domain name points to something other than the @acronym{URL}. |
| 4992 | 5001 | ||
| 4993 | @item email-address | 5002 | @item email-address |
| 4994 | Check whether an email address (e.g., @samp{foo@@example.org}) looks | 5003 | Check whether an email address (e.g., @samp{foo@@example.org}) looks |
| 4995 | suspicious. | 5004 | suspicious. @var{object} should be a string. |
| 4996 | 5005 | ||
| 4997 | @item local-address | 5006 | @item local-address |
| 4998 | Check whether the local part of an email address (the bit before the | 5007 | Check whether the local part of an email address (the bit before the |
| 4999 | @samp{@@} sign) looks suspicious. | 5008 | @samp{@@} sign) looks suspicious. @var{object} should be a string. |
| 5000 | 5009 | ||
| 5001 | @item name | 5010 | @item name |
| 5002 | Check whether a name (used in an email address header) looks suspicious. | 5011 | Check whether a name (used in an email address header) looks |
| 5012 | suspicious. @var{object} should be a string. | ||
| 5003 | 5013 | ||
| 5004 | @item email-address-header | 5014 | @item email-address-header |
| 5005 | Check whether a full RFC2822 email address header (e.g., | 5015 | Check whether a full RFC2822 email address header (e.g., |
| 5006 | @samp{=?utf-8?Q?=C3=81?= <foo@@example.com>}) looks suspicious. | 5016 | @samp{=?utf-8?Q?=C3=81?= <foo@@example.com>}) looks suspicious. |
| 5017 | @var{object} should be a string. | ||
| 5007 | @end table | 5018 | @end table |
| 5008 | 5019 | ||
| 5009 | If @var{object} is suspicious, this function will return a string that | 5020 | If @var{object} is suspicious, this function returns a string that |
| 5010 | explains why it is suspicious. If @var{object} is not suspicious, it | 5021 | explains why it is suspicious. If @var{object} is not suspicious, the |
| 5011 | returns @code{nil}. | 5022 | function returns @code{nil}. |
| 5012 | @end defun | 5023 | @end defun |
| 5013 | 5024 | ||
| 5025 | @vindex textsec-suspicious@r{ (face)} | ||
| 5014 | If the text is suspicious, the application should mark the suspicious | 5026 | If the text is suspicious, the application should mark the suspicious |
| 5015 | text with the @code{textsec-suspicious} face, and make the explanation | 5027 | text with the @code{textsec-suspicious} face, and make the explanation |
| 5016 | returned by @code{textsec-check} available to the user. The | 5028 | returned by @code{textsec-check} available to the user in some way |
| 5017 | application might also prompt the user before taking any action on a | 5029 | (for example, in a tooltip). The application might also prompt the |
| 5018 | suspicious string (like sending an email to a suspicious email | 5030 | user for confirmation before taking any action on a suspicious string |
| 5019 | address). | 5031 | (like sending an email to a suspicious email address). |
| 5020 | 5032 | ||
| 5021 | @node GnuTLS Cryptography | 5033 | @node GnuTLS Cryptography |
| 5022 | @section GnuTLS Cryptography | 5034 | @section GnuTLS Cryptography |
| @@ -1023,8 +1023,8 @@ may be used to confuse a user. | |||
| 1023 | If non-nil (which is the default), Emacs packages that are vulnerable | 1023 | If non-nil (which is the default), Emacs packages that are vulnerable |
| 1024 | to attackers trying to confuse the users will use the textsec library | 1024 | to attackers trying to confuse the users will use the textsec library |
| 1025 | to mark suspicious text. For instance shr/eww will mark suspicious | 1025 | to mark suspicious text. For instance shr/eww will mark suspicious |
| 1026 | URLs and links, and Gnus will mark suspicious From addresses, and | 1026 | URLs and links, Gnus will mark suspicious From addresses, and |
| 1027 | Message will query the user if the user is sending mail to a | 1027 | Message mode will query the user if the user is sending mail to a |
| 1028 | suspicious address. If this variable is nil, these checks aren't | 1028 | suspicious address. If this variable is nil, these checks aren't |
| 1029 | performed. | 1029 | performed. |
| 1030 | 1030 | ||
diff --git a/lisp/international/textsec-check.el b/lisp/international/textsec-check.el index f61cc82b5b2..e3662e0d85c 100644 --- a/lisp/international/textsec-check.el +++ b/lisp/international/textsec-check.el | |||
| @@ -29,7 +29,7 @@ | |||
| 29 | :version "29.1") | 29 | :version "29.1") |
| 30 | 30 | ||
| 31 | (defcustom textsec-check t | 31 | (defcustom textsec-check t |
| 32 | "If non-nil, perform some checks on certain texts. | 32 | "If non-nil, perform some security-related checks on text objects. |
| 33 | If nil, these checks are disabled." | 33 | If nil, these checks are disabled." |
| 34 | :type 'boolean | 34 | :type 'boolean |
| 35 | :version "29.1") | 35 | :version "29.1") |
| @@ -40,14 +40,30 @@ If nil, these checks are disabled." | |||
| 40 | 40 | ||
| 41 | ;;;###autoload | 41 | ;;;###autoload |
| 42 | (defun textsec-check (object type) | 42 | (defun textsec-check (object type) |
| 43 | "Test whether OBJECT is suspicious when considered as TYPE. | 43 | "Test whether OBJECT is suspicious for use as TYPE. |
| 44 | If OBJECT is suspicious, a string explaining the possible problem | 44 | If OBJECT is suspicious, return a string explaining the reason |
| 45 | is returned. | 45 | for considering it suspicious, otherwise return nil. |
| 46 | 46 | ||
| 47 | Available types include `url', `link', `domain', `local-address', | 47 | Available values of TYPE and corresponding OBJECTs are: |
| 48 | `name', `email-address', and `email-address-header'. | ||
| 49 | 48 | ||
| 50 | If the `textsec-check' user option is nil, these checks are | 49 | `url' -- a URL; OBJECT should be a URL string. |
| 50 | |||
| 51 | `link' -- an HTML link; OBJECT should be a cons cell | ||
| 52 | of the form (URL . LINK-TEXT). | ||
| 53 | |||
| 54 | `domain' -- a Web domain; OBJECT should be a string. | ||
| 55 | |||
| 56 | `local-address' -- the local part of an email address; OBJECT | ||
| 57 | should be a string. | ||
| 58 | `name' -- the \"display name\" part of an email address; | ||
| 59 | OBJECT should be a string. | ||
| 60 | |||
| 61 | `email-address' -- a full email address; OBJECT should be a string. | ||
| 62 | |||
| 63 | `email-address-header' -- a raw email address header in RFC 2822 format; | ||
| 64 | OBJECT should be a string. | ||
| 65 | |||
| 66 | If the user option `textsec-check' is nil, these checks are | ||
| 51 | disabled, and this function always returns nil." | 67 | disabled, and this function always returns nil." |
| 52 | (if (not textsec-check) | 68 | (if (not textsec-check) |
| 53 | nil | 69 | nil |