Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dkim_sign: Normalize CRLF->LF for DKIM-Signature #588

Merged
merged 1 commit into from
Apr 13, 2019

Conversation

zmousm
Copy link
Contributor

@zmousm zmousm commented Apr 6, 2019

Mail::DKIM::Signer wraps DKIM-Signature with with \r\n\t; this is the hardcoded Separator passed to Mail::DKIM::TextWrap via Mail::DKIM::KeyValueList. MIME::Tools on the other hand
(MIME::Head::stringify() in particular) encode EOL as plain \n; it is thus necessary to normalize CRLF->LF for DKIM-Signature to avoid confusing the mail agent.

Exim in particular handles line endings by observing these rules of interest:

  • If a bare CR is encountered within a header line, an extra space is added after the line terminator so as not to end the header line. The reasoning behind this is that bare CRs in header lines are most likely either to be mistakes, or people trying to play silly games.
  • If the first header line received in a message ends with CRLF, a subsequent bare LF in a header line is treated in the same way as a bare CR in a header line.

The result can be seen in the following example, where:

  • all headers following DKIM-Signature are indented by one space and are practically lost
  • Exim readds Message-Id and From (using gecos field for sympa system user)
  • DKIM signature is rendered invalid
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=lists.grnet.gr; h=date:to
	:from:message-id:subject:reply-to:sender:list-id:list-help
	:list-subscribe:list-unsubscribe:list-post:list-owner
	:list-archive; s=mysel; [email protected];
	 bh=7uqDQo3EVTnDX6HK/OlpR/tasWM=; b=l7ugudUBhte8kP/LDLh0+jvKlL5K
	ugS+4SduK4gbef68g+E08QjwZT1bF60EmFHd+0OUl6pTFlNxHqXkCphLawr3e1i8
	1ntMEItO50EDPA6FE94VpnFk89Oq+JjYC/hCEQG6mTxSJor9cRBc0oOY3+kPBxqn
	990yRm1gwGTXe0Y=
 Return-path: <[email protected]>
 Envelope-to: [email protected]
 Delivery-date: Thu, 04 Apr 2019 18:28:01 +0300
 Received: from mx0.grnet.gr ([2001:648:2ffc:200::161])
 	by lists.grnet.gr (envelope-from <[email protected]>)
 	with esmtp (Exim 4.89 (Debian GNU/Linux))
 	id 1hC4HZ-0002nI-QY
 	for [email protected]; Thu, 04 Apr 2019 18:28:01 +0300
 Date: Thu, 04 Apr 2019 18:28:01 +0300
 To: [email protected]
 From: [email protected]
 X-Mailer: swaks v20130209.0 jetmore.org/john/code/swaks/
 Message-Id: <[email protected]>
 Subject: [nontasv-test] test Thu, 04 Apr 2019 18:28:01 +0300
 Reply-To: [email protected]
 X-Loop: [email protected]
 X-Sequence: 12
 Errors-To: [email protected]
 Precedence: list
 Precedence: bulk
 Sender: [email protected]
 X-no-archive: yes
 List-Id: <nontasv-test.lists.grnet.gr>
 List-Help: <mailto:[email protected]?subject=help>
 List-Subscribe: <mailto:[email protected]?subject=subscribe%20nontasv-test>
 List-Unsubscribe: <mailto:[email protected]?subject=unsubscribe%20nontasv-test>
 List-Post: <mailto:[email protected]>
 List-Owner: <mailto:[email protected]>
 List-Archive: <http://lists.grnet.gr/sympa/arc/nontasv-test>
 Archived-At: <http://lists.grnet.gr/sympa/arcsearch_id/nontasv-test/2019-04/E1hC4HZ-0002nI-QY%40lists.grnet.gr>
 This is a test mailing
Message-Id: <[email protected]>
From: "Sympa mailing list manager,,," <[email protected]>
Date: Thu, 04 Apr 2019 18:28:04 +0300

Mail::DKIM::Signer wraps DKIM-Signature with with \r\n\t; this
is the hardcoded Separator passed to Mail::DKIM::TextWrap via
Mail::DKIM::KeyValueList. MIME::Tools on the other hand
(MIME::Head::stringify() in particular) encode EOL as plain \n;
it is thus necessary to normalize CRLF->LF for DKIM-Signature to
avoid confusing the mail agent.
@ikedas ikedas added the bug label Apr 6, 2019
@ikedas ikedas added this to the 6.2.44 milestone Apr 9, 2019
@ikedas ikedas merged commit 57d0120 into sympa-community:sympa-6.2 Apr 13, 2019
@ikedas
Copy link
Member

ikedas commented Apr 13, 2019

Merged. Thanks for improving Sympa!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants