Issue
- Vulnerability issues (ejs template injection vulnerability) were reported related to the EJS version inside the yarn.lock file while building fragments using the fragments toolkit.
- The EJS version is below 3.1.9 in many places in this yarn.lock file.
Environment
- Liferay DXP 7.4
Resolution
- The fragment toolkit is going to be deprecated (as per the roadmap) and instead of having a separate tool for fragments, this functionality will be unified with other tools in the portal.
-
Regarding the EJS vulnerability, the EJS library only runs when generating new files in the developer's (eg. running
yarn run add-fragment) computer, the code generated by each template can (and should) be reviewed and updated by the developer, so no harmful code should reach the portal at any time. Therefore, the only viable fix for this concern would be to review the code and ensure that no harmful code reaches the portal.
Please note that the fragment toolkit is only used to generate boilerplate code and it should be fine to submit code to the portal as long as it is being reviewed by a developer.
-
Furthermore, the following are some suggestions that might be helpful in preventing any EJS vulnerability issues (inside fragments toolkit):
- Do not develop fragments in the same production machine where the portal is published but in another development environment. The same must be followed even with updated dependencies.
- In case you have some security policy against all of this (which could be reasonable), then it is suggested to develop the fragments on an external machine and import them using the UI, either with zip files or by copy-pasting the code in the fragment administration.