Filter Received-SPF header by receiver hostname
Ensures parseLegacySPF only trusts Received-SPF headers where the receiver= field matches the configured receiverHostname, preventing incorrect SPF results from unrelated receivers.
This commit is contained in:
parent
a36824cf27
commit
b158336451
1 changed files with 10 additions and 0 deletions
|
|
@ -63,6 +63,16 @@ func (a *AuthenticationAnalyzer) parseLegacySPF(email *EmailMessage) *api.AuthRe
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verify receiver matches our hostname
|
||||||
|
if a.receiverHostname != "" {
|
||||||
|
receiverRe := regexp.MustCompile(`receiver=([^\s;]+)`)
|
||||||
|
if matches := receiverRe.FindStringSubmatch(receivedSPF); len(matches) > 1 {
|
||||||
|
if matches[1] != a.receiverHostname {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result := &api.AuthResult{}
|
result := &api.AuthResult{}
|
||||||
|
|
||||||
// Extract result (first word)
|
// Extract result (first word)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue