Package: opendkim
Version: 2.9.2-2
Severity: important
Tags: patch

OpenDKIM, or more precisely, libopendkim up to 2.10.3 fails to canonicalize
folded mail headers according to the RFC 6376 "relaxed" algorithm when a
header is folded (wrapped) right after the ":" as for instance in

| Subject:\r\n
|    long subject text continued on subsequent lines ...

https://tools.ietf.org/html/rfc6376#section-3.4 Section 3.4.2 requires 
that this is canonicalized into

| subject:long subject text continued on subsequent lines ...

but libopendkim produces (note the single space after ":")

| subject: long subject text continued on subsequent lines ...

Hence, DKIM signatures derived from such headers are broken for all 
systems other than OpenDKIM (up to and including 2.10.3), and OpenDKIM
fails to verify valid signatures produced by systems other than 
OpenDKIM.

For the "From:" header this has been reported upstream at

  #226 Bad signature of From:\r\n wrapped field 
  https://sourceforge.net/p/opendkim/bugs/226/

but the bug affects canonicalization in general.

The provided patches are trivial, see DEP-3 patch by A. Schulze at
https://sourceforge.net/p/opendkim/bugs/_discuss/thread/d08319d2/bd34/attachment/ticket226.patch
Quoting thereof for reference:

-- dv-opendkim-2.10.3.orig/libopendkim/dkim-canon.c
+++ dv-opendkim-2.10.3/libopendkim/dkim-canon.c
@@ -388,7 +388,7 @@ dkim_canon_header_string(struct dkim_dst
                /* skip all spaces before first word */
-               while (*p != '\0' && DKIM_ISWSP(*p))
+               while (*p != '\0' && DKIM_ISLWSP(*p))
                        p++;

The patch was applied upstream in opendkim-2.11.0.Alpha0 as of 
2015-10-22.

I was not yet able to assess which or how many mailers produce headers 
that wrap immediately after the header keyword.

However, I want to mention that Debian's default configuration of 
OpenDKIM as in Jessie and Stretch is unfortunately more likely to 
produce invalid signatures due to the fact that headers such as 
"References:" and "In-Reply-To:" which are often wrapped are signed. 
This is a default setting by OpenDKIM left unchanged by Debian, cf. 
opendkim.conf(5) + https://tools.ietf.org/html/rfc6376#section-5.4

So, signers can somewhat mitigate this bug's consequences using 
"OmitHeaders". Receivers, though, need to apply the patch.



-- System Information:
Debian Release: 7.11
  APT prefers oldstable-updates
  APT policy: (990, 'oldstable-updates'), (990, 'oldstable'), (500, 'stable')
Architecture: amd64 (x86_64)

Versions of packages opendkim depends on:
ii  adduser            3.113+nmu3
ii  libbsd0            0.4.2-1
ii  libc6              2.19-18+deb8u6
ii  libdb5.3           5.3.28-9
ii  libldap-2.4-2      2.4.31-2+deb7u2
ii  liblua5.1-0        5.1.5-4+deb7u1
ii  libmemcached11     1.0.18-4
ii  libmemcachedutil2  1.0.18-4
ii  libmilter1.0.1     8.14.4-4+deb7u1
ii  libopendbx1        1.4.6-8
ii  libopendkim9       2.9.2-2
ii  librbl1            2.9.2-2
ii  libssl1.0.0        1.0.1t-1+deb8u5
ii  libunbound2        1.4.17-3+deb7u2
ii  libvbr2            2.9.2-2
ii  lsb-base           4.1+Debian8+deb7u1

opendkim recommends no packages.

Versions of packages opendkim suggests:
ii  opendkim-tools  2.9.2-2

-- Configuration Files:
/etc/opendkim.conf changed [not included]

-- no debconf information

Reply via email to