* [PATCH] Fix mml-quoting in responses where pgp-signing is enabled
@ 2012-03-03 22:04 Tim Bielawa
2012-03-03 23:17 ` Tim Bielawa
2012-03-03 23:36 ` Jani Nikula
0 siblings, 2 replies; 10+ messages in thread
From: Tim Bielawa @ 2012-03-03 22:04 UTC (permalink / raw)
To: notmuch
The addition of mml-quote-region (notmuch-mua.el) in 2c6710e3 breaks
automatic signing in replies. When replies are mml-quoted and signing
is enabled by default the "<#part sign=pgpmime>" string will appear on
line 1. This will be consumed during the application of the
mml-quote-region function and transform into the inert string
"<#!part sign=pgpmime>". The result is that responses will no longer
be signed by default.
This fix moves the point forward one line before applying the quoting
function.
Consideration: Clients not signing mail by default. The first line of
their responses would be skipped when the quoting function is
applied. This string takes this general form:
On Sat, 03 Mar 2012 12:55:14 -0800, notmuch-request@notmuchmail.org wrote:
Because the string is generated by notmuch I don't believe this fix
introduces the possibility for malicious mml commands being omitted
from the quoting.
---
emacs/notmuch-mua.el | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 4be7c13..d8ab2c0 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -114,14 +114,25 @@ list."
(goto-char (point-max)))
(insert body)
(push-mark))
- (set-buffer-modified-p nil)
(message-goto-body)
;; Original message may contain (malicious) MML tags. We must
;; properly quote them in the reply. Note that using `point-max'
;; instead of `mark' here is wrong. The buffer may include user's
;; signature which should not be MML-quoted.
- (mml-quote-region (point) (mark)))
+ ;;
+ ;; Note also that we skip the first line of the response as it is
+ ;; either: the "<#part sign=pgpmime>" string when clients use
+ ;; automatic signing, or it is the generated string from notmuch
+ ;; indicating the date and author of the message which is being
+ ;; responded to, "on date x, y z -0000, foo@bar.com wrote:"
+ (forward-line 1)
+ (mml-quote-region (point) (mark))
+
+ ;; Quoting the message may modify the contents of the buffer,
+ ;; however, we shouldn't consider mml-quoting a modification because
+ ;; it's preformed by the mua, not the user.
+ (set-buffer-modified-p nil))
(defun notmuch-mua-forward-message ()
(message-forward)
--
1.7.4.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix mml-quoting in responses where pgp-signing is enabled
2012-03-03 22:04 [PATCH] Fix mml-quoting in responses where pgp-signing is enabled Tim Bielawa
@ 2012-03-03 23:17 ` Tim Bielawa
2012-03-03 23:36 ` Jani Nikula
1 sibling, 0 replies; 10+ messages in thread
From: Tim Bielawa @ 2012-03-03 23:17 UTC (permalink / raw)
To: notmuch
[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]
On Sat, 3 Mar 2012 17:04:22 -0500, Tim Bielawa <tbielawa@redhat.com> wrote:
> The addition of mml-quote-region (notmuch-mua.el) in 2c6710e3 breaks
> automatic signing in replies. When replies are mml-quoted and signing
> is enabled by default the "<#part sign=pgpmime>" string will appear on
> line 1. This will be consumed during the application of the
> mml-quote-region function and transform into the inert string
> "<#!part sign=pgpmime>". The result is that responses will no longer
> be signed by default.
>
> This fix moves the point forward one line before applying the quoting
> function.
>
> Consideration: Clients not signing mail by default. The first line of
> their responses would be skipped when the quoting function is
> applied. This string takes this general form:
>
> On Sat, 03 Mar 2012 12:55:14 -0800, notmuch-request@notmuchmail.org wrote:
>
> Because the string is generated by notmuch I don't believe this fix
> introduces the possibility for malicious mml commands being omitted
> from the quoting.
I suppose I should add that when running the unit tests the relevant
parts still pass:
> PASS Reply within emacs
> PASS Quote MML tags in reply
--
Tim Bielawa, Software Engineer/Scribe
Production Control Team (RDU)
919.332.6411 Cell | IRC: tbielawa
1BA0 4FAB 4C13 FBA0 A036 4958 AD05 E75E 0333 AE37
[-- Attachment #2: Type: application/pgp-signature, Size: 162 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix mml-quoting in responses where pgp-signing is enabled
2012-03-03 22:04 [PATCH] Fix mml-quoting in responses where pgp-signing is enabled Tim Bielawa
2012-03-03 23:17 ` Tim Bielawa
@ 2012-03-03 23:36 ` Jani Nikula
2012-03-04 1:12 ` Tim Bielawa
1 sibling, 1 reply; 10+ messages in thread
From: Jani Nikula @ 2012-03-03 23:36 UTC (permalink / raw)
To: Tim Bielawa, notmuch
On Sat, 3 Mar 2012 17:04:22 -0500, Tim Bielawa <tbielawa@redhat.com> wrote:
> The addition of mml-quote-region (notmuch-mua.el) in 2c6710e3 breaks
> automatic signing in replies. When replies are mml-quoted and signing
> is enabled by default the "<#part sign=pgpmime>" string will appear on
> line 1. This will be consumed during the application of the
> mml-quote-region function and transform into the inert string
> "<#!part sign=pgpmime>". The result is that responses will no longer
> be signed by default.
>
> This fix moves the point forward one line before applying the quoting
> function.
>
> Consideration: Clients not signing mail by default. The first line of
> their responses would be skipped when the quoting function is
> applied. This string takes this general form:
>
> On Sat, 03 Mar 2012 12:55:14 -0800, notmuch-request@notmuchmail.org wrote:
>
> Because the string is generated by notmuch I don't believe this fix
> introduces the possibility for malicious mml commands being omitted
> from the quoting.
Hmm, would it work to mml quote the reply *before* extracting it from
the temp buffer, like below? It would handle not mml quoting the user's
signature too. Completely untested...
BR,
Jani.
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 4be7c13..13244eb 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -95,6 +95,9 @@ list."
(goto-char (point-min))
(setq headers (mail-header-extract)))))
(forward-line 1)
+ ;; Original message may contain (malicious) MML tags. We must
+ ;; properly quote them in the reply.
+ (mml-quote-region (point) (point-max))
(setq body (buffer-substring (point) (point-max))))
;; If sender is non-nil, set the From: header to its value.
(when sender
@@ -116,12 +119,7 @@ list."
(push-mark))
(set-buffer-modified-p nil)
- (message-goto-body)
- ;; Original message may contain (malicious) MML tags. We must
- ;; properly quote them in the reply. Note that using `point-max'
- ;; instead of `mark' here is wrong. The buffer may include user's
- ;; signature which should not be MML-quoted.
- (mml-quote-region (point) (mark)))
+ (message-goto-body))
(defun notmuch-mua-forward-message ()
(message-forward)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Fix mml-quoting in responses where pgp-signing is enabled
2012-03-03 23:36 ` Jani Nikula
@ 2012-03-04 1:12 ` Tim Bielawa
2012-03-04 8:25 ` [PATCH] emacs: fix MML quoting in replies Jani Nikula
0 siblings, 1 reply; 10+ messages in thread
From: Tim Bielawa @ 2012-03-04 1:12 UTC (permalink / raw)
To: Jani Nikula, notmuch
[-- Attachment #1: Type: text/plain, Size: 2802 bytes --]
On Sun, 04 Mar 2012 01:36:29 +0200, Jani Nikula <jani@nikula.org> wrote:
> On Sat, 3 Mar 2012 17:04:22 -0500, Tim Bielawa <tbielawa@redhat.com> wrote:
> > The addition of mml-quote-region (notmuch-mua.el) in 2c6710e3 breaks
> > automatic signing in replies. When replies are mml-quoted and signing
> > is enabled by default the "<#part sign=pgpmime>" string will appear on
> > line 1. This will be consumed during the application of the
> > mml-quote-region function and transform into the inert string
> > "<#!part sign=pgpmime>". The result is that responses will no longer
> > be signed by default.
> >
> > This fix moves the point forward one line before applying the quoting
> > function.
> >
> > Consideration: Clients not signing mail by default. The first line of
> > their responses would be skipped when the quoting function is
> > applied. This string takes this general form:
> >
> > On Sat, 03 Mar 2012 12:55:14 -0800, notmuch-request@notmuchmail.org wrote:
> >
> > Because the string is generated by notmuch I don't believe this fix
> > introduces the possibility for malicious mml commands being omitted
> > from the quoting.
>
> Hmm, would it work to mml quote the reply *before* extracting it from
> the temp buffer, like below? It would handle not mml quoting the user's
> signature too. Completely untested...
>
> BR,
> Jani.
>
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index 4be7c13..13244eb 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -95,6 +95,9 @@ list."
> (goto-char (point-min))
> (setq headers (mail-header-extract)))))
> (forward-line 1)
> + ;; Original message may contain (malicious) MML tags. We must
> + ;; properly quote them in the reply.
> + (mml-quote-region (point) (point-max))
> (setq body (buffer-substring (point) (point-max))))
> ;; If sender is non-nil, set the From: header to its value.
> (when sender
> @@ -116,12 +119,7 @@ list."
> (push-mark))
> (set-buffer-modified-p nil)
>
> - (message-goto-body)
> - ;; Original message may contain (malicious) MML tags. We must
> - ;; properly quote them in the reply. Note that using `point-max'
> - ;; instead of `mark' here is wrong. The buffer may include user's
> - ;; signature which should not be MML-quoted.
> - (mml-quote-region (point) (mark)))
> + (message-goto-body))
>
> (defun notmuch-mua-forward-message ()
> (message-forward)
Works great. Passes unit tests. Definitely a better approach than the
original patch.
> Notmuch test suite complete.
> All 381 tests behaved as expected (2 expected failures).
+1 from me (this message replied to and signed using the new patch)
--
Tim Bielawa
[-- Attachment #2: Type: application/pgp-signature, Size: 162 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] emacs: fix MML quoting in replies
2012-03-04 1:12 ` Tim Bielawa
@ 2012-03-04 8:25 ` Jani Nikula
2012-03-05 0:41 ` Mark Walters
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Jani Nikula @ 2012-03-04 8:25 UTC (permalink / raw)
To: notmuch
The reply MML quoting added in commit ae438cc unintentionally MML
quotes also the signature/encryption MML tags added via
message-setup-hook, causing the reply not to be signed/encrypted.
MML quote just the original message in the temp buffer before
inserting it to the message buffer, to not interfere with message mode
hooks or message construction in general.
See [1] and [2] for bug reports.
Thanks to Tim Bielawa <tbielawa@redhat.com> for testing.
[1] id:"87hay78x6l.fsf@wyzanski.jamesvasile.com"
[2] id:"1330812262-28272-1-git-send-email-tbielawa@redhat.com".
Signed-off-by: Jani Nikula <jani@nikula.org>
---
emacs/notmuch-mua.el | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 4be7c13..13244eb 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -95,6 +95,9 @@ list."
(goto-char (point-min))
(setq headers (mail-header-extract)))))
(forward-line 1)
+ ;; Original message may contain (malicious) MML tags. We must
+ ;; properly quote them in the reply.
+ (mml-quote-region (point) (point-max))
(setq body (buffer-substring (point) (point-max))))
;; If sender is non-nil, set the From: header to its value.
(when sender
@@ -116,12 +119,7 @@ list."
(push-mark))
(set-buffer-modified-p nil)
- (message-goto-body)
- ;; Original message may contain (malicious) MML tags. We must
- ;; properly quote them in the reply. Note that using `point-max'
- ;; instead of `mark' here is wrong. The buffer may include user's
- ;; signature which should not be MML-quoted.
- (mml-quote-region (point) (mark)))
+ (message-goto-body))
(defun notmuch-mua-forward-message ()
(message-forward)
--
1.7.5.4
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] emacs: fix MML quoting in replies
2012-03-04 8:25 ` [PATCH] emacs: fix MML quoting in replies Jani Nikula
@ 2012-03-05 0:41 ` Mark Walters
2012-03-10 14:57 ` Tomi Ollila
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Mark Walters @ 2012-03-05 0:41 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula <jani@nikula.org> wrote:
> The reply MML quoting added in commit ae438cc unintentionally MML
> quotes also the signature/encryption MML tags added via
> message-setup-hook, causing the reply not to be signed/encrypted.
>
> MML quote just the original message in the temp buffer before
> inserting it to the message buffer, to not interfere with message mode
> hooks or message construction in general.
>
> See [1] and [2] for bug reports.
>
> Thanks to Tim Bielawa <tbielawa@redhat.com> for testing.
>
> [1] id:"87hay78x6l.fsf@wyzanski.jamesvasile.com"
> [2] id:"1330812262-28272-1-git-send-email-tbielawa@redhat.com".
LGTM (but I am not really a lisper). I don't sign messages so haven't
tested it but it seems "correct" to only mml-quote the actual body
(i.e. the bit that comes from someone else).
Best wishes
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] emacs: fix MML quoting in replies
2012-03-04 8:25 ` [PATCH] emacs: fix MML quoting in replies Jani Nikula
2012-03-05 0:41 ` Mark Walters
@ 2012-03-10 14:57 ` Tomi Ollila
2012-03-11 1:50 ` David Bremner
2012-03-14 22:08 ` Austin Clements
3 siblings, 0 replies; 10+ messages in thread
From: Tomi Ollila @ 2012-03-10 14:57 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula <jani@nikula.org> wrote:
> The reply MML quoting added in commit ae438cc unintentionally MML
> quotes also the signature/encryption MML tags added via
> message-setup-hook, causing the reply not to be signed/encrypted.
>
> MML quote just the original message in the temp buffer before
> inserting it to the message buffer, to not interfere with message mode
> hooks or message construction in general.
>
> See [1] and [2] for bug reports.
>
> Thanks to Tim Bielawa <tbielawa@redhat.com> for testing.
>
> [1] id:"87hay78x6l.fsf@wyzanski.jamesvasile.com"
> [2] id:"1330812262-28272-1-git-send-email-tbielawa@redhat.com".
>
> Signed-off-by: Jani Nikula <jani@nikula.org>
Looks good to me.
Tomi
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] emacs: fix MML quoting in replies
2012-03-04 8:25 ` [PATCH] emacs: fix MML quoting in replies Jani Nikula
2012-03-05 0:41 ` Mark Walters
2012-03-10 14:57 ` Tomi Ollila
@ 2012-03-11 1:50 ` David Bremner
2012-03-14 22:08 ` Austin Clements
3 siblings, 0 replies; 10+ messages in thread
From: David Bremner @ 2012-03-11 1:50 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula <jani@nikula.org> wrote:
> The reply MML quoting added in commit ae438cc unintentionally MML
> quotes also the signature/encryption MML tags added via
> message-setup-hook, causing the reply not to be signed/encrypted.
pushed,
d
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] emacs: fix MML quoting in replies
2012-03-04 8:25 ` [PATCH] emacs: fix MML quoting in replies Jani Nikula
` (2 preceding siblings ...)
2012-03-11 1:50 ` David Bremner
@ 2012-03-14 22:08 ` Austin Clements
2012-03-15 6:33 ` Jani Nikula
3 siblings, 1 reply; 10+ messages in thread
From: Austin Clements @ 2012-03-14 22:08 UTC (permalink / raw)
To: Jani Nikula, notmuch
On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula <jani@nikula.org> wrote:
> The reply MML quoting added in commit ae438cc unintentionally MML
> quotes also the signature/encryption MML tags added via
> message-setup-hook, causing the reply not to be signed/encrypted.
>
> MML quote just the original message in the temp buffer before
> inserting it to the message buffer, to not interfere with message mode
> hooks or message construction in general.
>
> See [1] and [2] for bug reports.
>
> Thanks to Tim Bielawa <tbielawa@redhat.com> for testing.
>
> [1] id:"87hay78x6l.fsf@wyzanski.jamesvasile.com"
> [2] id:"1330812262-28272-1-git-send-email-tbielawa@redhat.com".
>
> Signed-off-by: Jani Nikula <jani@nikula.org>
> ---
> emacs/notmuch-mua.el | 10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> index 4be7c13..13244eb 100644
> --- a/emacs/notmuch-mua.el
> +++ b/emacs/notmuch-mua.el
> @@ -95,6 +95,9 @@ list."
> (goto-char (point-min))
> (setq headers (mail-header-extract)))))
> (forward-line 1)
> + ;; Original message may contain (malicious) MML tags. We must
> + ;; properly quote them in the reply.
> + (mml-quote-region (point) (point-max))
Under what circumstances can the (re-search-forward "^$" nil t) above
this code fail? If it does fail, is it possible for the (forward-line 1)
to move past an adversary-controlled line of text and fail to quote that
line?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] emacs: fix MML quoting in replies
2012-03-14 22:08 ` Austin Clements
@ 2012-03-15 6:33 ` Jani Nikula
0 siblings, 0 replies; 10+ messages in thread
From: Jani Nikula @ 2012-03-15 6:33 UTC (permalink / raw)
To: Austin Clements; +Cc: notmuch
[-- Attachment #1: Type: text/plain, Size: 1848 bytes --]
On Mar 15, 2012 12:08 AM, "Austin Clements" <amdragon@mit.edu> wrote:
>
> On Sun, 4 Mar 2012 10:25:38 +0200, Jani Nikula <jani@nikula.org> wrote:
> > The reply MML quoting added in commit ae438cc unintentionally MML
> > quotes also the signature/encryption MML tags added via
> > message-setup-hook, causing the reply not to be signed/encrypted.
> >
> > MML quote just the original message in the temp buffer before
> > inserting it to the message buffer, to not interfere with message mode
> > hooks or message construction in general.
> >
> > See [1] and [2] for bug reports.
> >
> > Thanks to Tim Bielawa <tbielawa@redhat.com> for testing.
> >
> > [1] id:"87hay78x6l.fsf@wyzanski.jamesvasile.com"
> > [2] id:"1330812262-28272-1-git-send-email-tbielawa@redhat.com".
> >
> > Signed-off-by: Jani Nikula <jani@nikula.org>
> > ---
> > emacs/notmuch-mua.el | 10 ++++------
> > 1 files changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
> > index 4be7c13..13244eb 100644
> > --- a/emacs/notmuch-mua.el
> > +++ b/emacs/notmuch-mua.el
> > @@ -95,6 +95,9 @@ list."
> > (goto-char (point-min))
> > (setq headers (mail-header-extract)))))
> > (forward-line 1)
> > + ;; Original message may contain (malicious) MML tags. We must
> > + ;; properly quote them in the reply.
> > + (mml-quote-region (point) (point-max))
>
> Under what circumstances can the (re-search-forward "^$" nil t) above
> this code fail? If it does fail, is it possible for the (forward-line 1)
> to move past an adversary-controlled line of text and fail to quote that
> line?
It doesn't matter. The quoting is done between point and point-max, and the
message body to cite is extracted right after quoting using: (setq body
(buffer-substring (point) (point-max)))).
BR,
Jani.
[-- Attachment #2: Type: text/html, Size: 2676 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2012-03-15 6:33 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-03 22:04 [PATCH] Fix mml-quoting in responses where pgp-signing is enabled Tim Bielawa
2012-03-03 23:17 ` Tim Bielawa
2012-03-03 23:36 ` Jani Nikula
2012-03-04 1:12 ` Tim Bielawa
2012-03-04 8:25 ` [PATCH] emacs: fix MML quoting in replies Jani Nikula
2012-03-05 0:41 ` Mark Walters
2012-03-10 14:57 ` Tomi Ollila
2012-03-11 1:50 ` David Bremner
2012-03-14 22:08 ` Austin Clements
2012-03-15 6:33 ` Jani Nikula
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).