Skip to main content

Block custom attachments EXIM issue

Comments

15 comments

  • cPanelMichael
    Hello, In "WHM >> Exim Configuration Manager", under the "Filters" tab, are you using a custom filter for the "System Filter File" option? If so, you'd need to add your custom filter rules to that custom system filter file itself instead of adding them as separate filter files under the options directory. There's a thread on this topic at:
    0
  • EneTar
    In "WHM >> Exim Configuration Manager", under the "Filters" tab, are you using a custom filter for the "System Filter File" option?

    As I said
    I have created a custom system filter at /etc/cpanel_exim_system_filter_custom by copying the /etc/cpanel_exim_system_filter

    and I have selected that file in Exim Configuration Manager", under the "Filters" tab. My post also includes the content of that file which is a copy of the original and has some additional extensions to be blocked. Please look at the content of the file above. It includes the extensions ace|jar|r00|iso in addition to the defaults. So what you are saying
    add your custom filter rules to that custom system filter

    is true. The custom system filter contains the additional extensions. Trying to send from an external email account (Yahoo) the file I attached earlier which is an .iso file it hits the inbox on my server. Shouldn't it get blocked?
    0
  • EneTar
    I don't know what other services should I restart (I tried to restart only Exim). After a full system restart it seems that it works. Thank you
    0
  • cPanelMichael
    I don't know what other services should I restart (I tried to restart only Exim). After a full system restart it seems that it works. Thank you

    Hello, Exim restarts automatically when you save changes in the Exim Configuration Manager interface. Can you confirm the issue is now solved? Thank you.
    0
  • EneTar
    Yes it is resolved thank you
    0
  • EneTar
    I made several tests by attaching a single .ace file.
    • I used a yahoo account as a sender
    • As a recipient I used the same email address on my cpanel server.
    • All email messages had as an attachment the same .ace file.
    • The only thing I changed was the text of the subject and the text content of the body.
    For 10 tests that I made i noticed that some tests returned with error to the sender and some of the them got delivered into the recipient's inbox. So what does Exim do exactly? Does it apply the system filter randomly? Then I noticed the block below which is copied from the /etc/cpanel_exim_system_filter to my custom system filter. if not first_delivery then finish endif
    What does this mean? Is this the reason?
    0
  • EneTar
    I noticed that the messages that bypass the filter have the filename of the attachment as base64 encoded that's why EXIM doesn't filter them out. For example one message that bypassed the filter has Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="=?UTF-8?b?UFJPRk9STUEgSU5WT0lDRSAwNi0wMi0yMDE4LmFjZQ==?=" .... .. .
    However this UFJPRk9STUEgSU5WT0lDRSAwNi0wMi0yMDE4LmFjZQ==
    is base64 encoded and it is equal to PROFORMA INVOICE 06-02-2018.ace
    Reminder: .ace extensions are blocked in my custom EXIM system filter. So is there any way to base64 decode the filenames before filtering in Exim or perhaps spamassassin?
    0
  • rpvw
    Can you not do a string comparison on LmFjZQ== which is the .ace part ?
    0
  • EneTar
    Good idea so the ad[ep]|ba[st]|chm|cmd|com|cpl|crt|eml|exe|jar|ace|r00|iso|z|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]
    should become ad[ep]|ba[st]|chm|cmd|com|cpl|crt|eml|exe|jar|LmFjZQ==|ace|r00|iso|z|hlp|hta|in[fs]|isp|jse?|lnk|md[be]|ms[cipt]|pcd|pif|reg|scr|sct|shs|url|vb[se]|ws[fhc]
    Going to test in a while
    0
  • rpvw
    If that doesn't work (I suspect it wont because it includes a leading "." and the regex is looking for anything after the ".") you may need to experiment. I don't think that including it in the current regex for file extensions is going to be possible. You may need to add a supplemental set of header and body regex lines. This site might be useful :
    0
  • EneTar
    It doesn't work. I'm using that website as well. "PO-2018-30-01 - ape.ace" and "Filename-something.ace" have different endings. so the whole filename needs to be decoded first. Any ideas how this would work? I'm not an expert in base64 encoding and I'm not sure if it is possible in Exim either.
    0
  • rpvw
    I got about as far as finding a regex that you may be able to use to check if a header is base64 encoded ^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$
    I now have a headache !
    0
  • EneTar
    Rejecting base64 headers in general might not be a good idea. Here is some info as well regarding base64 headers (and other stuff as well) Filtering spam with Exim only Nothing about decoding though, and filtering later the base64 filename in the attachment.
    0
  • rpvw
    I suspect that the complexities of base64 decoding and then filtering would be beyond the scope of exim on its own. It would probably be handled by piping to an external program for processing like to Spamassassin or Clamav. I know that Spamassassin has scores for invalid characters in base64 encoding, and maybe Clamav also decodes the base64. Perhaps one could do something at this stage rather than re-inventing the wheel.
    0

Please sign in to leave a comment.