aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2022-01-20 11:04:41 +0200
committerEli Zaretskii2022-01-20 11:04:41 +0200
commit21e96ce324f2302ee6fb84d387ceed6911aadd04 (patch)
tree460f5e4a7d4f6622fb3f46615030cf2492d16339
parent4768657b3118ee115ea5310ec25042049b92f9ac (diff)
downloademacs-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.texi58
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/international/textsec-check.el30
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
4950Emacs can display data from many external sources, like mail and web 4953 Emacs can display text from many external sources, like email and Web
4951pages. Attackers may attempt to confuse the user reading this data by 4954sites. Attackers may attempt to confuse the user reading this text by
4952using obfuscated @acronym{URL}s or email addresses, and tricking the 4955using obfuscated @acronym{URL}s or email addresses, and tricking the
4953user into visiting a web page they didn't intend to visit, or sending 4956user into visiting a web page they didn't intend to visit, or sending
4954an email to the wrong address. 4957an email to the wrong address.
@@ -4959,11 +4962,13 @@ also other techniques used, like using bidirectional overrides, or
4959having an @acronym{HTML} link text that says one thing, while the 4962having an @acronym{HTML} link text that says one thing, while the
4960underlying @acronym{URL} points somewhere else. 4963underlying @acronym{URL} points somewhere else.
4961 4964
4962To help identify these @dfn{suspicious strings}, Emacs provides a 4965@cindex suspicious text strings
4963library to do a number of checks. (See 4966To help identify these @dfn{suspicious text strings}, Emacs provides a
4964@url{https://www.unicode.org/reports/tr39/} for the rationale behind 4967library to do a number of checks on text. (See
4965the checks that are available.) Packages that present data that might 4968@url{https://www.unicode.org/reports/tr39/, UTS #39: Unicode Security
4966be suspicious should use this library. 4969Mechanisms} for the rationale behind the checks that are available and
4970more details about them.) Packages that present data that might be
4971suspicious 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
4971should use. It respects the @code{textsec-check} user option, which 4976should use. It respects the @code{textsec-check} user option, which
4972allows the user to disable the checks. 4977allows the user to disable the checks.
4973 4978
4974This function checks @var{object} to see if it looks suspicious when 4979This function checks @var{object} (whose data type depends on
4975interpreted as a thing of @var{type}. The available types are: 4980@var{type}) to see if it looks suspicious when interpreted as a thing
4981of @var{type}. The available types and the corresponding @var{object}
4982data types are:
4976 4983
4977@table @code 4984@table @code
4978@item domain 4985@item domain
4979Check whether a domain (e.g., @samp{www.gnu.org} looks suspicious. 4986Check 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
4982Check whether an @acronym{URL} (e.g., @samp{http://gnu.org/foo/bar}) 4990Check whether an @acronym{URL} (e.g., @samp{http://gnu.org/foo/bar})
4983looks suspicious. 4991looks suspicious. @var{object} should be a string, the @acronym{URL}
4992to check.
4984 4993
4985@item link 4994@item link
4986Check whether an @acronym{HTML} link (e.g., @samp{<a 4995Check whether an @acronym{HTML} link (e.g., @samp{<a
4987href='http://gnu.org'>fsf.org</a>} looks suspicious. In this case, 4996href='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
4990suspicious if the link text contains a domain name, and that domain 4999is deemed suspicious if the link text contains a domain name, and that
4991name points to something other than the @acronym{URL}. 5000domain name points to something other than the @acronym{URL}.
4992 5001
4993@item email-address 5002@item email-address
4994Check whether an email address (e.g., @samp{foo@@example.org}) looks 5003Check whether an email address (e.g., @samp{foo@@example.org}) looks
4995suspicious. 5004suspicious. @var{object} should be a string.
4996 5005
4997@item local-address 5006@item local-address
4998Check whether the local part of an email address (the bit before the 5007Check 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
5002Check whether a name (used in an email address header) looks suspicious. 5011Check whether a name (used in an email address header) looks
5012suspicious. @var{object} should be a string.
5003 5013
5004@item email-address-header 5014@item email-address-header
5005Check whether a full RFC2822 email address header (e.g., 5015Check 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
5009If @var{object} is suspicious, this function will return a string that 5020If @var{object} is suspicious, this function returns a string that
5010explains why it is suspicious. If @var{object} is not suspicious, it 5021explains why it is suspicious. If @var{object} is not suspicious, the
5011returns @code{nil}. 5022function returns @code{nil}.
5012@end defun 5023@end defun
5013 5024
5025@vindex textsec-suspicious@r{ (face)}
5014If the text is suspicious, the application should mark the suspicious 5026If the text is suspicious, the application should mark the suspicious
5015text with the @code{textsec-suspicious} face, and make the explanation 5027text with the @code{textsec-suspicious} face, and make the explanation
5016returned by @code{textsec-check} available to the user. The 5028returned by @code{textsec-check} available to the user in some way
5017application might also prompt the user before taking any action on a 5029(for example, in a tooltip). The application might also prompt the
5018suspicious string (like sending an email to a suspicious email 5030user for confirmation before taking any action on a suspicious string
5019address). 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
diff --git a/etc/NEWS b/etc/NEWS
index d3abe349f2a..17ddd6bc186 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1023,8 +1023,8 @@ may be used to confuse a user.
1023If non-nil (which is the default), Emacs packages that are vulnerable 1023If non-nil (which is the default), Emacs packages that are vulnerable
1024to attackers trying to confuse the users will use the textsec library 1024to attackers trying to confuse the users will use the textsec library
1025to mark suspicious text. For instance shr/eww will mark suspicious 1025to mark suspicious text. For instance shr/eww will mark suspicious
1026URLs and links, and Gnus will mark suspicious From addresses, and 1026URLs and links, Gnus will mark suspicious From addresses, and
1027Message will query the user if the user is sending mail to a 1027Message mode will query the user if the user is sending mail to a
1028suspicious address. If this variable is nil, these checks aren't 1028suspicious address. If this variable is nil, these checks aren't
1029performed. 1029performed.
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.
33If nil, these checks are disabled." 33If 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.
44If OBJECT is suspicious, a string explaining the possible problem 44If OBJECT is suspicious, return a string explaining the reason
45is returned. 45for considering it suspicious, otherwise return nil.
46 46
47Available types include `url', `link', `domain', `local-address', 47Available values of TYPE and corresponding OBJECTs are:
48`name', `email-address', and `email-address-header'.
49 48
50If 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
66If the user option `textsec-check' is nil, these checks are
51disabled, and this function always returns nil." 67disabled, and this function always returns nil."
52 (if (not textsec-check) 68 (if (not textsec-check)
53 nil 69 nil