On Mon, May 01, 2023 at 03:41:37PM -0400, Jon LaBadie via Postfix-users wrote:

> I've been getting a lot of spam with Date: headers
> containing future dates, typically 1 year.
> 
> I don't find any header checks that would look for
> this type of message.  Have I over looked it?
> 
> In the meantime I've implemented a script and procmail
> rule to examine my messages.  But that is post-delivery
> and per-user.

I have a Python milter that defers some future-dated messages.

    ...

    def __init__(self):
        self.__id = Milter.uniqueID()
        self.__ipname = None
        self.__ip = None
        self.__port = None
        self.__from = None
        self.__now = time.time()
        ...

    ...

    def header(self, name, hval):
        """header callback gets called for each header
        """
        if config.debug:
            print("%s: %s" % (name, hval))

        lc = name.lower()

        # ...

        if ... selection criteria ... :
            if lc == "date":
                tm = email.utils.parsedate_tz(hval)
                if tm is not None:
                    try:
                        t = email.utils.mktime_tz(tm)
                        dt = t - self.__now
                        if config.debug:
                            print("Then %f, now %f, delta %f" % (t, self.__now, 
dt))
                        if ... no extenuating circumstances ...:
                            floor = -... allowance for clock drift ...
                        else:
                            floor = ... minimum delay penalty ...
                        if dt > floor:
                            self.setreply("454", xcode="4.7.0", msg="No thanks")
                            return Milter.TEMPFAIL
                    except Exception as _: pass

        return Milter.CONTINUE

Some messages have to arrive some time after the implied date, some can
arrive a short time before, and some are not restricted at all.  No
message is refused if the remote MTA is willing to retry long enough.
The logic is narrowly targetted at a particular pattern of abuse.

-- 
    Viktor.
_______________________________________________
Postfix-users mailing list -- postfix-users@postfix.org
To unsubscribe send an email to postfix-users-le...@postfix.org

Reply via email to