SA Bugzilla – Bug 4024
SPF and X-Envelope-From and sendmail
Last modified: 2006-12-06 10:34:50 UTC
The USAGE document says: However,sendmail will not expose the MAIL FROM: sender address by default. So if you're using sendmail, please add this to /etc/sendmail.cf : H?l?X-Envelope-From: $f This works fine as long as the message is received from a server that is not also set to add this header. But if the header has already been added by a previous server, then sendmail won't add another one. The existing header will be below the latest Received: line so SpamAssasin won't trust it and no SPF checks will be done. By SPF I mean the real SPF checks, not the SPF_HELO checks. Example headers from one that works: X-Envelope-From: cpicciotto@kalisystems.com Return-Path: <cpicciotto@kalisystems.com> Received: from picciotto.net (picciotto.net [66.91.143.194]) by mail.tippingmar.com (8.12.10/8.12.10) with ESMTP id iBAJ9Ye1001721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <mark@tippingmar.com>; Fri, 10 Dec 2004 11:09:35 -0800 Received: from [192.168.0.4] (cpe-66-91-125-24.hawaii.rr.com [66.91.125.24]) (authenticated bits=0) by picciotto.net (8.12.11/8.12.11) with ESMTP id iBAJ9QC5015715 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <mark@tippingmar.com>; Fri, 10 Dec 2004 09:09:26 -1000 Message-ID: <41B9F469.7060307@kalisystems.com> Example of one that doesn't work: Return-Path: <cpicciotto@kalisystems.com> Received: from picciotto.net (picciotto.net [66.91.143.194]) by mail.tippingmar.com (8.12.10/8.12.10) with ESMTP id iBAIise1001311 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for <mark@tippingmar.com>; Fri, 10 Dec 2004 10:44:55 -0800 X-Envelope-From: cpicciotto@kalisystems.com Received: from [192.168.0.4] (cpe-66-91-125-24.hawaii.rr.com [66.91.125.24]) (authenticated bits=0) by picciotto.net (8.12.11/8.12.11) with ESMTP id iBAIijMY015420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for <mark@tippingmar.com>; Fri, 10 Dec 2004 08:44:45 -1000 Message-ID: <41B9EE24.9070509@kalisystems.com>
You can work around this problem to a large extent by using: H?l?X-uniquename-Env-From: $f and then specifying the header name with: envelope_sender_header X-uniquename-Env-From in local.cf so the chances of there already being such a header in the incoming message are greatly reduced. Of course this problem only relates to use of SpamAssassin on gateways or in programs like MailScanner, where the message has not yet been given to a delivery agent. When sendmail passes the message to a delivery agent, it adds the Return-Path header, which SpamAssassin knows how to use.
Of course there's nothing we can do if the header is added by an untrusted relay, but we can use it if it was added by a trusted relay. Adding the HELO value found in the last trusted relay's received header to the current regex should do the trick. This also applies to the regexes for Envelope-Sender and Return-Path. Daryl
I'm not sure what you mean. The HELO and the Envelope-From are often different for legitimate messages. True SPF requires the Envelope-From address. As noted in the first post, the problem is with real SPF checks, not the SPF_HELO tests.
What I'm suggesting has nothing to do with SPF checks. It only has to do with determining when we can trust the X-Envelope-From, Envelope-Sender and/or Return Path found in a message, and when we can't. If these headers are found above the last trusted relay's received header, we can trust them. By modifying the current regexes, used to determine if we can use the 3 aforementioned headers, to include a token that appears in the last trusted relay's received header (and no sooner, but likely also later) we can determine whether or not we trust those 3 headers. I'll write a patch tonight if I can get some other work out of the way. Daryl
I see. Currently the header is only trusted if it is above the final Received header. You are saying we can also trust the header if it is above the last TRUSTED relay.
daryl -- I'm not sure your position is correct. it's entirely plausible that a *trusted* relay could forward the mail with a new envelope-sender address. my fetchmail setup, for exmaple, does this; also if the mail is resent via a Mailman/ezmlm mailing list, that will also do that.
Subject: Re: SPF and X-Envelope-From and sendmail I would say we should use the first envelope-sender header encountered above the last trusted received line.
Subject: Re: SPF and X-Envelope-From and sendmail The current code won't use the headers, regardless of where they are, if it finds an X-Sender header and a fetchmail received header since fetchmail may alter the envelope-sender. I don't suggest that this check be eliminated if we were to check for the 3 headers in between the trusted relays' received headers. That said, is there anytime fetchmail will alter the envelope-sender if it doesn't find an X-Sender header? Should the X-Sender requirement be removed (and just look for 'fetchmail') or should we also be looking for other headers that may cause fetchmail to alter the envelope-sender? Daryl
Created attachment 2596 [details] patch against 3.0
Created attachment 2597 [details] patch against trunk
Daryl -- do we still need this?
Forgot all about this... need to think about it a bit. If we do need it, I don't like my implementation. Looking for the last trusted helo is lame. Instead of using the "ALL" pseudo header, we should have an "ALL-TRUSTED" one to work with.
lowering pri
I can't convince myself that this is a good thing to do. It's messy and unreliable. As soon as you start messing with the return path you've got to give up on SPF. r483169 and r483171 removes the bogus info from the USAGE doc. Closing as WONTFIX.