]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1230932: Providing a condition as an ID to the webservice results in a taint...
authorFrédéric Buclin <LpSolit@gmail.com>
Sat, 19 Mar 2016 16:33:48 +0000 (17:33 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Sat, 19 Mar 2016 16:33:48 +0000 (17:33 +0100)
r/a=dkl

Bugzilla/WebService/Bug.pm
Bugzilla/WebService/Constants.pm
Bugzilla/WebService/Util.pm
template/en/default/global/code-error.html.tmpl

index c9965120103b2313d98fb904178225e0554937ef..b07d3cb01c552702643038da8a12fbc5e70d8de0 100644 (file)
@@ -1133,6 +1133,10 @@ sub update_comment_tags {
                           { function => 'Bug.update_comment_tags',
                             param    => 'comment_id' });
 
+    ThrowCodeError('param_integer_required', { function => 'Bug.update_comment_tags',
+                                               param => 'comment_id' })
+      unless $comment_id =~ /^[0-9]+$/;
+
     my $comment = Bugzilla::Comment->new($comment_id)
         || return [];
     $comment->bug->check_is_visible();
index 0bdd3517e4ba6db2a1155759cec9f0e52c10770f..557a996f87bb3d5d51272f22ee5ce39ef620e9b1 100644 (file)
@@ -67,6 +67,8 @@ use constant WS_ERROR_CODE => {
     number_too_large            => 54,
     number_too_small            => 55,
     illegal_date                => 56,
+    param_integer_required      => 57,
+    param_scalar_array_required => 58,
     # Bug errors usually occupy the 100-200 range.
     improper_bug_id_field_value => 100,
     bug_id_does_not_exist       => 101,
index 26a6ebbb02a7b21d9c91cc84821513a117db7720..a879c0e0d979bb9b76a4104334ab5045b9a7db8f 100644 (file)
@@ -16,6 +16,7 @@ use Bugzilla::FlagType;
 use Bugzilla::Error;
 
 use Storable qw(dclone);
+use List::MoreUtils qw(any none);
 
 use parent qw(Exporter);
 
@@ -220,14 +221,19 @@ sub validate  {
     # $params should be.
     return ($self, undef) if (defined $params and !ref $params);
 
+    my @id_params = qw(ids comment_ids);
     # If @keys is not empty then we convert any named 
     # parameters that have scalar values to arrayrefs
     # that match.
     foreach my $key (@keys) {
         if (exists $params->{$key}) {
-            $params->{$key} = ref $params->{$key} 
-                              ? $params->{$key} 
-                              : [ $params->{$key} ];
+            $params->{$key} = [ $params->{$key} ] unless ref $params->{$key};
+
+            if (any { $key eq $_ } @id_params) {
+                my $ids = $params->{$key};
+                ThrowCodeError('param_scalar_array_required', { param => $key })
+                  unless ref($ids) eq 'ARRAY' && none { ref $_ } @$ids;
+            }
         }
     }
 
index 63f3ae9d90393f4f019846f630e6c3f6c19c864b..830a7e7f6ef6b26b89fabaedc76b855221f56efb 100644 (file)
     a <code>[% param FILTER html %]</code> argument, and that
     argument was not set.
 
+  [% ELSIF error == "param_integer_required" %]
+    The function <code>[% function FILTER html %]</code> requires
+    that <code>[% param FILTER html %]</code> be an integer.
+
+  [% ELSIF error == "param_scalar_array_required" %]
+    The <code>[% param FILTER html %]</code> parameter must be an array of scalars
+    (integers and/or strings).
+
   [% ELSIF error == "params_required" %]
     [% title = "Missing Parameter" %]
     The function <code>[% function FILTER html %]</code> requires