This is an automated email from the ASF dual-hosted git repository. Arsnael pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-jspf.git
commit d1da3a625d0b775c112c813028f57eca0402f563 Author: Benoit TELLIER <[email protected]> AuthorDate: Tue Nov 10 09:15:23 2026 +0100 [FIX] exists mechanism: a failed lookup of the target is a temperror ExistsMechanism.onDNSResponse took a TimeoutException, which the executors give for every failed lookup, as no match and went on to the next term. RFC 7208 5 requires temperror when the DNS query of a mechanism fails, and the a and mx mechanisms already throw TempErrorException. A deny list such as "-exists:%{ir}.bl.example.com ... +all" stopped blocking while its lookup failed, and an allow list such as "exists:%{i}._spf.%{d} -all" gave a permanent fail during a transient outage. Throw TempErrorException, as AMechanism does. --- .../java/org/apache/james/jspf/terms/ExistsMechanism.java | 4 ++-- .../test/java/org/apache/james/jspf/SPFExecutorBaseTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/resolver/src/main/java/org/apache/james/jspf/terms/ExistsMechanism.java b/resolver/src/main/java/org/apache/james/jspf/terms/ExistsMechanism.java index 6aaea2a..1d4d912 100644 --- a/resolver/src/main/java/org/apache/james/jspf/terms/ExistsMechanism.java +++ b/resolver/src/main/java/org/apache/james/jspf/terms/ExistsMechanism.java @@ -89,8 +89,8 @@ public class ExistsMechanism extends GenericMechanism implements SPFCheckerDNSRe try { aRecords = response.getResponse(); } catch (TimeoutException e) { - spfSession.setAttribute(Directive.ATTRIBUTE_MECHANISM_RESULT, Boolean.FALSE); - return null; + // RFC 7208 5: a failed lookup of the target is a temperror, not a missing name + throw new TempErrorException("Timeout querying dns server"); } if (aRecords != null && aRecords.size() > 0) { diff --git a/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java b/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java index 12c04c9..bd4e1c1 100644 --- a/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java +++ b/resolver/src/test/java/org/apache/james/jspf/SPFExecutorBaseTest.java @@ -1664,4 +1664,16 @@ public abstract class SPFExecutorBaseTest { assertEquals(SPFErrorConstants.FAIL_CONV, result.getResult()); } + + @Test(timeout = 10000) + public void existsShouldReturnTempErrorWhenTheLookupOfTheTargetFails() throws IOException { + String hostname = "existsFailing.spfexecutor.fake"; + DNSService dns = dnsFailing(DNSRequest.A, new TXTRecord(Name.fromString(hostname + "."), DClass.IN, 30L, + "v=spf1 -exists:%{ir}.bl." + hostname + " +all")); + + SPFResult result = createCustomSPF(dns).checkSPF("1.2.3.4", "a_user@" + hostname, hostname); + + // RFC 7208 5: a DNS error of a mechanism lookup is a temperror, the deny list does not fail open + assertEquals(SPFErrorConstants.TEMP_ERROR_CONV, result.getResult()); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
