APIs are certified “cool” - they provide access to data and services otherwise locked behind corporate firewalls, they enable easy development of web and mobile products, and they allow organizations to do business in new ways. But this strategic opportunity opens up vulnerabilities, and APIs are becoming the primary attack vector for unscrupulous individuals, organizations - even governments!
Security then must be a leading concern - all API stakeholders (developers, architects, operations, and the business) must play a role in deploying a security model that both enables and protects. I’ve put together a list of guiding principles your API projects should follow.
- Don't Put Security Last: Security is often relegated to the last design consideration - deciding how to deal with authentication and access control. But a robust security model must also consider your overall application architecture and find all layers where threats and vulnerabilities may exist. It’s also important to think about reusability in your security architecture, making it easy for developers to leverage standardized mechanisms at each application tier.
- Leverage Existing Standards: As I mentioned in #1, basic access control is actually pretty simple. Users and clients request access to objects like data, applications, and services - your access controls then make a decision to grant or deny that request. Today, user management is a mature space and most organizations have a central user directory. Object management must reach this same maturity, enabling better controls and improved granularity across your APIs and data models. Leverage existing standards (E.g. OAuth 2.0) to grant granular access to services.
- It's Not Always Keeping the Bad Guys Out: You might think that security architectures are focused on keeping the bad guys out, but in fact most often the inverse is true. Access control infrastructure is designed to provide a user experience to authorized entities - employees, customers, etc. It’s important to design for malice - assume that those who try to gain unauthorized access are in fact not “playing by the rules,” instead of finding ways to work around the areas governed by policy.
- Keep it Balanced: Users simply don’t care about or understand security - they just want easy access and peace of mind that their data is secure. Unfortunately, for a long time security measures and technologies have delegated far too much responsibility to the end user, expecting them to make educated and technical decisions. How often have you been asked “Do you trust this certificate?” in a web browser? It’s not practical to assume users have the technical knowledge to understand PKI - so how is it reasonable to push this responsibility to them? API security should be designed in such a way to balance user experience and security.
- Arm the Developers: Developer experience is just as important as user experience, and here again knowledge around security can be dangerously lacking. Your API consumers can’t be expected to know, and your APIs can unwittingly create vulnerabilities by not arming developers with sufficient knowledge. For example, a developer may hit an API too many times and degrade performance. Or a developer may not know why or how to protect API and session keys. These can result in Denial of Service, and other security issues.
- Protect All Patterns: Finally, API integration patterns are evolving, and while request/response still makes up the lion’s share of implementations today, there are other models that need to be secured as well. With an increasing preference for Webhooks, Server-Sent Events, and WebSockets, the client-server designation is becoming blurred. Signatures and encryption (e.g. TLS) should be considered to help protect these bi-directional integration patterns. Here's an example of Cloud Elements Event Management Security.
Hopefully, this list helps at least shed some light on the issues you may encounter, and provide some guidance and best practice for specific use cases. API Security may not be a glamorous topic, and you won’t get much glory if you do everything right. But then again, nobody wants to make headlines for their failures!