]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 725663 - (CVE-2012-0453) [SECURITY] CSRF vulnerability in the XML-RPC API when...
authorDave Lawrence <dlawrence@mozilla.com>
Wed, 22 Feb 2012 15:38:20 +0000 (10:38 -0500)
committerDave Lawrence <dlawrence@mozilla.com>
Wed, 22 Feb 2012 15:38:20 +0000 (10:38 -0500)
r/a=LpSolit

Bugzilla/WebService/Constants.pm
Bugzilla/WebService/Server/XMLRPC.pm
template/en/default/global/user-error.html.tmpl

index ab3111eed98269388d60af4b41e7cbd88f0d2d21..59aab9b553d0c720d27d069e4b0554f768809c2f 100644 (file)
@@ -24,6 +24,7 @@ our @EXPORT = qw(
     WS_ERROR_CODE
     ERROR_UNKNOWN_FATAL
     ERROR_UNKNOWN_TRANSIENT
+    XMLRPC_CONTENT_TYPE_WHITELIST
 
     WS_DISPATCH
 );
@@ -172,6 +173,8 @@ use constant WS_ERROR_CODE => {
     unknown_method       => -32601,
     json_rpc_post_only   => 32610,
     json_rpc_invalid_callback => 32611,
+    xmlrpc_illegal_content_type   => 32612, 
+    json_rpc_illegal_content_type => 32613, 
 };
 
 # These are the fallback defaults for errors not in ERROR_CODE.
@@ -180,6 +183,11 @@ use constant ERROR_UNKNOWN_TRANSIENT => 32000;
 
 use constant ERROR_GENERAL       => 999;
 
+use constant XMLRPC_CONTENT_TYPE_WHITELIST => qw(
+    text/xml
+    application/xml
+);
+
 sub WS_DISPATCH {
     # We "require" here instead of "use" above to avoid a dependency loop.
     require Bugzilla::Hook;
index 5c367799333957f16ac3ef21b2bdb81e758ad3e8..822709d857d750182bddfe42d99548528e65fb51 100644 (file)
@@ -86,10 +86,18 @@ use XMLRPC::Lite;
 our @ISA = qw(XMLRPC::Deserializer);
 
 use Bugzilla::Error;
+use Bugzilla::WebService::Constants qw(XMLRPC_CONTENT_TYPE_WHITELIST);
 use Scalar::Util qw(tainted);
 
 sub deserialize {
     my $self = shift;
+
+    # Only allow certain content types to protect against CSRF attacks
+    if (!grep($_ eq $ENV{'CONTENT_TYPE'}, XMLRPC_CONTENT_TYPE_WHITELIST)) {
+        ThrowUserError('xmlrpc_illegal_content_type',
+                       { content_type => $ENV{'CONTENT_TYPE'} });
+    }
+
     my ($xml) = @_;
     my $som = $self->SUPER::deserialize(@_);
     if (tainted($xml)) {
index 9e99dae155c3e89bdf0bdb8b502bd58d6b9d9528..feff9f042e5643ff464d71fa2e971aa47857b79a 100644 (file)
     &lt;[% type FILTER html %]&gt; field. (See the XML-RPC specification
     for details.)
 
+  [% ELSIF error == "xmlrpc_illegal_content_type" %]
+    When using XML-RPC, you cannot send data as
+    [%+ content_type FILTER html %]. Only text/xml 
+    and application/xml are allowed.
+
   [% ELSIF error == "zero_length_file" %]
     [% title = "File Is Empty" %]
     The file you are trying to attach is empty, does not exist, or you don't