diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/WebService/Constants.pm | 8 | ||||
-rw-r--r-- | Bugzilla/WebService/Server/XMLRPC.pm | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm index ab3111eed..59aab9b55 100644 --- a/Bugzilla/WebService/Constants.pm +++ b/Bugzilla/WebService/Constants.pm @@ -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; diff --git a/Bugzilla/WebService/Server/XMLRPC.pm b/Bugzilla/WebService/Server/XMLRPC.pm index 5c3677993..822709d85 100644 --- a/Bugzilla/WebService/Server/XMLRPC.pm +++ b/Bugzilla/WebService/Server/XMLRPC.pm @@ -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)) { |