Victor Duchovni
2006-10-24 02:00:50 UTC
There was a recent report of interoperability issues between Exchange
acting as TLS client, and Postfix acting as a TLS server. I have just
experienced the converse problem, and the packet capture shows severe
breakage on the Exchange side...
First we send "EHLO hostname.fq.dn\r\n" (21 bytes) in the clear:
23:03:23.491182 Postfix > Exchange: P 1:22(21) ack 126 win 8760 (DF)
Then the server responds with 248 bytes of ESMTP features:
23:03:23.530482 Exchange > Postfix: P 126:374(248) ack 22 win 65514
Then "STARTTLS\r\n" and the server "220 2.0.0 SMTP server ready\r\n"
23:03:23.531045 Postfix > Exchange: P 22:32(10) ack 374 win 8760 (DF)
23:03:23.569872 Exchange > Postfix: P 374:403(29) ack 32 win 65504
Then a normal TLS handshake (short because session is cached):
23:03:23.573556 Postfix > Exchange: P 32:130(98) ack 403 win 8760 (DF)
23:03:23.612668 Exchange > Postfix: P 403:533(130) ack 130 win 65406
23:03:23.614696 Postfix > Exchange: P 130:181(51) ack 533 win 8760 (DF)
Then the client sends "EHLO hostname.fq.dn\r\n" again, but this time with
5 bytes of TLS header + padded CBC encrypted data, with a MAC which expands
to 4 + 48 or 53 bytes:
23:03:23.838369 Postfix > Exchange: P 181:234(53) ack 533 win 8760 (DF)
0x0020 XXXX XXXX XXXX XXXX 1703 0100 3049 49eb
0x0030 7a2f ebae 9049 21c2 0831 18ae fd77 df76
0x0040 7829 b404 92d0 4fad 2091 c802 43bc 941f
0x0050 3bfc d026 19c7 a2cf 88c4 0085 53
The 5 byte TLS header "1703 0100 30" indicates 48 bytes of TLS payload, which
decrypts to the 21 byte EHLO command.
And finally the Exchange response is corrupted! It sends, 258 bytes of TCP
data with a TLS header of "1703 0100 f8" which is 248 bytes of TLS payload
(for a total of 253 bytes of TLS message) plus a mysterious final 5 bytes
"2f 2f77 7777" which decodes to "//www". The first 248 decode to a valid
EHLO response, but the extra 5 bytes totally mess up subsequent communication.
23:03:23.877772 Exchange > Postfix: P 533:791(258) ack 234 win 65302
0x0020 XXXX XXXX XXXX XXXX 1703 0100 f828 fe97
0x0030 5984 aa62 4ce1 0557 a7c6 9fac 54c6 323b
0x0040 6d18 5201 989e 2e02 8433 8132 0d22 fec8
0x0050 b6a6 0990 6350 38f8 736a 92eb 5962 29d7
0x0060 3473 9afe 69a0 d446 74e3 e9e5 de73 489b
0x0070 8eb4 bc6d 35ac eac7 6f1a 645e b827 8027
0x0080 488b 3434 3ad5 dca0 1152 7786 19b7 582c
0x0090 4c59 ee88 2307 aa59 fc7f e79d c9fb abb5
0x00a0 d5e0 489f fb64 0880 58f7 55a5 f900 4ba0
0x00b0 b567 7d7a a59e 801a a8d1 f214 63db 35fc
0x00c0 f39c 97e3 21b3 098d 562b be4f 1221 c82e
0x00d0 ee09 a91c 62cd 9ab2 1269 f6f3 b66f dc73
0x00e0 439d 39ca 3ab1 0b52 f05f a4bf e802 2970
0x00f0 44d5 8da1 cf0b 9dd9 f673 1c26 0c61 db96
0x0100 4417 f726 5016 1a8f 993a 3e22 0546 c456
0x0110 f660 40c0 5083 0f86 4885 6cd2 54a8 1cfc
0x0120 f771 9436 542f 2f77 7777 .q.6T//www
It is very odd to find "//www" in the middle of a TLS stream. At this
point in the TCP stream we should see either a packet boundary, or
the beginning of the next TLS message (another 1703 0100 ... header).
Instead Exchange appended 5 bytes of clear-text junk (reused a buffer
without clearing it perhaps) leaking data from another message and
corrupting the TLS session.
If similar insertion of "random" data is present in the Exchange TLS
client, all manner of protocol issues will arise as garbage is interpreted
as TLS data.
I am no longer attempting to use TLS with the server in question...
--
Viktor.
Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.
To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:***@postfix.org?body=unsubscribe%20postfix-users>
If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.
acting as TLS client, and Postfix acting as a TLS server. I have just
experienced the converse problem, and the packet capture shows severe
breakage on the Exchange side...
First we send "EHLO hostname.fq.dn\r\n" (21 bytes) in the clear:
23:03:23.491182 Postfix > Exchange: P 1:22(21) ack 126 win 8760 (DF)
Then the server responds with 248 bytes of ESMTP features:
23:03:23.530482 Exchange > Postfix: P 126:374(248) ack 22 win 65514
Then "STARTTLS\r\n" and the server "220 2.0.0 SMTP server ready\r\n"
23:03:23.531045 Postfix > Exchange: P 22:32(10) ack 374 win 8760 (DF)
23:03:23.569872 Exchange > Postfix: P 374:403(29) ack 32 win 65504
Then a normal TLS handshake (short because session is cached):
23:03:23.573556 Postfix > Exchange: P 32:130(98) ack 403 win 8760 (DF)
23:03:23.612668 Exchange > Postfix: P 403:533(130) ack 130 win 65406
23:03:23.614696 Postfix > Exchange: P 130:181(51) ack 533 win 8760 (DF)
Then the client sends "EHLO hostname.fq.dn\r\n" again, but this time with
5 bytes of TLS header + padded CBC encrypted data, with a MAC which expands
to 4 + 48 or 53 bytes:
23:03:23.838369 Postfix > Exchange: P 181:234(53) ack 533 win 8760 (DF)
0x0020 XXXX XXXX XXXX XXXX 1703 0100 3049 49eb
0x0030 7a2f ebae 9049 21c2 0831 18ae fd77 df76
0x0040 7829 b404 92d0 4fad 2091 c802 43bc 941f
0x0050 3bfc d026 19c7 a2cf 88c4 0085 53
The 5 byte TLS header "1703 0100 30" indicates 48 bytes of TLS payload, which
decrypts to the 21 byte EHLO command.
And finally the Exchange response is corrupted! It sends, 258 bytes of TCP
data with a TLS header of "1703 0100 f8" which is 248 bytes of TLS payload
(for a total of 253 bytes of TLS message) plus a mysterious final 5 bytes
"2f 2f77 7777" which decodes to "//www". The first 248 decode to a valid
EHLO response, but the extra 5 bytes totally mess up subsequent communication.
23:03:23.877772 Exchange > Postfix: P 533:791(258) ack 234 win 65302
0x0020 XXXX XXXX XXXX XXXX 1703 0100 f828 fe97
0x0030 5984 aa62 4ce1 0557 a7c6 9fac 54c6 323b
0x0040 6d18 5201 989e 2e02 8433 8132 0d22 fec8
0x0050 b6a6 0990 6350 38f8 736a 92eb 5962 29d7
0x0060 3473 9afe 69a0 d446 74e3 e9e5 de73 489b
0x0070 8eb4 bc6d 35ac eac7 6f1a 645e b827 8027
0x0080 488b 3434 3ad5 dca0 1152 7786 19b7 582c
0x0090 4c59 ee88 2307 aa59 fc7f e79d c9fb abb5
0x00a0 d5e0 489f fb64 0880 58f7 55a5 f900 4ba0
0x00b0 b567 7d7a a59e 801a a8d1 f214 63db 35fc
0x00c0 f39c 97e3 21b3 098d 562b be4f 1221 c82e
0x00d0 ee09 a91c 62cd 9ab2 1269 f6f3 b66f dc73
0x00e0 439d 39ca 3ab1 0b52 f05f a4bf e802 2970
0x00f0 44d5 8da1 cf0b 9dd9 f673 1c26 0c61 db96
0x0100 4417 f726 5016 1a8f 993a 3e22 0546 c456
0x0110 f660 40c0 5083 0f86 4885 6cd2 54a8 1cfc
0x0120 f771 9436 542f 2f77 7777 .q.6T//www
It is very odd to find "//www" in the middle of a TLS stream. At this
point in the TCP stream we should see either a packet boundary, or
the beginning of the next TLS message (another 1703 0100 ... header).
Instead Exchange appended 5 bytes of clear-text junk (reused a buffer
without clearing it perhaps) leaking data from another message and
corrupting the TLS session.
If similar insertion of "random" data is present in the Exchange TLS
client, all manner of protocol issues will arise as garbage is interpreted
as TLS data.
I am no longer attempting to use TLS with the server in question...
--
Viktor.
Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.
To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:
<mailto:***@postfix.org?body=unsubscribe%20postfix-users>
If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.