Snawoot / postfix-mta-sts-resolver

Daemon which provides TLS client policy for Postfix via socketmap, according to domain MTA-STS policy
MIT License
117 stars 23 forks source link

Querying IDN domains causes an error #90

Closed DanWin closed 2 years ago

DanWin commented 2 years ago

Describe the bug When querying an IDN domain with utf-8 characters in them, the connection gets closed prematurely and an error gets logged.

To Reproduce Steps to reproduce the behavior:

  1. Run a lookup with a domain that has an utf-8 character in it: /usr/sbin/postmap -q ätsch.de socketmap:inet:127.0.0.1:8461:postfix

Expected behavior The domain should be converted to it's ascii counterpart (in this example xn--tsch-koa.de) and resolved correctly.

Output listings

Aug 20 18:52:28 proxy mta-sts-daemon[283]: 2022-08-20 18:52:28 ERROR    STS: Exception in sender coro: 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)
Aug 20 18:52:28 proxy mta-sts-daemon[283]: Traceback (most recent call last):
Aug 20 18:52:28 proxy mta-sts-daemon[283]:   File "/usr/lib/python3/dist-packages/postfix_mta_sts_resolver/responder.py", line 149, in sender
Aug 20 18:52:28 proxy mta-sts-daemon[283]:     data = await fut
Aug 20 18:52:28 proxy mta-sts-daemon[283]:   File "/usr/lib/python3/dist-packages/postfix_mta_sts_resolver/responder.py", line 167, in process_request
Aug 20 18:52:28 proxy mta-sts-daemon[283]:     req_zone, _, req_domain = raw_req.decode('ascii').partition(' ')
Aug 20 18:52:28 proxy mta-sts-daemon[283]: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)
Aug 20 18:52:28 proxy mta-sts-daemon[283]: 2022-08-20 18:52:28 ERROR    STS: Exception in sender coro: 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)
Aug 20 18:52:28 proxy mta-sts-daemon[283]: Traceback (most recent call last):
Aug 20 18:52:28 proxy mta-sts-daemon[283]:   File "/usr/lib/python3/dist-packages/postfix_mta_sts_resolver/responder.py", line 149, in sender
Aug 20 18:52:28 proxy mta-sts-daemon[283]:     data = await fut
Aug 20 18:52:28 proxy mta-sts-daemon[283]:   File "/usr/lib/python3/dist-packages/postfix_mta_sts_resolver/responder.py", line 167, in process_request
Aug 20 18:52:28 proxy mta-sts-daemon[283]:     req_zone, _, req_domain = raw_req.decode('ascii').partition(' ')
Aug 20 18:52:28 proxy mta-sts-daemon[283]: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)
Aug 20 18:52:28 proxy postfix/postmap[11247]: warning: table socketmap:inet:127.0.0.1:8461:postfix lookup error: unexpected disconnect
Aug 20 18:52:28 proxy postfix/postmap[11247]: fatal: table socketmap:inet:127.0.0.1:8461:postfix: query error: Operation now in progress

Environment (please complete the following information):

Snawoot commented 2 years ago

Fixed in 1.1.4.