Описание
Mailgen: HTML injection vulnerability in plaintext e-mails
HTML Injection and XSS Filter Bypass in Plaintext Emails
Summary
An HTML injection vulnerability in plaintext emails generated by Mailgen has been discovered. Your project is affected if you use the Mailgen.generatePlaintext(email); method and pass in user-generated content. The issue was discovered and reported by Edoardo Ottavianelli (@edoardottt).
Vulnerability Analysis
The following function (inside index.js) is intended to strip all HTML content to produce a plaintext string.
The process fails because it first converts HTML break tags to newlines and then attempts to strip HTML tags with a regular expression. Using a break tag inside another HTML tag can deceive the filter, allowing HTML content to be injected into the email.
A valid payload is: <img<br> src=xyz onerror=alert(1)>.
Proof of Concept
Resulting output file (emailText.txt):
Mitigation
The vulnerability has been patched in commit 741a019 and released to npm in version 2.0.30.
Thanks to Edoardo Ottavianelli (@edoardottt) for discovering and reporting this vulnerability.
Пакеты
mailgen
< 2.0.30
2.0.30
Связанные уязвимости
mailgen is a Node.js package that generates responsive HTML e-mails for sending transactional mail. Prior to version 2.0.30, there is an HTML injection vulnerability in plaintext e-mails generated by Mailgen. Projects are affected if the Mailgen.generatePlaintext(email) method is used and given user-generated content. This vulnerability has been patched in version 2.0.30. A workaround involves stripping all HTML tags before passing any content into Mailgen.generatePlaintext(email).
Уязвимость метода Mailgen.generatePlaintext(email) пакета Mailgen программной платформы Node.js, позволяющая нарушителю выполнить произвольный HTML-код