You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@spamassassin.apache.org by Benoit Panizzon <be...@imp.ch> on 2026/06/01 11:56:41 UTC

tflags publish <= What is this good for? (Re: Rule for: Subject contains email address from To: header?)

Hi

I figured out the culpit why a rule did not work was tflags publish

Actual finding in trying to get the shipped rule TO_IN_SUBJ to match
anything. Just created a new rule with one of the regexp:

header          TEST_EMAIL_SUBJ_TO      ALL =~ /\nSubject:(?=[^\n]{0,200}@)[^\n]{0,200}([a-z][a-z0-9_.]{3,80}@(?:[a-z0-9_]{1,80}\.){1,4}[a-z]{2,30})(?:[^\n]+\n)*To:\s+[^\n]{0,100}\1[^a-z0-9.]/ism
describe        TEST_EMAIL_SUBJ_TO      Testing: Email in Subject then To
score           TEST_EMAIL_SUBJ_TO      1
tflags          TEST_EMAIL_SUBJ_TO      publish

When I remove the tflags line, the rule is run and matches as
expected when invoking SpamAssassin from MIMEDefang.

When I keep the tflags line, then the rule seems to only run when
calling SpamAssassin from command line.

So I wonder if there might be some setting somewhere to cause
spamassassin not running rules with a specific tflags in some
situations?

Mit freundlichen Grüssen

-Benoît Panizzon-
-- 
I m p r o W a r e   A G    -    Leiter Commerce Kunden
______________________________________________________

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch
______________________________________________________

Re: tflags publish <= What is this good for? (Re: Rule for: Subject contains email address from To: header?)

Posted by John Hardin <jh...@impsec.org>.
On Mon, 1 Jun 2026, Benoit Panizzon wrote:

> TO_IN_SUBJ itself is yet another meta involving __TO_IN_SUBJ and some
> other negated rules.

That is intentional. The negated rules are intended to remove ham-only or 
mostly-ham hits observed in masscheck so that the rule performs more 
reliably - IN ISOLATION.

Note that the patterns of ham and spam change over time so it's entirely 
possible those exclusions have rotted and become a problem rather than a 
benefit. That approach of rule tuning _does_ require periodic review and 
retuning.

I'll try to review and retune TO_IN_SUBJ sometime this week.

> Turned out, the issue most probably never was __TO_IN_SUBJ this was
> probably always producing a hit (which I could see by manually calling
> spamassassin on the command line).
>
> The issue most probably is one of the other negated rules which disable
> TO_IN_SUBJ despite __TO_IN_SUBJ being true.

Right.

If you're doing fresh metarules for local conditions, start with the 
unfiltered subrule __TO_IN_SUBJ and add other conditions based on local 
observed spam.

> meta		IMP_TO_IN_SUBJ		__TO_IN_SUBJ
> describe	IMP_TO_IN_SUBJ		Empfaengeradresse in Betreff
> score		IMP_TO_IN_SUBJ		2

Useful to gauge the impact of the masscheck-based FP avoidance exclusions.

> header	__IMP_SHOP_IN_SUBJ	Subject =~/(UPS|Rossmann|Lidl|Hermes|DPD|GLS|ADAC)/i
>
> meta		IMP_SHOP_PHISH		(__TO_IN_SUBJ + __IMP_SHOP_IN_SUBJ > 1)
> describe	IMP_SHOP_PHISH		Empfaengeradresse in Betreff + Firmenname
> score		IMP_SHOP_PHISH		8

Like that, yes.

Style note: the "> 1" is not needed (and can be confusing) for rules that 
do not have "tflags multiple". Single-match rules either hit or they 
don't, so it's less confusing in most cases to use non-score boolean logic 
in metarules.

Recommend instead:

   meta    IMP_SHOP_PHISH    __TO_IN_SUBJ && __IMP_SHOP_IN_SUBJ



-- 
  John Hardin KA7OHZ                    http://www.impsec.org/~jhardin/
  jhardin@impsec.org                         pgpk -a jhardin@impsec.org
  key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
  5 days until the 82nd anniversary of D-Day

Re: tflags publish <= What is this good for? (Re: Rule for: Subject contains email address from To: header?)

Posted by Benoit Panizzon <be...@imp.ch>.
Hi Bill

> As described, this is definitely a bug.

No not a Bug!

I guess there were more 'things' which are involved which I overlooked
and which now hit me in the face when I attempted to create the 'real'
rule, first using TO_IN_SUBJ and hitting the SAME issue again, without
tflags.

TO_IN_SUBJ itself is yet another meta involving __TO_IN_SUBJ and some
other negated rules.

Turned out, the issue most probably never was __TO_IN_SUBJ this was
probably always producing a hit (which I could see by manually calling
spamassassin on the command line).

The issue most probably is one of the other negated rules which disable
TO_IN_SUBJ despite __TO_IN_SUBJ being true.

While testing from my google account and crafting emails which should
have caused the hits, I noticed that indeed __TO_IN_SUBJ scored a hit
but not TO_IN_SUBJ and when running the same email from command line
(even when removing the headers added locally) I did not get the same
rules to match and indeed when run that way TO_IN_SUBJ was positive.

This below, now works as I expected, hopefully not causing too many
false positives - but now I can proceed with additional to fine tune
like also adding certain ASN which are mostly the source of those
phishing emails with known brands.

meta		IMP_TO_IN_SUBJ		__TO_IN_SUBJ
describe	IMP_TO_IN_SUBJ		Empfaengeradresse in Betreff
score		IMP_TO_IN_SUBJ		2

header		__IMP_SHOP_IN_SUBJ	Subject =~/(UPS|Rossmann|Lidl|Hermes|DPD|GLS|ADAC)/i

meta		IMP_SHOP_PHISH		(__TO_IN_SUBJ + __IMP_SHOP_IN_SUBJ > 1)
describe	IMP_SHOP_PHISH		Empfaengeradresse in Betreff + Firmenname
score		IMP_SHOP_PHISH		8

Mit freundlichen Grüssen

-Benoît Panizzon-
-- 
I m p r o W a r e   A G    -    Leiter Commerce Kunden
______________________________________________________

Zurlindenstrasse 29             Tel  +41 61 826 93 00
CH-4133 Pratteln                Fax  +41 61 826 93 01
Schweiz                         Web  http://www.imp.ch
______________________________________________________

Re: tflags publish <= What is this good for? (Re: Rule for: Subject contains email address from To: header?)

Posted by Bill Cole <sa...@billmail.scconsult.com>.
On 2026-06-01 at 09:08:33 UTC-0400 (Mon, 01 Jun 2026 09:08:33 -0400)
Bill Cole <us...@spamassassin.apache.org>
is rumored to have said:

> On 2026-06-01 at 07:56:41 UTC-0400 (Mon, 1 Jun 2026 13:56:41 +0200)
> Benoit Panizzon <us...@spamassassin.apache.org>
> is rumored to have said:
>
>> Hi
>>
>> I figured out the culpit why a rule did not work was tflags publish
>
> That's obviously not good.
>
> The 'publish' tflag exists to force a rule in the full set of rules in our collection into the active list that is distributed.
>
>> Actual finding in trying to get the shipped rule TO_IN_SUBJ to match
>> anything. Just created a new rule with one of the regexp:
>>
>> header          TEST_EMAIL_SUBJ_TO      ALL =~ /\nSubject:(?=[^\n]{0,200}@)[^\n]{0,200}([a-z][a-z0-9_.]{3,80}@(?:[a-z0-9_]{1,80}\.){1,4}[a-z]{2,30})(?:[^\n]+\n)*To:\s+[^\n]{0,100}\1[^a-z0-9.]/ism
>> describe        TEST_EMAIL_SUBJ_TO      Testing: Email in Subject then To
>> score           TEST_EMAIL_SUBJ_TO      1
>> tflags          TEST_EMAIL_SUBJ_TO      publish
>>
>> When I remove the tflags line, the rule is run and matches as
>> expected when invoking SpamAssassin from MIMEDefang.
>>
>> When I keep the tflags line, then the rule seems to only run when
>> calling SpamAssassin from command line.
>
> This does not make sense. The publish tflag should not have any effect on how messages are checked.
>
> As described, this is definitely a bug.

However, I cannot reproduce it. I constructed a message matching TO_IN_SUBJ and ran it through both MIMEDefang and the spamassassin script. It hit in both cases.

Please note that TO_IN_SUBJ is not a simple rule. It is a meta-rule and will not fire if the message appears to be from a discussion list OR if the envelope sender matches the From header address.

>> So I wonder if there might be some setting somewhere to cause
>> spamassassin not running rules with a specific tflags in some
>> situations?

Thankfully, no.

The next step is for you to validate your MIMEDefang configuration to make sure that it is loading the same rules as the spamassassin script. Note that by default, MD loads /etc/mail/sa-mimedefang.cf, which the spamassassin script does not load. w


-- 
 Bill Cole
 bill@scconsult.com or billcole@apache.org
 (AKA @grumpybozo@toad.social and many *@billmail.scconsult.com addresses)
 Please keep discussion mailing list replies *on-list*
 Not Currently Available For Hire

Re: tflags publish <= What is this good for? (Re: Rule for: Subject contains email address from To: header?)

Posted by Bill Cole <sa...@billmail.scconsult.com>.
On 2026-06-01 at 07:56:41 UTC-0400 (Mon, 1 Jun 2026 13:56:41 +0200)
Benoit Panizzon <us...@spamassassin.apache.org>
is rumored to have said:

> Hi
>
> I figured out the culpit why a rule did not work was tflags publish

That's obviously not good.

The 'publish' tflag exists to force a rule in the full set of rules in our collection into the active list that is distributed.

> Actual finding in trying to get the shipped rule TO_IN_SUBJ to match
> anything. Just created a new rule with one of the regexp:
>
> header          TEST_EMAIL_SUBJ_TO      ALL =~ /\nSubject:(?=[^\n]{0,200}@)[^\n]{0,200}([a-z][a-z0-9_.]{3,80}@(?:[a-z0-9_]{1,80}\.){1,4}[a-z]{2,30})(?:[^\n]+\n)*To:\s+[^\n]{0,100}\1[^a-z0-9.]/ism
> describe        TEST_EMAIL_SUBJ_TO      Testing: Email in Subject then To
> score           TEST_EMAIL_SUBJ_TO      1
> tflags          TEST_EMAIL_SUBJ_TO      publish
>
> When I remove the tflags line, the rule is run and matches as
> expected when invoking SpamAssassin from MIMEDefang.
>
> When I keep the tflags line, then the rule seems to only run when
> calling SpamAssassin from command line.

This does not make sense. The publish tflag should not have any effect on how messages are checked.

As described, this is definitely a bug.

> So I wonder if there might be some setting somewhere to cause
> spamassassin not running rules with a specific tflags in some
> situations?

Not intentionally.




-- 
 Bill Cole
 bill@scconsult.com or billcole@apache.org
 (AKA @grumpybozo@toad.social and many *@billmail.scconsult.com addresses)
 Please keep discussion mailing list replies *on-list*
 Not Currently Available For Hire