]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 515191: [SECURITY] SQL Injection via Bug.create (CVE-2009-3165)
authormkanat%bugzilla.org <>
Fri, 11 Sep 2009 16:15:43 +0000 (16:15 +0000)
committermkanat%bugzilla.org <>
Fri, 11 Sep 2009 16:15:43 +0000 (16:15 +0000)
Bugzilla/Object.pm
Bugzilla/WebService/Constants.pm [changed mode: 0755->0644]
template/en/default/global/code-error.html.tmpl

index d616bb2daca8f459cd85e6f41b10c75382a5ae7e..7f39b81f6c4cc5bbbd200ea3aff66e9048ea7a79 100644 (file)
@@ -157,6 +157,7 @@ sub match {
 
     my (@terms, @values);
     foreach my $field (keys %$criteria) {
+        $class->_check_field($field, 'match');
         my $value = $criteria->{$field};
         if (ref $value eq 'ARRAY') {
             # IN () is invalid SQL, and if we have an empty list
@@ -300,6 +301,17 @@ sub create {
     return $object;
 }
 
+# Used to validate that a field name is in fact a valid column in the
+# current table before inserting it into SQL.
+sub _check_field {
+    my ($invocant, $field, $function) = @_;
+    my $class = ref($invocant) || $invocant;
+    if (!Bugzilla->dbh->bz_column_info($class->DB_TABLE, $field)) {
+        ThrowCodeError('param_invalid', { param    => $field,
+                                          function => "${class}::$function" });
+    }
+}
+
 sub check_required_create_fields {
     my ($class, $params) = @_;
 
@@ -342,6 +354,7 @@ sub insert_create_data {
 
     my (@field_names, @values);
     while (my ($field, $value) = each %$field_values) {
+        $class->_check_field($field, 'create');
         push(@field_names, $field);
         push(@values, $value);
     }
old mode 100755 (executable)
new mode 100644 (file)
index 98597a9..078d76e
@@ -52,6 +52,8 @@ use constant WS_ERROR_CODE => {
     object_name_not_specified   => 50,
     param_required              => 50,
     object_does_not_exist       => 51,
+    # Error 52 exists only in later releases.
+    param_invalid               => 53,
     # Bug errors usually occupy the 100-200 range.
     improper_bug_id_field_value => 100,
     bug_id_does_not_exist       => 101,
index bb07068ecb5aacbc0e986e1b09c04ff8b808f3ec..ed5ddc0c90847cb827b8992e5f6445f29ba236ee 100644 (file)
     There is no valid transition from
     [%+ get_status("UNCONFIRMED") FILTER html %] to an open state.
 
+  [% ELSIF error == "param_invalid" %]
+    [% title = "Invalid Parameter" %]
+    <code>[% param FILTER html %]</code> is not a valid parameter
+    for the [% function FILTER html %] function.
+
   [% ELSIF error == "param_must_be_numeric" %]
     [% title = "Invalid Parameter" %]
     Invalid parameter passed to [% function FILTER html %].