From: Frédéric Buclin Date: Wed, 4 Aug 2010 22:15:55 +0000 (+0200) Subject: Bug 583690: (CVE-2010-2759) [SECURITY][PostgreSQL] Bugzilla crashes when viewing... X-Git-Tag: bugzilla-3.4.8~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=02c0e879d5698e0e47b52dedb7473ec9730b2bdf;p=thirdparty%2Fbugzilla.git Bug 583690: (CVE-2010-2759) [SECURITY][PostgreSQL] Bugzilla crashes when viewing a bug if a comment contains 'bug ' or 'attachment ' where is greater than the max allowed integer r=mkanat a=LpSolit --- diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm index 1228d841d0..451a77e848 100644 --- a/Bugzilla/Constants.pm +++ b/Bugzilla/Constants.pm @@ -150,6 +150,7 @@ use File::Basename; MIN_SMALLINT MAX_SMALLINT + MAX_INT_32 MAX_LEN_QUERY_NAME MAX_CLASSIFICATION_SIZE @@ -433,6 +434,7 @@ use constant ON_WINDOWS => ($^O =~ /MSWin32/i); use constant MIN_SMALLINT => -32768; use constant MAX_SMALLINT => 32767; +use constant MAX_INT_32 => 2147483647; # The longest that a saved search name can be. use constant MAX_LEN_QUERY_NAME => 64; diff --git a/Bugzilla/Object.pm b/Bugzilla/Object.pm index 5a74996f13..d9f4dd126c 100644 --- a/Bugzilla/Object.pm +++ b/Bugzilla/Object.pm @@ -76,6 +76,9 @@ sub _init { || ThrowCodeError('param_must_be_numeric', {function => $class . '::_init'}); + # Too large integers make PostgreSQL crash. + return if $id > MAX_INT_32; + $object = $dbh->selectrow_hashref(qq{ SELECT $columns FROM $table WHERE $id_field = ?}, undef, $id); @@ -137,6 +140,8 @@ sub new_from_list { detaint_natural($id) || ThrowCodeError('param_must_be_numeric', {function => $class . '::new_from_list'}); + # Too large integers make PostgreSQL crash. + next if $id > MAX_INT_32; push(@detainted_ids, $id); } # We don't do $invocant->match because some classes have diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 16d60c8e14..bafdf806f5 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -255,8 +255,8 @@ sub get_attachment_link { my ($attachid, $link_text) = @_; my $dbh = Bugzilla->dbh; - detaint_natural($attachid) - || die "get_attachment_link() called with non-integer attachment number"; + (detaint_natural($attachid) && $attachid <= MAX_INT_32) + || return $link_text; my ($bugid, $isobsolete, $desc) = $dbh->selectrow_array('SELECT bug_id, isobsolete, description @@ -304,6 +304,7 @@ sub get_bug_link { } my $quote_bug_num = html_quote($bug_num); detaint_natural($bug_num) || return "<invalid bug number: $quote_bug_num>"; + ($bug_num <= MAX_INT_32) || return $link_text; my ($bug_alias, $bug_state, $bug_res, $bug_desc) = $dbh->selectrow_array('SELECT bugs.alias, bugs.bug_status, bugs.resolution, bugs.short_desc