Skip to content

Potential fix for code scanning alert no. 2: Email content injection#23

Merged
gustaavik merged 1 commit into
mainfrom
alert-autofix-2
May 9, 2025
Merged

Potential fix for code scanning alert no. 2: Email content injection#23
gustaavik merged 1 commit into
mainfrom
alert-autofix-2

Conversation

@gustaavik
Copy link
Copy Markdown
Member

Potential fix for https://github.com/Zenfulcode/CommercifyGO/security/code-scanning/2

To fix the issue, we need to sanitize and validate all user-provided data before it is used in constructing email content. Specifically:

  1. Sanitize the data.Subject and data.Body fields in the SendEmail function to ensure they do not contain malicious content.
  2. Use a trusted source for any dynamic data included in the email, such as configuration values or validated inputs.
  3. Ensure that the renderTemplate function is only used with trusted and sanitized data.

The changes will be made in internal/infrastructure/email/smtp_email_service.go to sanitize the data.Subject and data.Body fields before constructing the email message.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@gustaavik gustaavik marked this pull request as ready for review May 9, 2025 10:58
@gustaavik gustaavik merged commit b16cd79 into main May 9, 2025
4 checks passed
@gustaavik gustaavik deleted the alert-autofix-2 branch May 9, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant