LukeSmithxyz / emailwiz

Script that installs/configures a Dovecot, Postfix, Spam Assassin, OpenDKIM Debian web server
GNU General Public License v3.0
1.82k stars 302 forks source link

You can still spoof the local email domain through subdomains #293

Open william-stacken opened 1 year ago

william-stacken commented 1 year ago

See #237 for context. Someone was able to bypass the fix by sending "from" the mail subdomain. Seems like any valid subdomain is affected by this.

I solved it by adding the line echo "/^(.*)@(.*)\.$(sh -c "echo $domain | sed 's/\./\\\./'")$/ \${1}" >> /etc/postfix/login_maps.pcre below the previous line. This works for me since I don't have more than one level of subdomains, but there may be a better more general purpose solution.

How to reproduce:

openssl s_client -starttls smtp -connect mail.example.com:587 <<EOF
helo example.com
mail from:<admin@mail.example.com>
rcpt to:<user@example.com>
Data
From: <admin@mail.example.com>
To: <user@example.com>     
Subject: Yo

This is a mail
.
quit
EOF