From: lpsolit%gmail.com <> Date: Thu, 6 Nov 2008 00:41:33 +0000 (+0000) Subject: Bug 449931: [SECURITY] Unprivileged users can approve/unapprove all the quips (includ... X-Git-Tag: bugzilla-3.2rc2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5128f42a22ebe86ac63910305fa011dc71ad7c20;p=thirdparty%2Fbugzilla.git Bug 449931: [SECURITY] Unprivileged users can approve/unapprove all the quips (including bypassing moderation) - Patch by Robin H. Johnson r/a=LpSolit --- diff --git a/quips.cgi b/quips.cgi index 295b6c83fc..33b4e23ce7 100755 --- a/quips.cgi +++ b/quips.cgi @@ -88,6 +88,11 @@ if ($action eq "add") { } if ($action eq 'approve') { + $user->in_group('admin') + || ThrowUserError("auth_failure", {group => "admin", + action => "approve", + object => "quips"}); + # Read in the entire quip list my $quipsref = $dbh->selectall_arrayref("SELECT quipid, approved FROM quips"); @@ -100,11 +105,18 @@ if ($action eq 'approve') { my @approved; my @unapproved; foreach my $quipid (keys %quips) { - my $form = $cgi->param('quipid_'.$quipid) ? 1 : 0; - if($quips{$quipid} ne $form) { - if($form) { push(@approved, $quipid); } - else { push(@unapproved, $quipid); } - } + # Must check for each quipid being defined for concurrency and + # automated usage where only one quipid might be defined. + my $quip = $cgi->param("quipid_$quipid") ? 1 : 0; + if(defined($cgi->param("defined_quipid_$quipid"))) { + if($quips{$quipid} != $quip) { + if($quip) { + push(@approved, $quipid); + } else { + push(@unapproved, $quipid); + } + } + } } $dbh->do("UPDATE quips SET approved = 1 WHERE quipid IN (" . join(",", @approved) . ")") if($#approved > -1); diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index e0db5991b4..565ec1b077 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -146,6 +146,8 @@ schedule [% ELSIF action == "use" %] use + [% ELSIF action == "approve" %] + approve [% END %] [% IF object == "administrative_pages" %] diff --git a/template/en/default/list/quips.html.tmpl b/template/en/default/list/quips.html.tmpl index 14cecb26ee..d6000d5971 100644 --- a/template/en/default/list/quips.html.tmpl +++ b/template/en/default/list/quips.html.tmpl @@ -124,6 +124,9 @@ +