]> 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:48:50 +0000 (10:48 -0500)
committerDave Lawrence <dlawrence@mozilla.com>
Wed, 22 Feb 2012 15:48:50 +0000 (10:48 -0500)
r/a=LpSolit

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

index c2eaa0cb23c6e5819eff9fb3c4ac8f42ac9b2674..491970291c0f1998c944469ca66a45ac72774de9 100644 (file)
@@ -14,6 +14,7 @@ our @EXPORT = qw(
     WS_ERROR_CODE
     ERROR_UNKNOWN_FATAL
     ERROR_UNKNOWN_TRANSIENT
+    XMLRPC_CONTENT_TYPE_WHITELIST
 
     WS_DISPATCH
 );
@@ -162,6 +163,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.
@@ -170,6 +173,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 67e7b755572ab24b76211563001bba170706cda8..33a1e92d3704d668243212e3af64c90eb7fbcd3a 100644 (file)
@@ -73,10 +73,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 7408a1a05e51afe27b786d062397b7e652d2aff9..fdcdc66269a7a129051bbd017e64b66376712ee4 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 %]. Allowed content types 
+    are [% constants.XMLRPC_CONTENT_TYPE_WHITELIST.join(', ') %].
+
   [% 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