]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
(CVE-2012-0440) [SECURITY] JSON-RPC permits to bypass token checks and can lead to...
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 31 Jan 2012 16:01:20 +0000 (17:01 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 31 Jan 2012 16:01:20 +0000 (17:01 +0100)
r=mkanat a=LpSolit

https://bugzilla.mozilla.org/show_bug.cgi?id=718319

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

index 3b232aafafaa946607559342414d4eac0de2efc0..cec1c29ea2d0cfd020822b282dc476d462bccd09 100644 (file)
@@ -365,7 +365,19 @@ sub _argument_type_check {
 
     Bugzilla->input_params($params);
 
-    if ($self->request->method ne 'POST') {
+    if ($self->request->method eq 'POST') {
+        # CSRF is possible via XMLHttpRequest when the Content-Type header
+        # is not application/json (for example: text/plain or
+        # application/x-www-form-urlencoded).
+        # application/json is the single official MIME type, per RFC 4627.
+        my $content_type = $self->cgi->content_type;
+        # The charset can be appended to the content type, so we use a regexp.
+        if ($content_type !~ m{^application/json(-rpc)?(;.*)?$}i) {
+            ThrowUserError('json_rpc_illegal_content_type',
+                            { content_type => $content_type });
+        }
+    }
+    else {
         # When being called using GET, we don't allow calling
         # methods that can change data. This protects us against cross-site
         # request forgeries.
index dc0a94ac7f72319a580f817a858909285ad6dcf0..9e99dae155c3e89bdf0bdb8b502bd58d6b9d9528 100644 (file)
     parameter. See the documentation at
     [%+ docs_urlbase FILTER html %]api/Bugzilla/WebService/Server/JSONRPC.html
 
+  [% ELSIF error == "json_rpc_illegal_content_type" %]
+    When using JSON-RPC over POST, you cannot send data as
+    [%+ content_type FILTER html %]. Only application/json and
+    application/json-rpc are allowed.
+
   [% ELSIF error == "json_rpc_invalid_params" %]
     Could not parse the 'params' argument as valid JSON.
     Error: [% err_msg FILTER html %]