| Description | When a master issue is being cloned by the user, including private bugnotes attachments (bug_report.php line 66), or the user performs bulk issues copying (bug_actiongroup.php line 157), they will ultimately call function file_copy_attachments from core/file_api.php to copy attachments to the destination bug.
In that function, the INSERT SQL query did not insert the value for column bugnote_id. Therefore, all copied attachments will become issue-level instead of bugnote-level, including but not limited to private bugnotes attachments:
function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
// [...]
for( $i = 0;$i < $t_count;$i++ ) {
// [...]
$t_query = 'INSERT INTO {bug_file} (
bug_id, title, description, diskfile, filename, folder,
filesize, file_type, date_added, user_id, content
)
VALUES ( '
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ', ' . db_param() .
')';
db_query( $t_query, array(
$p_dest_bug_id, $t_bug_file['title'], $t_bug_file['description'],
$t_new_diskfile_name, $t_new_file_name, $t_file_path,
$t_bug_file['filesize'], $t_bug_file['file_type'], $t_bug_file['date_added'],
$t_bug_file['user_id'], $t_bug_file['content']
) );
}
}
|
|---|
| Additional Information | Patch
To patch this vulnerability, it is recommended that the INSERT SQL query should also insert bugnote_id into table {bug_file}:
function file_copy_attachments( $p_source_bug_id, $p_dest_bug_id ) {
// [...]
for( $i = 0;$i < $t_count;$i++ ) {
// [...]
$t_query = 'INSERT INTO {bug_file} (
bug_id, title, description, diskfile, filename, folder,
filesize, file_type, date_added, user_id, content, bugnote_id
)
VALUES ( '
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ', ' . db_param() . ', ' . db_param() . ', '
. db_param() . ', ' . db_param() . ', ' . db_param() .
')';
db_query( $t_query, array(
$p_dest_bug_id, $t_bug_file['title'], $t_bug_file['description'],
$t_new_diskfile_name, $t_new_file_name, $t_file_path,
$t_bug_file['filesize'], $t_bug_file['file_type'], $t_bug_file['date_added'],
$t_bug_file['user_id'], $t_bug_file['content'], $t_bug_file['bugnote_id']
) );
}
}
|
|---|