The vulnerability is a reflected Cross-Site Scripting (XSS) issue in FacturaScripts. The root cause lies in the Core/View/Macro/Utils.html.twig template, specifically within the master macro. This macro uses Twig's |raw filter when rendering log messages, which disables the default output escaping and allows any HTML or JavaScript within the message to be executed by the browser.
The exploit chain begins when a user sends a request with a malicious payload to an endpoint that performs a database query, such as the EditProducto controller with a malformed code parameter. This input causes the database to throw an error. The DataBase::select method (or similar methods like exec and query) catches this error and logs the database's error message, which includes the original malicious payload.
Finally, this log message is passed to the Utils.master macro to be displayed to the user. Due to the |raw filter, the malicious script is rendered unescaped and executes in the context of the user's session. The fix involved removing the |raw filter from the template, ensuring all log messages are properly HTML-escaped by default.