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

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

index 2c95f1eec28e8dc4249ffe89ceadce51a3269c07..c1230e3aed25cfe06a9fd9be17ecc903c5adf13a 100644 (file)
@@ -24,6 +24,7 @@ our @EXPORT = qw(
     WS_ERROR_CODE
     ERROR_UNKNOWN_FATAL
     ERROR_UNKNOWN_TRANSIENT
+    XMLRPC_CONTENT_TYPE_WHITELIST
 
     CONTENT_TYPE_BLACKLIST
 
@@ -161,6 +162,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.
@@ -177,6 +180,11 @@ use constant CONTENT_TYPE_BLACKLIST => qw(
     multipart/form-data
 );
 
+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 b74d0eebdb35b994a225a2ae22f4a7fc25e9905a..94d44fd019e07eb6d7362059d563946f6da8cd54 100644 (file)
@@ -72,10 +72,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 5634a7af3e9e640d7c4c911d5455922d10f4d198..9e11e36a691b899848c681de5b028a5a64c91e9c 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