Skip to main content

How to block spoofed emails

Comments

15 comments

  • cPRex Jurassic Moderator
    Hey there! The short answer is "you can't" - if there was a foolproof way to handle these it would be famous and implemented everywhere by now. The best recommendation would be to review the details here and ensure everything is set up on your side as best it can be to help authenticate legitimate messages from your server:
    0
  • linkup
    Pardon my ignorance as I haven't programmed in 30 years, but since it "knows" the mail didn't originate on my server, how hard is it to determine it is spoofed? Thanks for the link!
    0
  • linkup
    Hey there! The short answer is "you can't" - if there was a foolproof way to handle these it would be famous and implemented everywhere by now. The best recommendation would be to review the details here and ensure everything is set up on your side as best it can be to help authenticate legitimate messages from your server:
    0
  • cPRex Jurassic Moderator
    You're very welcome! As far as the "it should know" issue, the mailserver isn't always the smartest when it comes to handling those. It reads the data from the header as best it can, but there isn't a "check to see if this email address exists locally even though it came in remotely" function.
    0
  • linkup
    You're very welcome! As far as the "it should know" issue, the mailserver isn't always the smartest when it comes to handling those. It reads the data from the header as best it can, but there isn't a "check to see if this email address exists locally even though it came in remotely" function.

    I wasn't so much referring to the email address, but instead the IP address. It should be able to see the "from" address isn't the server's address. Seems like a quick easy check. I wrote a mail to my cousin who is an amazing programmer and very familiar with Unix so I will be curious to hear what he says. Thanks
    0
  • Jonathan.c
    @cPRex The article mentioned covers preventing inbound spoof emails, what about preventing outgoing spoof emails from servers?
    0
  • DennisMidjord
    @cPRex The article mentioned covers preventing inbound spoof emails, what about preventing outgoing spoof emails from servers?

    You can't prevent spoofed mails 100% but setting up SPF and DKIM gets you a long way. SPF lets you specify which IP's/hosts that your email may be sent from. DKIM adds a digital signiture to the email which lets the receiving server verify that the message actually comes from your server. Additionally, you can also setup DMARC which allows you to specify what the receiving server should do with the message in case SPF and/or DKIM fails. It's still up to the receiving email server to support all those options, though, and you're never going to be able to prevent spoofing completely.
    0
  • cPRex Jurassic Moderator
    I'm not sure how you would be detecting outbound spoofed messages? Do you have an example from a log that you could share of such a message being sent from your machine? As @DennisMidjord mentioned, the same tools apply as they are DNS-level verification, so they'd help with either direction.
    0
  • lowraxe
    I read through this thread, but didn't see that what I'm trying to do was clearly addressed. Perhaps I somehow missed it, but I think the responses have generally been that what I'm aiming to do is not possible for some reason. Here's my situation: I have cPanel set so that any emails that arrive from my domain are whitelisted. In this way, even if one of the other folks on my domain sent me a spam, it would come through. Recently, I have been receiving emails from spammers that are spoofing my domain, so, of course, those emails are coming through per my whitelist, which, as far as I can tell, only looks at the envelope-from line to identify who sent the email. However, if I look at the headers for any of the spoofed emails, I can find clear differences between a valid email, sent from me or from any other sender on my domain, and one sent from a spammer. In particular, if I send an email from my domain to one of my other addresses on a different domain, I can see that there are distinct items that I would think I can filter based on. So, for example, if a particular item does not exist in the header, use the filter to send it to the spam folder. So the question is, can't I set up a simple filter that looks for key items in the header of any email sent from my domain (or "sent from my domain") to identify it as validly sent from my domain, rather than from a spammer? Thanks!
    0
  • cPRex Jurassic Moderator
    So the question is, can't I set up a simple filter that looks for key items in the header of any email sent from my domain (or "sent from my domain") to identify it as validly sent from my domain, rather than from a spammer?

    Not really? If it were that easy, every email system on the planet would already have it in place and there would be no more spoofing.
    0
  • lowraxe
    OK, while I was waiting for a response though, I just set up a filter that says if "from" contains my domain, and "any header" does not contain a certain line that my emails appear to consistently contain (in this case, X-authenticated-sender: ) then send the email to spam. Is there a reason this is not a valid way to address what I've posed?
    0
  • cPRex Jurassic Moderator
    It's possible that will work well for you, but spammers that send out millions of emails can manipulate the headers any way they choose, so this may not work for every situation.
    0
  • lowraxe
    Looks like it's working OK so far (last 20 minutes or so). I ran a couple of test emails through the filter test and it looked OK. I'll try to remember to report back here after a few weeks with an update on how it works out. I'm not too concerned about a few spam spoofs slipping through. My bigger concern would be with rejecting too many valid emails. However, I'm working on a very specific case here, which is to filter out emails that are supposedly from my domain, but aren't actually. It seems like a controlled enough case that this (or something else) should be a reasonable solution. If anyone on this forum who knows more than me about these issues (pretty much anyone) sees a flaw in what I'm doing, please let me know so I can modify my approach, or just give up altogether. Thanks!
    0
  • lowraxe
    Well, I found a problem pretty quickly. It appears the headers do not always necessarily contain the "X-authenticated-sender" line. With that in mind, is there a way in cPanel to add some custom content to the header of any email that is sent out from my domain so that I can then filter based on that content?
    0
  • cPRex Jurassic Moderator
    Told ya ;) There is a way with Exim itself, but that work would need to be researched and performed outside of cPanel tools, and our tools don't get to that level of Exim customization.
    0

Please sign in to leave a comment.