On port 25 we wishes that only mails originating from the platform (either authenticated OR DKIM signed) uses FROM local address in their mail headers.
GIVEN attacker@evil.com
WHEN attacker@evil.com sends a mail to a local user
AND uses `MAIL FROM: <attacker@evil.com>` in the envelope
AND sets `From: victim@local.fr`
THEN the SMTP transaction on port 25 gets rejected as the mail is not DKIM signed
Note: legitimate use of local from from external sender is:
GIVEN lawyer1@orange.fr redirects mails to lawyer1@platform.fr
WHEN lawyer2@platform.fr sends a mail to lawyer1@orange.fr
THEN orange.fr will send us a mail using a local From but we shall accept it as the DKIM is valid...
What to do
Modify DKIMHook.DKIMCheckNeeded.onlyForSenderDomain in order to apply if the from of the envelope is matching the domain OR the *header from is matching the specified domain.
Special care needs to be taken in order to handle invalid header from (second clause is skept in case of error).
On port 25 we wishes that only mails originating from the platform (either authenticated OR DKIM signed) uses FROM local address in their mail headers.
Note: legitimate use of local from from external sender is:
What to do
Modify
DKIMHook.DKIMCheckNeeded.onlyForSenderDomain
in order to apply if the from of the envelope is matching the domain OR the *header from is matching the specified domain.Special care needs to be taken in order to handle invalid header from (second clause is skept in case of error).
We need both unit and integration tests for this.