You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by bu...@spamassassin.apache.org on 2025/07/23 16:25:37 UTC

[Bug 8340] New: DMARC avoidance

https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

            Bug ID: 8340
           Summary: DMARC avoidance
           Product: Spamassassin
           Version: 4.0.2
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Private
          Assignee: dev@spamassassin.apache.org
          Reporter: giovanni@paclan.it
  Target Milestone: Undefined

On SpamAssassin-4.0.2-rc1 when the e-mail field "From:" contains space DMARC
check doesn't work and the spam/phishing emails are not blocked via
DMARC_REJECT rule.

Here's an example:

The following doesn't trigger the DMARC (note the space between no reply)
From: companyname <no reply@domain-example.com>

This works as expected and match DMARC_REJECT 
From: companyname <no...@domain-example.com>

Some of the spam/phishing e-mails start to use this technique to avoid the
DMARC.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #14 from Giovanni Bechis <gi...@paclan.it> ---
(In reply to Kent Oyer from comment #12)
> Created attachment 6030 [details]
> Add unit tests
> 
> Looks good. I made a couple minor changes and added some unit tests. Let me
> know what you think.
> 
> Now if only we could penalize messages that have parser errors...

bz https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8342

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|dev@spamassassin.apache.org |giovanni@paclan.it

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #6027|0                           |1
        is obsolete|                            |

--- Comment #11 from Giovanni Bechis <gi...@paclan.it> ---
Created attachment 6029
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=6029&action=edit
Set wrong emails as invalid

This fixes the email with spaces and silence a Warning in DMARC if the domain
is not valid.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #13 from Giovanni Bechis <gi...@paclan.it> ---
+1 for fkento@ diff.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #10 from Kent Oyer <ke...@mxguardian.net> ---
Ok, while it does makes sense to remove invalid chars from the domain portion,
what do we do with this:

"Support" <support@foo.com/bar.com>

Which domain should be used for DMARC lookup?

In the context of a parser, I think it is better to return the unmodified data
and set the "invalid" flag rather than to modify the data and not set the
"invalid" flag. Then dependent code can decide what to do with it.

Just my $0.02

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|giovanni@paclan.it          |dev@spamassassin.apache.org

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Group|private                     |

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #17 from Giovanni Bechis <gi...@paclan.it> ---
there is no code change between latest and previous patch and there are enough
+1,
you can just commit it.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #18 from Kent Oyer <ke...@mxguardian.net> ---
Commited in r1927705

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #6027|1                           |0
         is private|                            |

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Kent Oyer <ke...@mxguardian.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kent@mxguardian.net

--- Comment #7 from Kent Oyer <ke...@mxguardian.net> ---
First minor nitpick: Your regex has '\s' twice.

Second minor nitpick: Your patch seems to fix the DMARC issue however so does
this much simpler patch:

@@ -2640,10 +2640,6 @@
     if (defined $2) {
       # Remove comments (no nested support here)
       $address =~ s/\((?:|(?:[^()\\]++|\\.)*+)\)//gs;
-      # Validate as somewhat email looking
-      if ($address !~ /^$header_address_mailre$/) {
-        $address = undef;
-      }
     }


In other words, don't set $address to undef if it doesn't validate. By removing
invalid chars you are preventing other tests from checking for these invalid
chars. Your patch converts "no reply" to "noreply" but if I have this rule:

header   RULE_NAME   From:addr =~ /no reply/

it will not fire.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #9 from Giovanni Bechis <gi...@paclan.it> ---
Better with this:

Index: lib/Mail/SpamAssassin/Util.pm
===================================================================
--- lib/Mail/SpamAssassin/Util.pm       (revision 1927536)
+++ lib/Mail/SpamAssassin/Util.pm       (working copy)
@@ -2640,9 +2640,14 @@
     if (defined $2) {
       # Remove comments (no nested support here)
       $address =~ s/\((?:|(?:[^()\\]++|\\.)*+)\)//gs;
+      # Remove extra chars added after the domain
+      if($address =~ /(.*\@.*)[\x00-\x1F\x7F\s<>()[\]\\,;:\/"]/) {
+        $address = $1;
+      }
-       # Validate as somewhat email looking
-       if ($address !~ /^$header_address_mailre$/) {
-         $address = undef;
-       }
     }

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovanni@paclan.it
   Target Milestone|Undefined                   |4.0.2
            Version|4.0.2                       |unspecified

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #12 from Kent Oyer <ke...@mxguardian.net> ---
Created attachment 6030
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=6030&action=edit
Add unit tests

Looks good. I made a couple minor changes and added some unit tests. Let me
know what you think.

Now if only we could penalize messages that have parser errors...

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Comment #0 is|1                           |0
            private|                            |
      Comment #1 is|1                           |0
            private|                            |
      Comment #2 is|1                           |0
            private|                            |
      Comment #4 is|1                           |0
            private|                            |
      Comment #5 is|1                           |0
            private|                            |

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #8 from Giovanni Bechis <gi...@paclan.it> ---
(In reply to Kent Oyer from comment #7)
> First minor nitpick: Your regex has '\s' twice.
> 
> Second minor nitpick: Your patch seems to fix the DMARC issue however so
> does this much simpler patch:
> 
> @@ -2640,10 +2640,6 @@
>      if (defined $2) {
>        # Remove comments (no nested support here)
>        $address =~ s/\((?:|(?:[^()\\]++|\\.)*+)\)//gs;
> -      # Validate as somewhat email looking
> -      if ($address !~ /^$header_address_mailre$/) {
> -        $address = undef;
> -      }
>      }
> 
I've tried this, however, with this approach this email address will not be
checked by DMARC (and other) rules:
"Support" <support@domain.tld/support> 

> 
> In other words, don't set $address to undef if it doesn't validate. By
> removing invalid chars you are preventing other tests from checking for
> these invalid chars. Your patch converts "no reply" to "noreply" but if I
> have this rule:
> 
> header   RULE_NAME   From:addr =~ /no reply/
> 
> it will not fire.
maybe removing invalid chars after the domain like this might be enough.

Index: lib/Mail/SpamAssassin/Util.pm
===================================================================
--- lib/Mail/SpamAssassin/Util.pm       (revision 1927536)
+++ lib/Mail/SpamAssassin/Util.pm       (working copy)
@@ -2640,9 +2640,14 @@
     if (defined $2) {
       # Remove comments (no nested support here)
       $address =~ s/\((?:|(?:[^()\\]++|\\.)*+)\)//gs;
+      # Remove extra chars added after the domain
+      if($address =~ /(.*\@.*)[\x00-\x1F\x7F\s<>()[\]\\,;:\/"]/) {
+        $address = $1;
+      }
       # Validate as somewhat email looking
       if ($address !~ /^$header_address_mailre$/) {
         $address = undef;
       }
     }

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Bill Cole <bi...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |billcole@apache.org

--- Comment #6 from Bill Cole <bi...@apache.org> ---
+1 TO COMMIT

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Giovanni Bechis <gi...@paclan.it> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #19 from Giovanni Bechis <gi...@paclan.it> ---
Code committed in r1927705

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

Kent Oyer <ke...@mxguardian.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #6030|0                           |1
        is obsolete|                            |

--- Comment #16 from Kent Oyer <ke...@mxguardian.net> ---
Created attachment 6037
  --> https://bz.apache.org/SpamAssassin/attachment.cgi?id=6037&action=edit
Remove unnecessary change caused by my IDE

For some reason my IDE (PhpStorm) wants to keep changing the Latin-1 characters
on line 290 to UTF-8. Updated patch to keep them in Latin-1. Maybe we can fix
this later

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 8340] DMARC avoidance

Posted by bu...@spamassassin.apache.org.
https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

--- Comment #15 from Bill Cole <bi...@apache.org> ---
+1 for latest patch

-- 
You are receiving this mail because:
You are the assignee for the bug.

Re: [Bug 8340] New: DMARC avoidance

Posted by gi...@paclan.it.
On 7/23/25 6:45 PM, Benny Pedersen via dev wrote:
> bugzilla-daemon@spamassassin.apache.org skrev den 2025-07-23 18:25:
>> https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340
> 
>> Some of the spam/phishing e-mails start to use this technique to avoid the
>> DMARC.
> 
> is dkim results pass ?
> 
> i think we would soon begin to blacklist based on dkim signer, i keep my rants :)
> 
> dkim/dmarc is not full email addr, only domain name, so let them try
> 
> 
> 
the email I forged doesn't pass SPF, doesn't have DKIM headers but "passes" DMARC checks.
  Giovanni

Re: [Bug 8340] New: DMARC avoidance

Posted by Jared Hall via dev <de...@spamassassin.apache.org>.
On 7/23/2025 12:45 PM, Benny Pedersen via dev wrote:
> bugzilla-daemon@spamassassin.apache.org skrev den 2025-07-23 18:25:
>> https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340
>
>> Some of the spam/phishing e-mails start to use this technique to 
>> avoid the
>> DMARC.
>
> is dkim results pass ?
>
> i think we would soon begin to blacklist based on dkim signer, i keep 
> my rants :)
>
> dkim/dmarc is not full email addr, only domain name, so let them try
>

+1

I do the same; not very often.

Re: [Bug 8340] New: DMARC avoidance

Posted by Benny Pedersen via dev <de...@spamassassin.apache.org>.
bugzilla-daemon@spamassassin.apache.org skrev den 2025-07-23 18:25:
> https://bz.apache.org/SpamAssassin/show_bug.cgi?id=8340

> Some of the spam/phishing e-mails start to use this technique to avoid 
> the
> DMARC.

is dkim results pass ?

i think we would soon begin to blacklist based on dkim signer, i keep my 
rants :)

dkim/dmarc is not full email addr, only domain name, so let them try