Legacy Knowledge Base
Published Jun. 30, 2025

Does having a script in a fragment qualify as a potential XSS vulnerability?

Written By

István Gergely-Tárnoki

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

  • We can put Javascript code in a fragment's HTML section where the code can be executed, when the fragment is opened, like <img src=x onerror="alert(document.cookie)">
  • Can that be a vulnerability to Cross Site Scripting (XSS)?

Environment

  • Liferay DXP 7.3+

Resolution

  • This is the intended behavior, as having scripts in a fragment HTML is a valid use case.
  • The HTML fragment does not provide any out-of-the-box sanitization, since we expect users to allow only advanced roles to use it, and they can restrict its access by configuring the Master page to not allow its usage. Any fragment admin can write any kind of Javascript in the fragment’s JS field and these scripts are not injected by malicious parties, but by admins to provide functionality to their site
  • Nevertheless, we provide:
Did this article resolve your issue ?

Legacy Knowledge Base