]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 466692: [SECURITY] keywords and unused flag types can be deleted by bypassing...
authorlpsolit%gmail.com <>
Mon, 2 Feb 2009 19:04:31 +0000 (19:04 +0000)
committerlpsolit%gmail.com <>
Mon, 2 Feb 2009 19:04:31 +0000 (19:04 +0000)
editflagtypes.cgi
editkeywords.cgi
template/en/default/admin/flag-type/confirm-delete.html.tmpl
template/en/default/admin/keywords/confirm-delete.html.tmpl [changed mode: 0755->0644]
template/en/default/admin/keywords/list.html.tmpl [changed mode: 0755->0644]

index 6ed20c47c366c1199e01eabdbb01b3333b106208..ac71dba3671fb21ff024b93fab74b3a48bd899c7 100755 (executable)
@@ -389,16 +389,13 @@ sub update {
 }
 
 
-sub confirmDelete 
-{
-  my $id = validateID();
-
-  # check if we need confirmation to delete:
-  
-  my $count = Bugzilla::Flag::count({ 'type_id' => $id,
-                                      'is_active' => 1 });
-  
-  if ($count > 0) {
+sub confirmDelete {
+    my $id = validateID();
+
+    # check if we need confirmation to delete:
+    my $count = Bugzilla::Flag::count({ 'type_id' => $id,
+                                        'is_active' => 1 });
+
     $vars->{'flag_type'} = Bugzilla::FlagType::get($id);
     $vars->{'flag_count'} = scalar($count);
     $vars->{'token'} = issue_session_token('delete_flagtype');
@@ -408,11 +405,6 @@ sub confirmDelete
     # Generate and return the UI (HTML page) from the appropriate template.
     $template->process("admin/flag-type/confirm-delete.html.tmpl", $vars)
       || ThrowTemplateError($template->error());
-  } 
-  else {
-    my $token = issue_session_token('delete_flagtype');
-    deleteType($token);
-  }
 }
 
 
index e008cffc0062ff110bb1bc89b6abeed47226da28..04f045322e3ef7b2c30a08496b048ec39dd1ae72 100755 (executable)
@@ -247,36 +247,34 @@ if ($action eq 'update') {
 }
 
 
-if ($action eq 'delete') {
+if ($action eq 'del') {
     my $id = ValidateKeyID(scalar $cgi->param('id'));
 
     my $name = $dbh->selectrow_array('SELECT name FROM keyworddefs
                                       WHERE id= ?', undef, $id);
 
-    if (!$cgi->param('reallydelete')) {
-        my $bugs = $dbh->selectrow_array('SELECT COUNT(*) FROM keywords
-                                          WHERE keywordid = ?',
-                                          undef, $id);
-
-        # We need this token even if there is no bug using this keyword.
-        $token = issue_session_token('delete_keyword');
+    my $bugs = $dbh->selectrow_array('SELECT COUNT(*) FROM keywords
+                                      WHERE keywordid = ?',
+                                      undef, $id);
 
-        if ($bugs) {
-            $vars->{'bug_count'} = $bugs;
-            $vars->{'keyword_id'} = $id;
-            $vars->{'name'} = $name;
-            $vars->{'token'} = $token;
+    $vars->{'bug_count'} = $bugs;
+    $vars->{'keyword_id'} = $id;
+    $vars->{'name'} = $name;
+    $vars->{'token'} = issue_session_token('delete_keyword');
 
-            print $cgi->header();
+    print $cgi->header();
 
-            $template->process("admin/keywords/confirm-delete.html.tmpl", $vars)
-              || ThrowTemplateError($template->error());
+    $template->process("admin/keywords/confirm-delete.html.tmpl", $vars)
+      || ThrowTemplateError($template->error());
+    exit;
+}
 
-            exit;
-        }
-    }
-    # We cannot do this check earlier as we have to check 'reallydelete' first.
+if ($action eq 'delete') {
     check_token_data($token, 'delete_keyword');
+    my $id = ValidateKeyID(scalar $cgi->param('id'));
+
+    my $name = $dbh->selectrow_array('SELECT name FROM keyworddefs
+                                      WHERE id= ?', undef, $id);
 
     $dbh->do('DELETE FROM keywords WHERE keywordid = ?', undef, $id);
     $dbh->do('DELETE FROM keyworddefs WHERE id = ?', undef, $id);
index e67412a1c21e0ab4b87873d294e4133eaed014fa..411a8a3933df0586bc18fff0c73e2b848a2230b5 100644 (file)
 [% PROCESS global/header.html.tmpl title = title %]
 
 <p>
-   There are [% flag_count %] flags of type [% flag_type.name FILTER html %].
-   If you delete this type, those flags will also be deleted.  Note that
-   instead of deleting the type you can
+  [% IF flag_count %]
+    There are [% flag_count %] flags of type [% flag_type.name FILTER html %].
+    If you delete this type, those flags will also be deleted.
+  [% END %]
+
+  Note that instead of deleting the type you can
    <a href="editflagtypes.cgi?action=deactivate&amp;id=[% flag_type.id %]&amp;token=
            [%- token FILTER html %]">deactivate it</a>,
-   in which case the type and its flags will remain in the database
-   but will not appear in the [% terms.Bugzilla %] UI.
+  in which case the type [% IF flag_count %] and its flags [% END %] will remain
+  in the database but will not appear in the [% terms.Bugzilla %] UI.
 </p>
 
 <table>
old mode 100755 (executable)
new mode 100644 (file)
index 3329a54..e079f5d
@@ -33,7 +33,7 @@
 <p>
   [% IF bug_count == 1 %]
     There is one [% terms.bug %] with this keyword set.
-  [% ELSE %]
+  [% ELSIF bug_count > 1 %]
     There are [% bug_count %] [%+terms.bugs %] with
     this keyword set.
   [% END %]
@@ -45,7 +45,6 @@
 <form method="post" action="editkeywords.cgi">
   <input type="hidden" name="id" value="[% keyword_id %]">
   <input type="hidden" name="action" value="delete">
-  <input type="hidden" name="reallydelete" value="1">
   <input type="hidden" name="token" value="[% token FILTER html %]">
   <input type="submit" value="Yes, really delete the keyword">
 </form>
old mode 100755 (executable)
new mode 100644 (file)
index 0853332..41b7903
@@ -55,7 +55,7 @@
      { 
        heading => "Action" 
        content => "Delete"
-       contentlink => "editkeywords.cgi?action=delete&amp;id=%%id%%"
+       contentlink => "editkeywords.cgi?action=del&amp;id=%%id%%"
      }
    ]
 %]