fix: properly validate email containing comments

Originally reported by jomo (https://jomo.tv). A malicious actor could
register with an email address containing a comment, for example
"attacker@evil (comment@broken)". This commit fixes this issue by only
operating on normalized email addresses.

Signed-off-by: famfo <famfo@famfo.xyz>
This commit is contained in:
famfo
2025-08-30 09:45:14 +02:00
committed by Earl Warren
parent 9828aca733
commit cf1fda81f6
+8 -1
View File
@@ -80,8 +80,15 @@ func validateEmailDomain(email string) error {
}
func IsEmailDomainAllowed(email string) bool {
// Normalized the address. This strips for example comments which could be
// used to smuggle a different domain
parsedAddress, err := mail.ParseAddress(email)
if err != nil {
return false
}
return isEmailDomainAllowedInternal(
email,
parsedAddress.Address,
setting.Service.EmailDomainAllowList,
setting.Service.EmailDomainBlockList)
}