CVE-2024-34080: Insufficient Information (NVD-CWE-noinfo)
value: MantisBT (Mantis Bug Tracker) is an open source issue tracker. If an issue references a note that belongs to another issue that the user doesn't have access to, then it gets hyperlinked. Clicking on the link gives an access denied error as expected, yet some information remains available via the link, link label, and tooltip. This can result in disclosure of the existence of the note, the note author name, the note creation timestamp, and the issue id the note belongs to. Version 2.26.2 contains a patch for the issue. No known workarounds are available.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
Published: 2024-05-14T15:38Z
Repository: https://github.com/mantisbt/mantisbt
Language: PHP
Files changed: core/string_api.php
Commit date: 2024-05-12 17:38:56 +0200
Commit message: Fix access level check for note links

Fixes #34434

Diff: diff --git a/core/string_api.php b/core/string_api.php
index 3bf9a8e41cf..ddcb2d92298 100644
--- a/core/string_api.php
+++ b/core/string_api.php
@@ -418,28 +418,36 @@ function string_process_bugnote_link( $p_string, $p_include_anchor = true, $p_de
 					global $g_project_override;
 					$c_bugnote_id = (int)$p_array[2];
 					if( bugnote_exists( $c_bugnote_id ) ) {
 						$t_bug_id = bugnote_get_field( $c_bugnote_id, 'bug_id' );
 						if( bug_exists( $t_bug_id ) ) {
-							$g_project_override = bug_get_field( $t_bug_id, 'project_id' );
-							if(   access_compare_level(
-										user_get_access_level( auth_get_current_user_id(),
-										bug_get_field( $t_bug_id, 'project_id' ) ),
-										config_get( 'private_bugnote_threshold' )
-								   )
-								|| bugnote_get_field( $c_bugnote_id, 'reporter_id' ) == auth_get_current_user_id()
-								|| bugnote_get_field( $c_bugnote_id, 'view_state' ) == VS_PUBLIC
-							) {
-								$g_project_override = null;
-								return $p_array[1] .
-									string_get_bugnote_view_link(
-										$t_bug_id,
-										$c_bugnote_id,
-										(boolean)$p_detail_info,
-										(boolean)$p_fqdn
-									);
+							$t_project_id = bug_get_field( $t_bug_id, 'project_id' );
+							$t_user_id = auth_get_current_user_id();
+
+							$g_project_override = $t_project_id;
+
+							$t_can_view_issue = access_has_bug_level( config_get( 'view_bug_threshold' ), $t_bug_id, $t_user_id );
+							if( $t_can_view_issue ) {
+								$t_can_view_note = access_compare_level(
+									user_get_access_level( $t_user_id, $t_project_id ),
+									config_get( 'private_bugnote_threshold' )
+									)
+									|| bugnote_get_field( $c_bugnote_id, 'reporter_id' ) == $t_user_id
+									|| bugnote_get_field( $c_bugnote_id, 'view_state' ) == VS_PUBLIC;
+
+								if( $t_can_view_note ) {
+									$g_project_override = null;
+									return $p_array[1] .
+										string_get_bugnote_view_link(
+											$t_bug_id,
+											$c_bugnote_id,
+											(boolean)$p_detail_info,
+											(boolean)$p_fqdn
+										);
+								}
 							}
+
 							$g_project_override = null;
 						}
 					}
 					return $p_array[0];
 				}; # end of bugnote link callback closure

Vulnerable code: 							$g_project_override = bug_get_field( $t_bug_id, 'project_id' );
							if(   access_compare_level(
										user_get_access_level( auth_get_current_user_id(),
										bug_get_field( $t_bug_id, 'project_id' ) ),
										config_get( 'private_bugnote_threshold' )
								   )
								|| bugnote_get_field( $c_bugnote_id, 'reporter_id' ) == auth_get_current_user_id()
								|| bugnote_get_field( $c_bugnote_id, 'view_state' ) == VS_PUBLIC
							) {
								$g_project_override = null;
								return $p_array[1] .
									string_get_bugnote_view_link(
										$t_bug_id,
										$c_bugnote_id,
										(boolean)$p_detail_info,
										(boolean)$p_fqdn
									);
Fixed code: 							$t_project_id = bug_get_field( $t_bug_id, 'project_id' );
							$t_user_id = auth_get_current_user_id();

							$g_project_override = $t_project_id;

							$t_can_view_issue = access_has_bug_level( config_get( 'view_bug_threshold' ), $t_bug_id, $t_user_id );
							if( $t_can_view_issue ) {
								$t_can_view_note = access_compare_level(
									user_get_access_level( $t_user_id, $t_project_id ),
									config_get( 'private_bugnote_threshold' )
									)
									|| bugnote_get_field( $c_bugnote_id, 'reporter_id' ) == $t_user_id
									|| bugnote_get_field( $c_bugnote_id, 'view_state' ) == VS_PUBLIC;

								if( $t_can_view_note ) {
									$g_project_override = null;
									return $p_array[1] .
										string_get_bugnote_view_link(
											$t_bug_id,
											$c_bugnote_id,
											(boolean)$p_detail_info,
											(boolean)$p_fqdn
										);
								}