If a mail server uses both OpenDMARC and pypolicyd-spf, its SPF and DMARC authentication can be bypassed with the following message:
HELO: attacker.com
MAIL FROM: any@not.exist.legitimate.com
...
From: admin@legitimate.com
...
pypolicyd-spf uses the HELO identifier and generates the following message:
Authentication-Results: mx.legitimate.com; spf=pass (helo) smtp.helo=attacker.com
OpenDMARC uses the MAIL FROM identifier to check alignment with the From header.
Given the popularity of OpenDMARC and pypolicyd-spf, this bug may affect many online services. Hope you can fix it soon.
Please provide some real log excerpts that show output from pypolicyd-spf, OpenDMARC and the used MTA.
Thanks for your questions.
Here is the detailed steps to reproduce the attack:
1.Software version
Postfix v3.3.0
pypolicyd-spf v2.0.2
opendmarc v1.3.2
2.Configuration
Postfix enables pypolicyd-spf in its master.conf file.
policy-spf unix - n n - - spawn user=nobody argv=/usr/local/bin/policyd-spfpypolicyd-spf use its default configuration.
3.Send message via Telnet
Here are the SMTP commands via telnet:
4. Full message headers
Received-SPF header is generated by pypolicyd-spf. Sorry for the mistake in my initial report.
Authentication-Results header shows that the message has passed DMARC check.
I have also reported this issue to pypolicyd-spf last week. They said it's not their bug. See https://bugs.launchpad.net/pypolicyd-spf/+bug/1838816.
Can you retest with pypolicyd-spf set to AR mode (Header_Type = AR)?
Yep, you are right. Parsing of the Received-SPF header is too simple. It does not look at the identity, just at the result. So even a Received-SPF header already present in the incoming mail would be taken...
This assumes, that OpenDMARC is configured to not use the internal SPF code and that no Authentication-Results header for SPF is present.
I think it is, but just to be sure: is this the same vuln reported at https://github.com/trusteddomainproject/OpenDMARC/pull/48 and https://www.golem.de/news/opendmarc-aktiv-ausgenutzte-dmarc-sicherheitsluecke-ohne-fix-1909-143798.html ?