3. Why API Keys Are Not Enough
3. Why API Keys Are Not Enough
Who holds the key? APIs need robust identity control and access
management.
We’re all accustomed to using usernames and passwords for
hundreds of online accounts — but if not managed correctly,
using passwords can become a significant distraction and a
potential security vulnerability. The same is true in the API space.
There’s nothing inherently wrong with usernames — you need
those. But if you use them without also having credentials that
allow the service to verify the caller’s identity, you are certainly
doing it wrong.
Unfortunately, many API providers make a dangerous mistake
API Keys ≠ Security: Why API Keys Are Not Enough 23
1 IP84UTvzJKds1Jomx8gIbTXcEEJSUilGqpxCcmnx
Shifting of Responsibility
2, Amazon Auth, and more, require the use of SSL for this very
reason. Shifting the responsibility from the service provider to
the developer consumer is also a negligent decision from a UX
perspective.
Some people forgive the lack of security. After all, it’s on the
developer to make sure solutions like SSL are implemented.
However, even if you assure security, your issues don’t stop
there — API Keys by design lacks granular control.
Somewhat ironically, before API keys were used with RESTful
services, we had WS-Security tokens for SOAP services that let
us perform many things with more fine-grained control. While
other solutions can be scoped, audienced, controlled, and man-
aged down to the smallest of minutia, API Keys, more often than
not, only provide access until revoked. They can’t be dynami-
cally controlled.
That’s not to say API Keys lack any control — relatively useful
read/write/readwrite control is definitely possible in an API Key
application. However, the needs of the average API developer
often warrant more full-fledged options.
This is not a localized issue either. As more and more devices are
integrated into the Internet of Things, this control will become
more important than ever before, magnifying the choices made
in the early stages of development to gargantuan proportions
later on in the API Lifecycle.
API Keys ≠ Security: Why API Keys Are Not Enough 26
All of this comes down to a single fact: API Keys were never
meant to be used as a security feature. Most developers utilize
API Keys as a method of authentication or authorization, but the
API Key was only ever meant to serve as identification.
API Keys are best for two things: identification and analyt-
ics. While analytic tracking can make or break a system, other
solutions implement this feature in a more feature-rich way.
Likewise, while API Keys do a great job identifying a user, other
alternatives, such as public key encryption, HoK Tokens, etc. do
a much better job of it while providing more security.
There are definitely some valid reasons for using API Keys. First
and foremost, API Keys are simple. The use of a single identifier
is simple, and for some use cases, the best solution. For instance,
if an API is limited specifically in functionality where “read” is the
only possible command, an API Key can be an adequate solution.
Without the need to edit, modify, or delete, security is a lower
concern.
Secondly, API Keys can help reduce the entropy-related issues
within an authenticated service. Entropy — the amount of en-
ergy or potential within a system constantly expended during
its use — dictates that there are a limited amount of authenti-
cation pairs. Suppose entropy dictates that you can only have
6.5 million unique pairs when limited within a certain charac-
ter set and style. In that case, you can only have 6.5 million
devices, users, or accounts before you run into an issue with
naming. Conversely, establishing an API Key with a high number
API Keys ≠ Security: Why API Keys Are Not Enough 27
Back to Reality
The benefits of using API Keys outlined above are still tenuous in
the general use-case scenario. While API keys are simple, the lim-
itation of “read-only” is hampering rather than liberating. Even
though they provide higher levels of entropy, this solution is not
limited to API Keys and is inherent in other authentication/au-
thorization solutions. Likewise, autonomy can be put in place
through innovative server management and modern delegation
API Keys ≠ Security: Why API Keys Are Not Enough 28
systems.
The huge problems with API Keys come when end users, not
developers, start making API calls with these Keys, which more
often than not expose your API to security and management
risks. It comes down to that API Keys are, by nature, not a com-
plete solution. While they may be perfectly fine for read-only
purposes, they are too weak a solution to match the complexity
of a high-use API system. Whenever you start integrating other
functionality such as writing, modification, deletion, and more,
you necessarily enter the realm of Identification, Authentication,
and Authorization.
Basic API Key implementation doesn’t support authentication
without additional code or services. It doesn’t support authen-
tication without a matching third-party system or secondary
application. It doesn’t support authorization without some se-
rious “hacks” to extend use beyond what they were originally
intended for.
While an argument could be made for expanding out the API
Keys method to better support these solutions, that argument
would advocate re-inventing the wheel. There are already so
many improved solutions available that adding functionality to
an API Key system doesn’t make sense. Even if you did add some-
thing like authentication, especially federated authentication,
to the system using Shibboleth, OpenID, etc., there are a ton of
systems out there that already have support for this.