{"id":1378,"date":"2014-09-27T17:50:56","date_gmt":"2014-09-27T22:50:56","guid":{"rendered":"http:\/\/blografia.net\/vicm3\/?p=1378"},"modified":"2014-10-25T16:09:55","modified_gmt":"2014-10-25T21:09:55","slug":"wordpress-xmlrpc-ddos-mitigation","status":"publish","type":"post","link":"https:\/\/blografia.net\/vicm3\/2014\/09\/wordpress-xmlrpc-ddos-mitigation\/","title":{"rendered":"WordPress xmlrpc DDOS mitigation"},"content":{"rendered":"<p>Well not long ago DH contacted me with this dreaded message:<\/p>\n<blockquote><p>Hello,<\/p>\n<p>I&#8217;m writing you about your domain:<\/p>\n<p>foo.bar<\/p>\n<p>Specifically the file:<\/p>\n<p>xmlrpc.php<\/p>\n<p>This file is used for modifying your wordpress install from 3rd party\u00a0programs, like mobile site designers, desktop client programs, and pretty\u00a0much anything besides the wordpress control panel under wp-admin.\u00a0 Bots\u00a0and hackers have been increasingly attacking these files listed above to\u00a0try to either brute force into the wordpress installs, or cause other\u00a0downtime and server issues.\u00a0 Our security team is working on blocks and\u00a0protections to prevent these, but in the meantime this is causing server\u00a0issues and downtime for your site, so our oncall admin has had to disable\u00a0the file by changing permissions to 200 so it isn&#8217;t accessible.\u00a0 If you\u00a0don&#8217;t use external programs to modify this blog, you likely won&#8217;t even\u00a0notice any chance in behavior and it can remain.\u00a0 If you do make use of\u00a0this file, when you next need to use it it can be re-enabled by chmod.\u00a0If you have further questions please let us know.<\/p><\/blockquote>\n<p>This was on august 3\u2026 I suppose we where part of a severe DDOS that were targeting third party sites\u2026 BTW this was fixed with mod_rewrite hack on .htaccess [1].<\/p>\n<p>Two weeks ago we got report for another site I run, this time on a bigger VPS, that we where participating on an ongoing DDOS [2] that we also caught as our machine resources were drawn terribly.<\/p>\n<p>Yesterday we got visits again, of course we were aware of the problem and originally chmoded 000 the file, dropped via iptables 3 subnets that where hammering it and all was good, but as you can read on several places disabling this file breaks several functions of WordPress [3].<\/p>\n<p>So as we use nginx as front end, begin to investigate if like on apache or lighty could exist something like mod_evasive and indeed exists [2] it\u2019s called \u00a0mod_http_limit_req_module so after reading the documentation, I searched for examples and find a very good one that inspired this setup [4] so we ended with the next changes on nginx.conf:<\/p>\n<p><code># Prevent DDOS<br \/>\nlimit_req_zone $binary_remote_addr zone=one:10m rate=1r\/m;<\/code><\/p>\n<p>So we are limiting request to 1 request for minute, but as you could imagine we don\u2019t want this for all the site, so next on the site conf we added<\/p>\n<p><code>location = \/xmlrpc.php<br \/>\n{<br \/>\nlimit_req zone=one burst=5;<br \/>\n}<\/code><\/p>\n<p>So we had 1 connection for minute on this file and a burst of five, but as this guys where hammering at more than one connection per second, well I suspect going to get a lot of 503 messages, I only expect that normal sites and ourselves not need this file more than one time for minute\u2026 on the bright side CPU, IO, and other resources are normal now, BTW some better advice if you don&#8217;t manage a server but had only access to .htaccess can be found here [1]<\/p>\n<p>Update: 26\/10\/2014 We ended having to tweak the limiting as WordPress itself uses to connect to the file so we ended limiting ourselves the fix was to change on the first one to limit to \u00a0six request per second instead of minute:<\/p>\n<p><code># Prevent DDOS<br \/>\nlimit_req_zone $binary_remote_addr zone=one:10m rate=6r\/s;<\/code><\/p>\n<p>And on site config to change for:<\/p>\n<p><code>location = \/xmlrpc.php<br \/>\n{<br \/>\nlimit_req zone=one burst=7 nodelay;<br \/>\n}<\/code><\/p>\n<p>As the docs says if you want no delay you had to add and also thinking that most modern browsers make up to 16 simultaneous connections [6] we upped the number but we don&#8217;t expect to have 16 request per second to this file.<\/p>\n<p>[1]https:\/\/wordpress.org\/support\/topic\/resolving-xmlrpcphp-ddos-attack-with-htaccess-redirect<br \/>\n[2]\u00a0<a href=\"http:\/\/blog.sucuri.net\/2014\/03\/more-than-162000-wordpress-sites-used-for-distributed-denial-of-service-attack.html\">http:\/\/blog.sucuri.net\/2014\/03\/more-than-162000-wordpress-sites-used-for-distributed-denial-of-service-attack.html<br \/>\n<\/a><span style=\"font-size: 16px;\">[3]\u00a0<\/span><a style=\"font-size: 16px;\" href=\"https:\/\/wordpress.org\/support\/topic\/xmlrpcphp-attack-on-wordpress-38\">https:\/\/wordpress.org\/support\/topic\/xmlrpcphp-attack-on-wordpress-38<br \/>\n<\/a><span style=\"font-size: 16px;\">[4]\u00a0<\/span><a style=\"font-size: 16px;\" href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_limit_req_module.html\">http:\/\/nginx.org\/en\/docs\/http\/ngx_http_limit_req_module.html<br \/>\n<\/a>[5]\u00a0<a href=\"https:\/\/cowthink.org\/flood-dos-protection-with-limit-req-in-nginx\/\">https:\/\/cowthink.org\/flood-dos-protection-with-limit-req-in-nginx\/<br \/>\n<\/a><a style=\"font-size: 16px;\" href=\"https:\/\/wordpress.org\/support\/topic\/resolving-xmlrpcphp-ddos-attack-with-htaccess-redirect\">[<\/a><span style=\"font-size: 16px;\">6]\u00a0<\/span><a style=\"font-size: 16px;\" href=\"http:\/\/kb.mozillazine.org\/Network.http.max-connections-per-server\">http:\/\/kb.mozillazine.org\/Network.http.max-connections-per-server<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well not long ago DH contacted me with this dreaded message: Hello, I&#8217;m writing you about your domain: foo.bar Specifically the file: xmlrpc.php This file is used for modifying your wordpress install from 3rd party\u00a0programs, like mobile site designers, desktop &hellip; <a href=\"https:\/\/blografia.net\/vicm3\/2014\/09\/wordpress-xmlrpc-ddos-mitigation\/\">Sigue leyendo <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10,8,7],"tags":[418,416,287,415,61,417],"class_list":["post-1378","post","type-post","status-publish","format-standard","hentry","category-planetalinux","category-sysadmin","category-web","tag-bot","tag-ddos","tag-exploit","tag-ngnix","tag-wordpress","tag-xmlrcp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":57,"url":"https:\/\/blografia.net\/vicm3\/2005\/02\/on_php_flags\/","url_meta":{"origin":1378,"position":0},"title":"On php flags","author":"vicm3","date":"15 febrero, 2005","format":false,"excerpt":"Well as this post was originally on english and i have two powerful reasons to no translate is lefted as in the original... apologies to the spanish readers: Posted: Mon Feb 14, 2005 1:48 pm Before i have complained about had to use register_globals & magic_quotes... as for we host\u2026","rel":"","context":"En \u00abGeneral\u00bb","block_context":{"text":"General","link":"https:\/\/blografia.net\/vicm3\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1407,"url":"https:\/\/blografia.net\/vicm3\/2014\/12\/two-things-are-infinite-the-universe-and-human-stupidity\/","url_meta":{"origin":1378,"position":1},"title":"Two things are infinite: the universe and human stupidity","author":"vicm3","date":"10 diciembre, 2014","format":false,"excerpt":"I think that reality is better than fiction, so take this as a fiction story... well short of... The full quote that gives nave to this post it's \"Two things are infinite: the universe and human stupidity; and I'm not sure about the universe.\" Albert Einstein. Monday lost five hours\u2026","rel":"","context":"En \u00abDebraye\u00bb","block_context":{"text":"Debraye","link":"https:\/\/blografia.net\/vicm3\/category\/debraye\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":845,"url":"https:\/\/blografia.net\/vicm3\/2012\/02\/scratch-on-debian\/","url_meta":{"origin":1378,"position":2},"title":"Scratch on Debian","author":"vicm3","date":"7 febrero, 2012","format":false,"excerpt":"For some unknown reason, at least for me (license most likely) there is no Scratch package in Debian as long I remember the problem could be that the name and the mascot are trademarks (same problem that with Firefox \/ Iceweasel), any case there is a .deb package for Ubuntu,\u2026","rel":"","context":"En \u00abDebraye\u00bb","block_context":{"text":"Debraye","link":"https:\/\/blografia.net\/vicm3\/category\/debraye\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1068,"url":"https:\/\/blografia.net\/vicm3\/2013\/06\/legacy-code-everywhere\/","url_meta":{"origin":1378,"position":3},"title":"Legacy code everywhere","author":"vicm3","date":"19 junio, 2013","format":false,"excerpt":"From last weekend our blog lacobachab where not updating their feed, as I removed and updated wp-cache info, most probably I removed redundant entries on .htaccess, BUT looks like removed the correct ones and left the wrong ones, tip if you don't know if your .htaccess mod_rewrite rules are OK,\u2026","rel":"","context":"En \u00abDebraye\u00bb","block_context":{"text":"Debraye","link":"https:\/\/blografia.net\/vicm3\/category\/debraye\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":77,"url":"https:\/\/blografia.net\/vicm3\/2005\/04\/variaciones_de_voltaje\/","url_meta":{"origin":1378,"position":4},"title":"Variaciones de voltaje","author":"vicm3","date":"2 abril, 2005","format":false,"excerpt":"Leyendo a Gunnar y el como murio la alimentacion de su maquinita en casa, transcribo algo sobre mi experiencia con variaciones de voltaje en esta zona de la ciudad... que me recordaron algunas cosas interesantes... desafortunadamente el comentario original esta en ingles, ya que me tome un rato para practicarlo\u2026","rel":"","context":"En \u00abGeneral\u00bb","block_context":{"text":"General","link":"https:\/\/blografia.net\/vicm3\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":976,"url":"https:\/\/blografia.net\/vicm3\/2012\/11\/easy-way-to-enconde-video-for-set-top-box\/","url_meta":{"origin":1378,"position":5},"title":"Easy way to enconde video for set top box","author":"vicm3","date":"5 noviembre, 2012","format":false,"excerpt":"If you had one of these every day more affordable and really cheap mitzui and others DVD players that also reproduce vidx and xvid video and read USB sticks\/Memory Cards, but not MP4 with AC3. Sure you want to be able to reproduce without have to burn a CD with\u2026","rel":"","context":"En \u00abDebraye\u00bb","block_context":{"text":"Debraye","link":"https:\/\/blografia.net\/vicm3\/category\/debraye\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/posts\/1378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/comments?post=1378"}],"version-history":[{"count":0,"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/posts\/1378\/revisions"}],"wp:attachment":[{"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/media?parent=1378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/categories?post=1378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blografia.net\/vicm3\/wp-json\/wp\/v2\/tags?post=1378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}