policyd-spf crashes on broken SPF records
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pypolicyd-spf |
Invalid
|
Undecided
|
Antonio Feitosa | ||
pyspf (Ubuntu) |
Fix Released
|
High
|
Scott Kitterman | ||
Precise |
Fix Released
|
High
|
Scott Kitterman | ||
Quantal |
Fix Released
|
High
|
Scott Kitterman |
Bug Description
receiving an email from a sender whose SPF records are bogus (invalid UTF8) can crash policyd-spf.
email (spam as it turns out, but whatever) from <email address hidden> whose SPF record looks like this -
daltoninsurance
causes policyd-spf to crash like so (filtered through syslog and logcheck, so ignore the line preambles) -
...
TEST CASE: Install the current version of spf-tools-python and then run:
$ pyspf 1.1.1.1 email.recipe.com email.recipe.com
This should produce an error like:
Traceback (most recent call last):
File "/usr/bin/pyspf", line 1971, in <module>
print(
File "/usr/bin/pyspf", line 538, in check
spf = self.dns_
File "/usr/bin/pyspf", line 1094, in dns_spf
a = [t for t in self.dns_
File "/usr/bin/pyspf", line 1131, in dns_txt
for a in self.dns(
File "/usr/bin/pyspf", line 1130, in <genexpr>
return [''.join(
UnicodeDecodeError: 'ascii' codec can't decode byte 0x96 in position 32: ordinal not in range(128)
Install the updated binaries from pyspf (python-spf and spf-tools-python - don't bother with the python3 version, it's got other issues that aren't sorted yet) and try again. This time it should work without a traceback (it should raise a PermError about UniCode in an SPF record).
Related branches
description: | updated |
affects: | pypolicyd-spf → py3dns (Ubuntu) |
affects: | py3dns → pypolicyd-spf |
Changed in pypolicyd-spf: | |
assignee: | nobody → Antonio Feitosa (antonio-cfc) |
Fails in python3 too.
Traceback (most recent call last): socket. gethostname( ))) receiver) .check( ) spf(self. d) txt(domain) if RE_SPF.match(t)] domainname, 'TXT')] python3/ dist-packages/ DNS/Base. py", line 213, in req sendUDPRequest( server) python3/ dist-packages/ DNS/Base. py", line 242, in sendUDPRequest processUDPReply () python3/ dist-packages/ DNS/Base. py", line 115, in processUDPReply python3/ dist-packages/ DNS/Base. py", line 139, in processReply DnsResult( u,self. args) python3/ dist-packages/ DNS/Lib. py", line 603, in __init__ python3/ dist-packages/ DNS/Lib. py", line 659, in storeM answers. append( self.storeRR( u)) python3/ dist-packages/ DNS/Lib. py", line 686, in storeRR data']= getattr( u, mname)() python3/ dist-packages/ DNS/Lib. py", line 483, in getTXTdata append( str(self. getstring( ), enc)) python3. 2/encodings/ idna.py" , line 192, in decode append( ToUnicode( label)) python3. 2/encodings/ idna.py" , line 125, in ToUnicode
File "spf.py", line 1673, in <module>
receiver=
File "spf.py", line 304, in check
res,code,exp = query(i=i, s=s, h=h, local=local, receiver=
File "spf.py", line 503, in check
spf = self.dns_
File "spf.py", line 1051, in dns_spf
a = [t for t in self.dns_
File "spf.py", line 1086, in dns_txt
return [''.join(a) for a in self.dns(
File "spf.py", line 1193, in dns
for k, v in DNSLookup(name, qtype, self.strict, self.timeout):
File "spf.py", line 128, in DNSLookup
resp = req.req()
File "/usr/lib/
self.
File "/usr/lib/
r=self.
File "/usr/lib/
return self.processReply()
File "/usr/lib/
r=Lib.
File "/usr/lib/
self.storeM(u)
File "/usr/lib/
self.
File "/usr/lib/
r['
File "/usr/lib/
tlist.
File "/usr/lib/
result.
File "/usr/lib/
return str(label, "ascii")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 9: ordinal not in range(128)
This should either be a pyspf or py(3)dns bug.