{"id":157343,"date":"2016-07-18T14:00:00","date_gmt":"2016-07-18T14:00:00","guid":{"rendered":"https:\/\/premium.wpmudev.org\/blog\/?p=157343"},"modified":"2017-10-19T02:09:56","modified_gmt":"2017-10-19T02:09:56","slug":"xml-rpc-wordpress","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/xml-rpc-wordpress\/","title":{"rendered":"XML-RPC and Why It\u2019s Time to Remove it for WordPress Security"},"content":{"rendered":"<p>From the very beginnings of WordPress, there have been features that allow you to interact remotely with your site. These same features build your community by allowing other bloggers to reference your posts. At the core of all of this is XML-RPC.<\/p>\n<p>XML-RPC, or XML Remote Procedure Call,\u00a0powers these features in WordPress:<\/p>\n<ul>\n<li>Connecting to your site(s) with your smartphone<\/li>\n<li>Trackbacks and pingbacks when other sites refer to your site<\/li>\n<li>Jetpack<\/li>\n<\/ul>\n<p>But there\u2019s a problem with XML-RPC that you need to resolve to secure your WordPress site.<\/p>\n<h3>What Is XML-RPC and What Is It Used For?<\/h3>\n<p>Back in the early days of blogging (long before WordPress existed), most writers on the Internet were still using dial-up connections to surf the web. It was hard to write posts and get them up. The solution was to write on your computer offline and copy\/paste your prose, and perhaps a graphic or two to your blog. Folks who were using a word processor found this method somewhat troublesome, as their text often had extraneous codes attached, even if you saved a document as HTML.<\/p>\n<p>Blogger created an application programming interface (API) to allow other developers to access Blogger blogs. Enter the offline blog client, which allowed users to type posts offline and then connect to Blogger API-enabled blogs through XML-RPC. Other blogging systems followed suit, and there was eventually a MetaWeblogAPI that standardized basic access.<\/p>\n<p>Jumping forward a decade or so, today we all use apps on our phones and tablets instead of our computers. One of the things that people like to do with their phones is post to their WordPress sites. In 2008-09, Automattic obliged by creating WordPress apps for pretty much every mobile operating system (even Blackberry and Windows Mobile).<\/p>\n<p>These apps allowed you, through the XML-RPC interface, to use your WordPress.com credentials to log in to any WordPress site you had user rights to.<\/p>\n<p>This happens by way of the Remote Procedure Calls \u2013 that is what RPC stands for.<\/p>\n<p>And now you should be thinking \u201cOh, no. What happens if someone else gets my password?\u201d The answer isn&#8217;t pretty: that \u201csomeone else\u201d can do everything you can do on your site. Because, of course, they are effectively you. Getting a queasy feeling yet?<\/p>\n<p>More bad news: If you use Jetpack to use its wonderful tools on your self-hosted site, several of those wonders use XML-RPC too.<\/p>\n<h3>History: Should XML-RPC Stay or Go in WordPress?<\/h3>\n<p>XML-RPC support has been part of WordPress from the first day. If you want to be fussy about it, it\u2019s part of the pre-history of WordPress; being part of the b2 platform that Matt Mullenweg forked to create WordPress.<\/p>\n<p>WordPress 2.6 was released on July 15, 2008. Enable XML-RPC was added to the WordPress Remote Publishing settings, with the default setting set to &#8220;Off.&#8221;<\/p>\n<p>A week later, the WordPress for iPhone app was released, and its users were asked to flip the setting to &#8220;On.&#8221;<\/p>\n<p>Four years after the iPhone app joined the family, WordPress 3.5 made XML-RPC support enabled by default\u00a0and took away the dashboard setting.<\/p>\n<p>And so it has stayed.<\/p>\n<p>The main weaknesses associated with XML-RPC are:<\/p>\n<ul>\n<li><strong>Brute force attacks:<\/strong> Attackers try to login to WordPress using xmlrpc.php with as many username\/password combinations as they can enter. A method within xmlrpc.php allows the attacker to use a single command (system.multicall) to guess hundreds of passwords. <a href=\"https:\/\/blog.sucuri.net\/2015\/10\/brute-force-amplification-attacks-against-wordpress-xmlrpc.html\" target=\"_blank\">Daniel Cid at Sucuri described it well in October 2015<\/a>: \u201cWith only 3 or 4 HTTP requests, the attackers could try thousands of passwords, bypassing security tools that are designed to look and block brute force attempts.\u201d<\/li>\n<li><strong>Denial of Service Attacks via Pingback:<\/strong> Back in 2013, attackers sent Pingback requests through xmlrpc.php of approximately 2500 WordPress sites to \u201cherd (these sites) into a voluntary botnet,\u201d <a href=\"https:\/\/www.imperva.com\/blog\/archive\/wordpress-security-alert-pingback-ddos\/?redirect=Incapsula\" rel=\"noopener\" target=\"_blank\">according to Incapsula&#8217;s Gur Schatz<\/a>, \u201cThis gives any attacker a virtually limitless set of IP addresses to Distribute a Denial of Service attack across a network of over 100 million WordPress sites, without having to compromise them.\u201d<\/li>\n<\/ul>\n<h3>Convenience vs WordPress Security, Yet Again<\/h3>\n<p>So here we go again. The modern world is deeply annoying with its trade-offs.<\/p>\n<p>If you want to make sure no one is bringing a bomb on your airplane, you have to stand in line to go through the metal detectors. If you want to keep your car while you\u2019re shopping, lock the doors and close the windows. You can\u2019t use p@ssw0rd to lock your website, either. Especially if you like using Jetpack or the mobile apps.<\/p>\n\n<h3>What Can I Do About XML-RPC Security?<\/h3>\n<p>Understand that the security issue isn\u2019t really XML-RPC itself, the problem is that attackers can use this as another way to brute-force its way through to your username and password. So the best way to protect yourself is (still) to use long, complicated passwords (or use a password manager that can create them for you). But that isn\u2019t always easy to do, particularly if you engage with WordPress through several different computers.<\/p>\n<p>The next best thing you can do to protect yourself today is to turn off XML-RPC in your Settings altogether. Some additions to your .htaccess file can lock down access to the xmlrpc.php file. Here\u2019s how to do that.<\/p>\n<p><em>Note: Check with your web host for their policy on users creating and editing .htaccess before making changes.<\/em><\/p>\n<ul>\n<li>Check for an existing .htaccess file. Your web host documentation may point you in the right direction. If none exists, create the file in the htdocs\/wordpress folder.<\/li>\n<li>Open the file in a text editor and add the following code near the top:<\/li>\n<\/ul>\n<div class=\"gist\" data-gist=\"947a5b5ef39c3ab9619158999cb72d01\" data-gist-file=\"disable-xml-rpc\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/947a5b5ef39c3ab9619158999cb72d01.js?file=disable-xml-rpc\">Loading gist 947a5b5ef39c3ab9619158999cb72d01<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>You can simplify this process by installing and activating the <a href=\"https:\/\/wordpress.org\/plugins\/disable-xml-rpc\/\" target=\"_blank\">Disable XML-RPC<\/a> plugin.<\/p>\n<p>Disabling xmlrpc.php shuts down every tool that uses this file. You can still use WordPress on your phone or tablet. Instead of the mobile apps, you can<\/p>\n<h3>Partially Disabling XML-RPC in WordPress<\/h3>\n<p>So you have become dependent on all these tools that are, in turn, dependent on XML-RPC. I really get that you don\u2019t want to turn XML-RPC off, even for a little while.<\/p>\n<p>Here are some plugins that can help:<\/p>\n<ul>\n<li><strong>Stop XML-RPC Attack:<\/strong> Only allows Jetpack and other Automattic tools to access xmlrpc.php through .htaccess.<\/li>\n<li>Control XML-RPC Publishing: Simply restores the old Remote Publishing option to the<strong> Settings &gt; Writing<\/strong> menu.<\/li>\n<li><strong>iThemes Security, Anti-Malware Security and Brute-Force Firewall and All in One WP Security &amp; Firewall:<\/strong> These general-purpose security tools include brute-force protection in their free tier. They watch for repeated attempts to log in, with or without xmlrpc.php and ban sites that appear to be trying to break in. I\u2019ve successfully used the iThemes tool for several years now.<\/li>\n<\/ul>\n<p>I\u2019ll note that one major security plugin, Wordfence, decided against disabling XML-RPC. In a blog post, mark wrote:<\/p>\n<p>To us, disabling XML-RPC comes with a cost. You are disabling a major API in WordPress. We briefly provided this capability, but removed the feature because WordPress\u2019s own API abuse prevention has improved. Furthermore, providing the ability to disable XML-RPC caused confusion among users when their applications broke because they could not access the API.<\/p>\n<h3>REST (and OAuth) to the Rescue<\/h3>\n<p>Now you may already know that the WordPress core developers are turning WordPress\u2019s code into a REST application. The developers on the REST API team have had some issues getting ready, including with the authentication piece intended to resolve the XML-RPC problem. When this finally happens (currently planned for v4.7 at the end of 2016), you won\u2019t have to use XML-RPC to use the mobile apps or Jetpack.<\/p>\n<p>Instead, you\u2019ll authenticate yourself in external apps through the OAuth protocol. You may not know what OAuth is, but if you\u2019ve ever clicked a Twitter button on a post, you\u2019ve used OAuth.<\/p>\n<p>When you click the social sharing button, a secure HTTPS screen comes up and asks you to identify yourself to Twitter, Facebook, LinkedIn or whomever. You enter your username and password for that site, and you can share that post. The owner of the WordPress site doesn\u2019t know your social site\u2019s password, and no one can intercept that data while it\u2019s being sent.<\/p>\n<p>The social app then places a cookie in a browser with a key and secret that allows the remote site to connect for a designated period of time. Then you don\u2019t have to enter your credentials for the life of that cookie.<\/p>\n<p>Here\u2019s why OAuth is better, safer and more wonderful than XML-RPC: Fundamentally, you don\u2019t have to share your password in plain text over the Internet for your mobile app to connect to your site.<\/p>\n<p>The REST API team are working on an \u201c&#8221;Authentication Broker\u201d that will allow connections to any of the multitudes of WordPress sites.<\/p>\n<h3>Testing the WordPress REST API<\/h3>\n<p>As I said earlier, the REST API is not yet integrated into WordPress core, and won\u2019t be for months. Today, you can begin playing with it on your non-production sites. To do this:<\/p>\n<ol>\n<li>Get some background on <a href=\"https:\/\/wpmudev.com\/blog\/wordpress-rest-api\/\" target=\"_blank\">The REST API (and How It Could Change WordPress Forever)<\/a> from Tom Ewer.<\/li>\n<li>Read carefully Daniel Pataki\u2019s article, <a href=\"https:\/\/wpmudev.com\/blog\/using-wordpress-rest-api\/\" target=\"_blank\">How to Use the WordPress API (and the Companies Already Using it Successfully)<\/a>.<\/li>\n<li>Read <a href=\"https:\/\/make.wordpress.org\/core\/2016\/05\/16\/rest-api-authentication-broker\/\" target=\"_blank\">Joe Hoyle\u2019s post introducing the Authentication Broker<\/a>.<\/li>\n<li>Download and install the latest <a href=\"https:\/\/wordpress.org\/plugins\/json-rest-api\/\" target=\"_blank\">REST API plugin<\/a> from WordPress.org<\/li>\n<li>Spend some time with the <a href=\"http:\/\/wp-api.org\/\" target=\"_blank\">REST API documentation<\/a> to learn how it works.<\/li>\n<li>Install the <a href=\"https:\/\/github.com\/WP-API\/OAuth1\" target=\"_blank\">OAuth v1 plugin<\/a> from GitHub.<\/li>\n<li>Install the <a href=\"https:\/\/github.com\/WP-API\/broker-client\" target=\"_blank\">authentication broker plugin<\/a> from GitHub<\/li>\n<li>Create an app with the default broker.<\/li>\n<\/ol>\n<p>In the meantime, you have to make your own decisions about the convenience\/security tradeoff continuum.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>From the very beginnings of WordPress, there have been features that allow you to interact remotely with your site. These same features build your community by allowing other bloggers to reference your posts. At the core of all of this is XML-RPC. XML-RPC, or XML Remote Procedure Call,\u00a0powers these features in WordPress: Connecting to your [&hellip;]<\/p>\n","protected":false},"author":133030,"featured_media":157417,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263],"tags":[10810],"tutorials_categories":[],"class_list":["post-157343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-wordpress-security"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/157343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/133030"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=157343"}],"version-history":[{"count":12,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/157343\/revisions"}],"predecessor-version":[{"id":193825,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/157343\/revisions\/193825"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/157417"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=157343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=157343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=157343"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=157343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}