Mulesoft - Principles of Mircroservice Security
Mulesoft - Principles of Mircroservice Security
Principles of
microservice security
How to manage digital risk at scale
Contents
Introduction .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Summary ................................................................................................... 28
Glossary ..................................................................................................... 30
Additional resources .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Challenges
›› Organizations are increasingly adopting microservices
architectures to create a foundation for continuous inno-
vation and agility, but the financial incentives associated
with increased agility are tempered by the fear of exposing
the valuable information microservices process. By 2020,
Gartner predicts 60% of digital businesses will suffer major
service failures due to the inability of the IT security team to
manage risks.
›› The frameworks, protocols, and technologies that have
evolved over the years to solve security problems are multi-
ple, complex, and sometimes rather difficult to understand.
Choosing the right ones, applying and combining them appro-
priately, and leveraging them successfully is not an easy task.
›› These difficulties will be increased in a microservice
architecture because its many moving parts necessarily
multiply the number of required security checkpoints.
Recommendations
›› Understand and establish a “CIA” strategy for your
microservice architecture: how can you ensure
confidentiality, integrity, and availability of the information
that they process?
›› Apply a unified set of security principles and
recommendations that can ease how you design and
implement microservices that are secure at scale.
›› Consider deploying a unified platform that will allow you to
govern the entire lifecycle of microservices as they mature
from design to implementation to management and finally
to deprecation and retirement.
3
Introduction
4
The three goals of information security
5
An overview of the seven design
principles of microservice security
6
How the seven principles
manifest in an API strategy
App Dev
Experience APIs
Innovation and digital products
Knowledge/asset exchange
Developer communities
LoB
Decentralization
Dev/IT
Process APIs
Agility and new value creation
Accessibility
and
ownership
7
Both system and process APIs digitize business capabilities
and form discrete digital building blocks that are individually
scalable for use in initiatives that engage with users across
multiple channels. They should not be invoked directly by
any client software but through adaptations specific to the
business channels that need them. [targeted, locked]
Experience APIs are adaptations of the core capabilities
encapsulated in Process and System APIs. They are targeted
at the specific requirements of the business channel and
touchpoint that consumes them. A separate Experience API is
delivered to each channel. They expose only the capabilities
required for their channel. [targeted, minimized]
All three layers are protected with mechanisms that identify
clients and users using industry standards to authenticate and
authorize the callers. [locked, multi-keyed, standardized]
All three layers hide failures from the user when appropriate
and their APIs are individually scalable. [elastic, resilient]
8
The principles of microservice security
Standardized
Standards now abound in the industry to address information
security goals. HTTPS uses TLS to cater to both the
confidentiality and integrity of information. It encrypts all of
the data transported and uses digital certificates and digital
signatures to identify both microservice and client. OAuth 2.0
offers a powerful framework for token-based access control.
OpenID Connect sits on top of OAuth 2.0 offering even more
with tokens that deal with the identity of the authenticated
user. It also has the same capabilities as SAML 2.0 offering
federated SSO interoperability. RSA 2048+, AES 256+, and
Blowfish are excellent encryption standards. NIST and PCI-DSS
are excellent tokenization algorithms. It is preferable to use
public standards for security mechanisms as any flaws in these
will be discovered much quicker, given the huge proliferation of
their usage, than anything you can build yourself.
9
use self-signed certificates, but public APIs MUST NOT use
self-signed certificates. They MUST use certificates signed by a
certificate authority.
10
Targeted
The scope of responsibility designed for a microservice should
be focused on the groups of users that use their capabilities.
Ultimately, it is human beings that our strategy aims to protect
the microservices from. Malicious software like bots is pro-
grammed by human beings to expose confidential information
and capabilities to unauthorized users. Thus it is preferable to
target the microservices at particular groups of users and avoid
sharing their capabilities among multiple user groups.
11
Employee Partner
Datacenter Internet
Extranet
Load balancer
Customer
VPN
Anypoint Fabric
DMZ
Customer App
Load balancer
Hybrid firewall
Corporate firewall
CloudHub
Anypoint VPC
Load balancer
Hybrid zone
Corporate zone
VPN
Load balancer
Load balancer
Anypoint Fabric
Anypoint Fabric Worker cloud
13
Set up an API gateway
You MUST deploy experience APIs that act as a gateway to all
backend process and system APIs. These are the primary target
for the application of security policies like OAuth, rate limiting,
auditing, and data filtering. They SHOULD only compose
process and system APIs which belong to their own domain.
Domain events from other domains MAY also be subscribed
to from these gateways unless they are public APIs deployed
to the DMZ. Cross-domain API calls SHOULD be made through
the target domain’s gateway.
Gateway logic
Experience layer
API composition
Process layer
Connectivity
Systems layer
14
Minimized
Microservices should not be generous with information. They
should only respond to queries with information sufficient to
meet the needs of the request and no more.
Locked
Microservices must not be accessible for default. Every call
must be authenticated and authorized to execute the query
or command. Even public Experience APIs that expose
information considered to be of the public domain must only
be consumed by registered client applications. Private Process
and System APIs should only ever be consumed by Experience
APIs. The information microservices handle in queries and
commands must not be visible to third parties and must be
guaranteed to be correct.
16
Use OpenID Connect and OAuth 2.0
Use OAuth 2.0 and OpenID Connect to issue and validate
bearer tokens to your API clients. You MUST oblige all
consumers of Experience APIs to pass in an OpenID Connect ID
token as well as the access token. The access token addresses
client-oriented access control and the ID token addresses
the REQUIRED user-oriented access control (See Apply User-
Oriented Access Control).
Anypoint
<< synchronizes client
Platform Services API Administrator
IDs and secrets to >>
Corporate OpenID Connect/
OAuth 2.0
<< 8. delegates sign-in to User Agent
<< 9. makes call with access token to >> validation policy
requesting sign-in form from >>
Figure 4: Identity Provider and OAuth 2.0 / OpenID Connect with Anypoint Platform
17
for use in protecting System and Process APIs (see Protect
Process and System APIs with OAuth 2.0 Client Credentials).
Thus you MUST only use either ‘implicit’ or ‘authorization code’
when looking at your options for Experience APIs.
OAuth 2.0 classifies clients as private (those that can keep their
credentials a secret) and public (those that cannot keep their
credentials a secret). According to this classification mobile
apps and Javascript single page apps are necessarily public
clients. This will help us determine the appropriate grant
type to use. ‘Authorization code’ was designed for server-side
software clients like the older style JSP web apps. These can
safely hide their credentials. Hence, clients in the authorization
code scenario MUST authenticate. Client authentication is not
mandated in the ‘implicit’ grant type.
Grant type
Public Experience
Experience
Private
System/
Process
Semi-public Experience
18
to a malicious third-party against the exposure of an access
token (which the ‘implicit’ grant type allows) to the same entity).
19
MUST authenticate itself with your identity provider, it MUST
use multi-factor authentication to authenticate the user, and
it MUST validate the ID token that it receives at the end of the
flow. It MUST pass both the access token and the ID token in
separate headers in the API call. You MUST apply an access
token validation policy to the API. You MUST also apply an ID
token validation policy which is able to verify the signature on
the ID token and inspect the body for attributes that inform
the access control decision (see Apply User Oriented Access
Control). All policy validation failures MUST reject the API call
and return the HTTP status 403.
20
the access control decision (see Apply User-Oriented Access
Control). All policy validation failures MUST reject the API call
and return the HTTP status 403.
21
usernames, and passwords in plain text to any systems of
record, or logs, or message brokers.
Use encryption
You MAY choose to encrypt the entire payload before
persistence. In this case, you will need to decrypt it before
sending it back to a user or before subsequent processing.
When encrypting you MUST choose strong cryptographic
algorithms like RSA 2048+, AES 256+, or Blowfish. For stronger
security requirements you MUST use algorithms that have are
compliant or certified with industry standards like FIPS 140-2.
Use tokenization
It is RECOMMENDED that you adopt tokenization in preference
to encryption. You MUST tokenize sensitive data as soon as you
receive it in its plain text values. Whenever the plain text value
is needed for subsequent processing you MAY detokenize it.
You MUST NOT detokenize any tokenized values unless
needed for processing or in response to an explicit user query
for that information. You MUST respond to other user queries
with tokenized values. You MUST ensure that the algorithm
used is based on industry standards like NIST or PCI-DSS.
Multi-keyed
There should be no single point of failure in your security
mechanisms. It is preferable to have multiple checks so that if
one mechanism were to fail then the others will still protect the
microservice. The client must present credentials to identify
itself and the user who initiated the request.
22
Apply user-oriented access control
An inherent weakness to OAuth 2.0 (see Use OpenID Connect
and OAuth 2.0) is the assumption that the user, on behalf of
whom the access token was issued to the consuming app
(client, is the owner of the resource). You MUST NOT allow
access to your Experience APIs until you have verified the
identity of the user including information about them which
will inform the access control decision. You SHOULD use
the OpenID Connect ID token to help with this decision. You
SHOULD propagate the ID token across every API call made by
all the microservices that participate in a user transaction.
23
Use mutual TLS on private and semi-public APIs
You MUST use mutual TLS on all semi-public experience API
calls from within the extranet and on private API calls from the
DMZ to the corporate segment. It is NOT REQUIRED to do the
same on public API calls given the much larger customer base
that consume those APIs.
Elastic
To make information available at every time it is needed, your
microservices must be able to handle spikes in traffic. You
should protect your APIs from the very traffic that consumes
them. Even friendly traffic should be considered a threat as it
can overwhelm your microservices. A strategy is needed for
your microservices to grow and shrink with the traffic.
24
rate limiting and XML/JSON threat protection policies that you
can apply with API Manager.
Use containerization
You SHOULD use containerization to deliver your microservices
(See Use Container Scheduling). Apart from making the
realization of continuous delivery easy, containers also bring
security benefits to a microservice by decreasing the extent
of security risk present within its environment. You MUST
NOT pull random images from the internet. You MUST use
base images with vetted sources that can be easily validated
and checked. You MUST scan your containers for common
vulnerabilities and exposures (CVEs) just like any other software
distribution. You SHOULD add base image release metadata
to containers.
25
Resilient
Most commands and some queries issued by users will result
in multiple microservice calls. Microservice architectures must
be designed as if failures are guaranteed. Errors that occur
should be hidden from users when possible and appropriate.
26
Isolate subscriptions to message brokers
Microservices subscribed to Anypoint MQ queues or
exchanges, or those that subscribe to AMQP or JMS message
brokers MUST NOT do so from the DMZ. These subscriptions
SHOULD be limited to microservices deployed to the corporate
or hybrid zones or to Cloudhub. Microservices deployed to the
DMZ MAY publish messages to the message broker.
27
Summary
28
Principle Requirement API profile Level
Private
29
Glossary
30
Integrity: Characteristic that guarantees information is not
modified by a malicious third-party.
Json Web Token (JWT): Interoperable identity token used
for authentication scenarios and incorporated into OpenID
Connect flows.
Mutual TLS: Protocol that obliges the client to send a digital
certificate to authenticate itself to the microservice. One way
TLS consists in only the microservice authenticating itself to
the client.
Network Segment: A division of a network that provides
isolation accessible only when firewall rules are set up to
allow access.
OAuth 2.0: A framework for the delegated authorization by
authenticated users to apps of resources that they own.
OpenID Connect: Layer on top of OAuth 2.0 that addresses
interoperability, user identity and user authentication.
Private API: Interface to microservice only accessible from
within your LAN deployed to the corporate segment.
Public API: Interface to microservice deployed to your DMZ and
accessible from the internet.
SAML 2.0 Assertion: Interoperable identity token used for
authentication scenarios and incorporated into the WS security
standard as well as single-sign-on (SSO) configurations.
Semi-public API: Interface to microservice accessible from the
internet so long as a VPN connection is established.
Tokenization: the process of substituting sensitive data with a
meaningless token.
Transport Level Security (TLS): Is a network communication
protocol that aims to address the needs for information
confidentiality and integrity during the exchange between two
machines and does the same for microservice invocation.
31
Additional resources
32
About MuleSoft
33