The vulnerability is a directory traversal in the handling of mj-include tags in MJML. The analysis of the provided information, including the GitHub issue and the related commits, reveals the following:
The root cause of the vulnerability is the lack of sanitization of the path attribute of the mj-include tag. An attacker can provide a payload like ../../../../../../etc/passwd to traverse the directory structure and access arbitrary files on the filesystem.
The vulnerability is triggered through the following call chain:
-
The mjml2html function in packages/mjml-core/src/index.js is the main API for converting MJML to HTML. It receives the malicious MJML input.
-
mjml2html calls MJMLParser in packages/mjml-parser-xml/src/index.js to parse the input.
-
Inside MJMLParser, when an mj-include tag is found, the code extracts the path attribute and passes it to a handleInclude function. The path is not sanitized before being used.
-
The handleInclude function reads the file from the provided path. The GitHub issue confirms that if the type attribute of the mj-include tag is set to css, the content of the file is included verbatim in the output, leading to arbitrary file disclosure.
The commits provided are related to a previous, incomplete fix for a similar vulnerability (CVE-2020-12827). The fix introduced an ignoreIncludes option, but this does not address the path traversal vulnerability itself and is not a secure default. Therefore, the application remains vulnerable.
Based on this analysis, the functions mjml2html and MJMLParser would appear in a runtime profile when the vulnerability is exploited. MJMLParser is the function that directly handles the malicious input, and mjml2html is the public-facing function that initiates the process.