Skip to content

Conversation

offlinehoster
Copy link

@offlinehoster offlinehoster commented Sep 2, 2025

In case of unwanted spamfloods your mailcow will relay incoming mails from other mailservers because of a wrong rcpt_to or from: header. I this case you have can secue your mailcow by adding those 2 restrictions, one for external relays and also for the internal usecase, when you may accidently use the wrong relay adress with your auth.

In my case I learned that this will deny round about 20k spammails from outside, who tried to use my mailcow as "openrelay" because they used a wrong from/rcpt_to address and my mailcow thought..ok I will relay it back to the "primary" spam destination....

Contribution Guidelines

What does this PR include?

Short Description

Add 2 more settings to the smtpd_relay_restrictions key to make sure that no other auth or unwanted unauth relaying will happen under a wrong name/permission.

Affected Containers

  • postfix-mailcow

Did you run tests?

Yes

What did you tested?

I tested from internal/external by script to try to relay to external mailserver an undelivered mail -> denied (expected)
-> Sender address rejected: User unknown in virtual mailbox table;

What were the final results? (Awaited, got)

The default mailcow installaiton is now not anylonger possible to relay a mail from external to another external mailserver and so it's not an openrelay anymore. With the default config you do not have those 2 settings which mean that you could possible use "any" default mailcow to flood by relaying any other mail instance as you want to flood.
You're also not able to relay a mail from your own mailcow from another "domain" which does not belong to your own mailcow account. You can only relay with your own credentials and your own "domains/accounts".

FreddleSpl0it and others added 14 commits January 23, 2025 12:01
[Nginx] move conf.d include to end of nginx.conf
…ges (mailcow#6273)

* clamd: update to 1.4.2 + build from source instead using alpine packages

* clamd: remove exposed ports from buildfile

* clamd: cleanup dockerfile
In case of unwanted spamfloods your mailcow will relay incoming mails from other mailservers because of a wrong rcpt_to or from: header. I this case you have can secue your mailcow by adding those 2 restrictions, one for external relays and also for the internal usecase, when you may accidently use the wrong relay adress with your auth. 

In my case I learned that this will deny round about 20k spammails from outside, who tried to use my mailcow as "openrelay" because they used a wrong from/rcpt_to address and my mailcow thought..ok I will relay it back to the "primary" spam destination....
@milkmaker
Copy link
Collaborator

Thanks for contributing!

I noticed that you didn't select staging as your base branch. Please change the base branch to staging.
See the attached picture on how to change the base branch to staging:

check_prs_if_on_staging.png

1 similar comment
@milkmaker
Copy link
Collaborator

Thanks for contributing!

I noticed that you didn't select staging as your base branch. Please change the base branch to staging.
See the attached picture on how to change the base branch to staging:

check_prs_if_on_staging.png

@offlinehoster offlinehoster changed the base branch from master to staging September 2, 2025 09:54
@offlinehoster offlinehoster changed the title Prevent unwanted unauth relaying to other mailservers [Postfix] Prevent unwanted unauth relaying to other mailservers Sep 2, 2025
@DerLinkman DerLinkman added the not matching contrib guidelines Whenever a issue/pr is not matching the Guidelines this tag will assigned label Sep 3, 2025
@DerLinkman
Copy link
Member

Violating Contrib Rule 3, please reopen based on staging

@DerLinkman DerLinkman closed this Sep 3, 2025
@offlinehoster
Copy link
Author

Let's try this -> #6707

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not matching contrib guidelines Whenever a issue/pr is not matching the Guidelines this tag will assigned
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants