mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 03:54:21 +00:00
189505c80f
# Which Problems Are Solved ZITADEL uses HTML for emails and renders certain information such as usernames dynamically. That information can be entered by users or administrators. Due to a missing output sanitization, these emails could include malicious code. This may potentially lead to a threat where an attacker, without privileges, could send out altered notifications that are part of the registration processes. An attacker could create a malicious link, where the injected code would be rendered as part of the email. During investigation of this issue a related issue was found and mitigated, where on the user's detail page the username was not sanitized and would also render HTML, giving an attacker the same vulnerability. While it was possible to inject HTML including javascript, the execution of such scripts would be prevented by most email clients and the Content Security Policy in Console UI. # How the Problems Are Solved - All arguments used for email are sanitized (`html.EscapeString`) - The email text no longer `html.UnescapeString` (HTML in custom text is still possible) - Console no longer uses `[innerHtml]` to render the username # Additional Changes None # Additional Context - raised via email --------- Co-authored-by: peintnermax <max@caos.ch>
52 lines
2.0 KiB
Go
52 lines
2.0 KiB
Go
package templates
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
|
"github.com/zitadel/zitadel/internal/i18n"
|
|
)
|
|
|
|
const (
|
|
DefaultFontFamily = "-apple-system, BlinkMacSystemFont, Segoe UI, Lato, Arial, Helvetica, sans-serif"
|
|
DefaultFontColor = "#22292f"
|
|
DefaultBackgroundColor = "#fafafa"
|
|
DefaultPrimaryColor = "#5282C1"
|
|
)
|
|
|
|
type TemplateData struct {
|
|
Title string
|
|
PreHeader string
|
|
Subject string
|
|
Greeting string
|
|
Text string
|
|
URL string
|
|
ButtonText string
|
|
PrimaryColor string
|
|
BackgroundColor string
|
|
FontColor string
|
|
LogoURL string
|
|
FontURL string
|
|
FontFaceFamily string
|
|
FontFamily string
|
|
|
|
IncludeFooter bool
|
|
FooterText string
|
|
}
|
|
|
|
func (data *TemplateData) Translate(translator *i18n.Translator, msgType string, args map[string]interface{}, langs ...string) {
|
|
data.Title = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessageTitle), args, langs...)
|
|
data.PreHeader = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessagePreHeader), args, langs...)
|
|
data.Subject = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessageSubject), args, langs...)
|
|
data.Greeting = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessageGreeting), args, langs...)
|
|
data.Text = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessageText), args, langs...)
|
|
data.ButtonText = translator.Localize(fmt.Sprintf("%s.%s", msgType, domain.MessageButtonText), args, langs...)
|
|
// Footer text is neither included in i18n files nor defaults.yaml
|
|
footerText := fmt.Sprintf("%s.%s", msgType, domain.MessageFooterText)
|
|
data.FooterText = translator.Localize(footerText, args, langs...)
|
|
// translator returns the id of the string to be translated if no translation is found for that id
|
|
// we'll include the footer if we have a custom non-empty string and if the string doesn't include the
|
|
// id of the string that could not be translated example InitCode.Footer
|
|
data.IncludeFooter = len(data.FooterText) > 0 && data.FooterText != footerText
|
|
}
|