haraka / haraka-plugin-spf

SPF plugin for Haraka
https://www.npmjs.com/package/haraka-plugin-spf
MIT License
2 stars 5 forks source link

spf calling next() multiple times when several MX lookups fail #23

Open celesteking opened 3 years ago

celesteking commented 3 years ago

Basically,

[core] Error
    at callback (/Haraka/plugins.js:482:34)
    at Plugin.exports.return_results (Haraka/plugins/spf.js:295:20)
    at ch_cb (Haraka/plugins/spf.js:214:16)
    at mech_chain_caller (Haraka/spf.js:316:28)
    at QueryReqWrap.callback (Haraka/spf.js:507:56)
    at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:10)

This is happening because of the following events chain:

        net_utils.get_mx(domain, (err, mxes) => {
            for (let a=0; a<mxes.length; a++) {
                dns[resolve_method](mx, (err4, addrs) => {
                            default:            return cb(null, self.SPF_TEMPERROR);

When there are multiple MX, and some of them fail (or maybe even when some fail, some succeed), we invoke CB which doesn't put a stopper on further invocations.

System Info:

2.8.27

celesteking commented 3 years ago

Thinking this further, if some mechs fail and others succeed, shouldn't we consider it a success instead of temperror or whatever? What is some lookups inside a mech fail, but others produce a MATCH, shouldn't we consider the same? A question to someone who's read RFC.