Skip to content

Commit b08e9c1

Browse files
committedSep 5, 2011
Fix #13140: Incorrect permissions check during bug reporting and cloning
Todd Whitesel reported an issue with incorrect permissions checks being performed when cloning issues. The steps to reproduce this bug were provided by Todd: ------ Fresh 1.2.5 install. Create two users, a Developer and an Updater. Create a private project. (Actually create a couple more projects so you can see the project selector.) Add both users to the private project AS MANAGERS. Login as Developer, select the private project, and create an issue. Login as Updater, select All Projects, and attempt to clone that issue. It fails with ACCESS DENIED error #13. Also note that your access level was Manager while editing the cloned issue, but in the error screen your access level is back to your global access of Updater. As Updater, Select the private project, create an issue. Then select All Projects, and attempt to clone that issue. It succeeds, apparently because you are cloning your own issue. Create a public project and attach the private project as a subproject of it. Retry the above cloning tests with the public parent project instead of All Projects -- the results are the same whether you select All Projects or the parent project. ------ The problem was that the current project (from the project selector dropdown) was used as the basis for config_get calls, thus leading to incorrect permissions and settings being used within bug_report.php. We need to instead switch (temporarily) the current project to either the master issue (when cloning) or the specified project_id (when creating a new issue via bug_report_page.php). Thanks again to Todd for the discovery and debugging of this problem, the detailed bug report and initial patch (that has been extended to resolve the second project_id issue from bug_report_page.php). Conflicts: bug_report.php
1 parent 7af2f47 commit b08e9c1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed
 

‎bug_report.php

+22-1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,27 @@
8080

8181
form_security_validate( 'bug_report' );
8282

83+
$t_project_id = null;
84+
$f_master_bug_id = gpc_get_int( 'm_id', 0 );
85+
if ( $f_master_bug_id > 0 ) {
86+
bug_ensure_exists( $f_master_bug_id );
87+
if ( bug_is_readonly( $f_master_bug_id ) ) {
88+
error_parameters( $f_master_bug_id );
89+
trigger_error( ERROR_BUG_READ_ONLY_ACTION_DENIED, ERROR );
90+
}
91+
$t_master_bug = bug_get( $f_master_bug_id, true );
92+
project_ensure_exists( $t_master_bug->project_id );
93+
access_ensure_bug_level( config_get( 'update_bug_threshold', null, null, $t_master_bug->project_id ), $f_master_bug_id );
94+
$t_project_id = $t_master_bug->project_id;
95+
} else {
96+
$f_project_id = gpc_get_int( 'project_id' );
97+
project_ensure_exists( $f_project_id );
98+
$t_project_id = $f_project_id;
99+
}
100+
if ( $t_project_id != helper_get_current_project() ) {
101+
$g_project_override = $t_project_id;
102+
}
103+
83104
access_ensure_project_level( config_get('report_bug_threshold' ) );
84105

85106
$t_bug_data = new BugData;
@@ -118,7 +139,7 @@
118139
$f_copy_attachments_from_parent = gpc_get_bool( 'copy_attachments_from_parent', false);
119140

120141

121-
$t_bug_data->project_id = gpc_get_int( 'project_id' );
142+
$t_bug_data->project_id = $t_project_id;
122143

123144
$t_bug_data->reporter_id = auth_get_current_user_id();
124145

0 commit comments

Comments
 (0)
Please sign in to comment.