A Case for REST API

The following posts are coming up!

Recent Posts

WordPress 4.7.1 and 4.7 were vulnerable via the REST API. Any unauthenticated user could modify the content of any post or page on a site. Since the release of the information, a surprisingly large number of users failed to update to 4.7.2 and, thus, were hacked.

I say surprisingly because WordPress enabled automatic updates quite a while ago (WordPress 3.7), which will automatically secure your WordPress install. There have been 18 automated releases since then (which is why we have 3.7.18) and the vast majority have addressed security in one way, shape, or form.

But this post isn’t about the reasons why someone might need to disable the automatic updates. No, this is about the argument I saw stem from the vulnerability, whereby people said it was proof the REST API should be disabled by default.

And to them I say “No.”

The REST API Probably Has More Vulnerabilities

Look, I’m not going to lie to you. The odds are high that the REST API, which is a very new feature, probably has some serious issues still. But, as my friend Helen pointed out to those arguing for it to be disabled by default.

Why should this be treated differently from XML-RPC? Have you gone through the history of the XML-RPC setting?

While the REST API may introduce new vulnerabilities to WordPress, and even ones that are horrifyingly accessible to non-logged in users, it is not the first nor the last feature WordPress has added that puts a site at risk. The API, being brand new and not used or tested as much as other aspects of WordPress, is going to be dangerous to exist, but realistically not more or less than any other part of WordPress.

Go through the list of all WordPress security releases. A lot of issues have been fixed. This is just the first one for the REST API.

In 2008, XML-RPX in pre-2.3.3 systems allowed remote attackers to edit posts of other blog users, if registration was enabled. That’s a long time ago, and since then the majority of the exploits have revolved around DDoS and pingbacks. But yes, back in the day, this new feature was also problematic.

Do You Trust WordPress?

Everyone makes mistakes. Every code has bugs. Everything is vulnerable. The question you have to ask is not “Why did WordPress let this happen?” nor “Why did they put me in danger?” but “Did they handle this well?”

The heart of the matter is not if you trust WordPress not to screw up, but that you trust them to react responsibly, quickly, and with the appropriate concern. Some security issues are massive. Others are not. With over 26% of the internet using WordPress, fixing the security issues quickly and properly is a huge concern.

So you have to ask “Do I trust WordPress to fix security issues?” And “Do I trust WordPress has my best interests, with regards to security, at heart?”

I do, but it’s a question of risk.

Risk = {si, λi, xi}

My father, a risk analyst, asks three important questions:

  • What can go wrong?
  • How likely is it?
  • What are the consequences?

Obviously a lot can go wrong. So much, in fact, that it can be impossible to wrap your head around the vastness of the possibilities and subsequent probabilities. Even just listing the things you think might go wrong is incomplete. You know you’re not thinking of everything, so you have to start with the big picture.

Most of us aren’t capable of calculating the risk and reliability of WordPress. Those Six Sigma experts aren’t either. There’s no way I could actually explain well enough how to determine the risk of using WordPress. If I could, I’d start with asking people “What can go wrong if I disable automatic updates?” and “What can go wrong if I don’t disable automatic updates?”

The likelihood of the REST API being vulnerable is a little higher than other aspects of WordPress core, but much lower than plugins and themes. The consequences are generally higher than that of plugins and themes, but there’s an extra factor you must consider.

  • How quickly can it be fixed?

If you leave WordPress auto-updates on, then the answer is “As quickly as humanly possible.” And that, I feel, lowers the overall risk.

Planned Disclosure

To those arguing WordPress should have told everyone sooner, this is not the first time WordPress waited a while before announcing a security issue. Take, for example, The Case of the Trojan Emoji. That’s not a Sherlock Holmes mystery, that’s the true case of where WordPress hid a major security fix inside the additions of emoji support.

There’s a big difference between the Trojan Emoji in 4.2 and the RESTless Backdoor we faced in 4.7, and that is the exploitability. The vulnerability fixed with emojis was hard to do. The one in the API was super easy. In both cases, however, the moment the vulnerability is disclosed, a ticking clock begins to see when people get hacked.

Sometimes folks tell me I’m hyperbolic or exaggerating when I say ‘attacks will begin within minutes.’ I think that my claim was proven valid, considering how many sites were hacked, and how quickly it happened. Within days of the announcement,

Remember, security is nuanced. It’s never as simple as “Hey, I found a vulnerability! Patch it!” It requires testing, validation, more testing, and more testing. A good patch doesn’t introduce worse problems (yes, that’s happened before).

Rarely Used Code Is More Vulnerable

I bring this guy up every time people argue why WordPress turns on features by default. The WordPress argument is that if they don’t turn it on, people won’t use it. The reason that matters can be found in the works of Herbert Hecht.

Hecht wrote papers about rare conditions and their effect on software failures. The tl;dr summary for you is this: Rarely used code fails more often.

Now, Hecht specially was referring to the early days of software use, which the REST API certainly falls under, but the basic philosophy is valid. The less the code is use, the more at risk it is, specifically because it’s used so rarely. People are less familiar with it, they don’t know how to fix it or even test it for all the possibilities, because they don’t yet know what they are.

Are those reasons to not use the REST API? Not always. You have to consider the risk of using it for yourself. Will your site go down? How bad is that if it happens? Are you doing everything you could to protect yourself?

Should You Disable The REST API?

No. Unless you’re certain you’ll never use it, ever, leave it on. It will be fixed, and as long as you apply security patches promptly, you’ll be fine.






3 responses to “A Case for REST API”

  1. Florian Avatar

    Millions of people have content accessable that they hide or simply don’t see online anddon’t want online. Because those people have no idea REST exists.

    They are annoyed. WPis not for developers only.

    1. Ipstenu (Mika Epstein) Avatar

      @Florian: Your argument is misinformed. They don’t have data more or less accessible than they did before. The REST API didn’t reveal more than WordPress already does via the website itself, RSS, and XMPRPC. The only difference is the way the data is represented.

  2. Patrick Sletvold Avatar

    I totally agree, especially on that last point about not deactivating the API just because it has had a single serious issue. Ever since WPBeginner told its users in a newsletter that they should disable the REST API just to be sure, I have thought that the non-developer community of WordPress users have been badly informed…

    What’s great about the XML-RPC is the ability to use apps, like the WordPress mobile app for non-Jetpack sites, with your WordPress installation, without requiring any setup on the admin side. The REST API is kind of the modern replacement of this, a universal form of communicating with WordPress sites, and for that reason it should stay activated. How else could the developer of an app or service expect to reliably talk to WordPress sites?

    Part of the problem is that regular users believe REST APIs are “developer stuff”, not something they will benefit from too. As you point out in your post “REST API – Democratizing Reading”, the REST API is a tool used by developers for the users, not a tool designed for developers to use for themselves.

    When everyone understands this, I believe we have solved much of the problem.

%d bloggers like this: