Monday, April 8, 2019

postfix-policyd-spf-python - spoof protection - spf checks FAIL but no action taken - why?

I've installed postfix-policyd-spf-python and configured the postfix integration according to the docs.



This is my policyd-spf.conf config file:



debugLevel = 1 
TestOnly = 0


HELO_reject = SPF_Not_Pass
Mail_From_reject = Fail

PermError_reject = False
TempError_Defer = False

skip_addresses = 127.0.0.0/8,::ffff:127.0.0.0/104,::1


Incoming emails from foreign mail servers get checked and flagged correctly. But when I check for spoof protection, somehow the emails go through:




$ telnet mail.example.com 25

Connected to mail.example.com.
Escape character is '^]'.
220 mail.example.com ESMTP Postfix
helo asd.somedomain.com
250 mail.example.com
mail from: me@example.com
250 2.1.0 Ok

rcpt to: test@example.com
250 2.1.5 Ok
data
354 End data with .
from: "ME"
to: "test"
subject: test

asdasd klajsdlaksjd


thanks!
.

250 2.0.0 Ok: queued as 8C9EC1260E1


In my view, this email should NOT be delivered.



Here's the debugging output from postfix-policyd-spf-python:




policyd-spf[34414]: Found the end of entry
policyd-spf[34414]: Config: {'debugLevel': 5, 'HELO_reject': 'SPF_Not_Pass', 'Mail_From_reject': 'Fail', 'PermError_reject': 'False', 'TempError_Defer': 'False', 'skip_addresses': '127.0.0.0/8,::ffff:127.0.0.0/104,::1', 'TestOnly': 0, 'SPF_Enhanced_Status_Codes': 'Yes', 'Header_Type': 'SPF', 'Hide_Receiver': 'Yes', 'Authserv_Id': 'mail.example.com', 'Lookup_Time': 20, 'Whitelist_Lookup_Time': 10, 'Void_Limit': 2, 'Reason_Message': 'Message {rejectdefer} due to: {spf}. Please see {url}', 'No_Mail': False, 'Mock': False}
policyd-spf[34414]: Cached data for this instance: []

policyd-spf[34414]: skip_addresses enabled.

policyd-spf[34414]: _get_resultcodes: scope: helo, Reject_Not_Pass_Domains: None, helo_policy: SPF_Not_Pass, mfrom_policy: Fail
policyd-spf[34414]: Scope helo unused results: ['Pass', 'None', 'Temperror', 'Permerror']
policyd-spf[34414]: helo policy true results: actions: {'defer': [], 'reject': ['Fail', 'Softfail', 'Neutral'], 'prepend': ['Pass', 'None', 'Temperror', 'Permerror']} local {'local_helo': False, 'local_mfrom': False}
policyd-spf[34414]: spfcheck: pyspf result: "['None', '', 'helo']"

policyd-spf[34414]: None; identity=no SPF record; client-ip=xx.xx.xx.xx; helo=asd.somedomain.com; envelope-from=me@example.com; receiver=


policyd-spf[34414]: _get_resultcodes: scope: mfrom, Reject_Not_Pass_Domains: None, helo_policy: SPF_Not_Pass, mfrom_policy: Fail
policyd-spf[34414]: Scope mfrom unused results: ['Pass', 'None', 'Neutral', 'Softfail', 'Temperror', 'Permerror']
policyd-spf[34414]: mfrom policy true results: actions: {'defer': [], 'reject': ['Fail'], 'prepend': ['Pass', 'None', 'Neutral', 'Softfail', 'Temperror', 'Permerror']} local {'local_helo': False, 'local_mfrom': False}
policyd-spf[34414]: spfcheck: pyspf result: "['Fail', 'SPF fail - not authorized', 'mailfrom']"

policyd-spf[34414]: Fail; identity=mailfrom; client-ip=xx.xx.xx.xx; helo=asd.somedomain.com; envelope-from=me@example.com; receiver=



policyd-spf[34414]: Action: None: Text: None Reject action: 550 5.7.23


As we can see from the log files, the SPF check does return:



spfcheck: pyspf result: "['Fail', 'SPF fail - not authorized', 'mailfrom']"



however, the last line reads:




Action: None: Text: None Reject action: 550 5.7.23



Why is that? Why is the Action: None? In my view, the email should be rejected and not accepted by the server. What am I doing wrong?

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...