The vulnerability is a reflected Cross-Site Scripting (XSS) issue in MantisBT. The entry point for the attack is the return_dynamic_filters.php script, which processes the filter_target GET parameter. The script failed to properly validate this parameter.
An attacker could craft a malicious filter_target value. This value, after partial processing, is passed as a field identifier to other functions responsible for rendering HTML form elements. Specifically, the functions print_filter_custom_field and print_filter_custom_field_date in core/filter_form_api.php would receive this malicious identifier and embed it without escaping into the name attribute of an <input> or <select> tag, leading to the execution of arbitrary JavaScript in the user's browser.
The patch addresses the vulnerability at two levels. First, it adds validation in return_dynamic_filters.php to ensure the custom field ID is numeric, thus preventing the malicious string from propagating. Second, as a defense-in-depth measure, it adds output escaping using string_html_specialchars in the functions print_filter_custom_field, print_filter_custom_field_date, and print_date_selection_set to ensure that even if un-sanitized data reaches them, it will not result in an XSS vulnerability.