Advanced Container Security - Jason Umiker - 28jun - Final
Advanced Container Security - Jason Umiker - 28jun - Final
Jason Umiker
Solutions Architect, AWS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Agenda
Introduction
Conclusion
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Challenges of containers at scale
• More transient/dynamic
• More distributed and complex
• More services interdependent over a network
• Scheduling / Scaling / Resource Management
• Less isolated
• Share a kernel
• Often share a network and—in case of Amazon Elastic Container
Service for Kubernetes (Amazon EKS)—a network interface
Coming
Soon!
2. Choose your
launch type
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM = Who can do what on the platform / in the cluster?
People Code/Pipelines
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Invest in end-to-end automation via pipelines
• AWS infrastructure as code
• Code and container builds
• Security (DevSecOps)
• Deployments
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why DevSecOps via pipelines?
Because if you don’t make it
fast and easy to do the right
thing, people will often just go
around the rules/restrictions to
get their work done!
Photo &
License
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Identity and Access Management (IAM) vs.
Kubernetes RBAC
If using Amazon ECS, then that If running Kubernetes, either
is a native extension of the yourself or via Amazon EKS,
AWS solution and is fully you need to understand and
managed by IAM. configure BOTH IAM and
Kubernetes RBAC.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS: IAM authentication + kubectl
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS: IAM authentication + kubectl
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS: IAM authentication + kubectl
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS: IAM authentication + kubectl
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EKS: IAM authentication + kubectl
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Kubernetes RBAC built-in ClusterRoles
Default
Description
ClusterRole
Allows superuser access to perform any action on any resource. When used in
a ClusterRoleBinding, it gives full control over every resource in the cluster and in all
cluster-admin
namespaces. When used in a RoleBinding, it gives full control over every resource in the
Rolebinding's namespace, including the namespace itself.
Allows read/write access to most objects in a namespace. It does not allow viewing or
edit
modifying roles or rolebindings.
Allows read-only access to see most objects in a namespace. It does not allow viewing
view
roles or rolebindings. It does not allow viewing secrets, since those are escalating.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Kubernetes RBAC basics
Kubernetes has roles, which are kind: ClusterRole
defined and apply within a single metadata:
namespace (a virtual cluster) and name: cluster-admin
ClusterRoles, which apply rules:
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
IAM role per task/pod?
Assigning an IAM role to an instance/task/function means the right
AWS access key and secret to call the AWS CLI/SDK are transparently
obtained and rotated.
Assigning an IAM role to an Amazon If running Kubernetes, you need to
ECS task is an included feature in the add either kube2iam or kiam to
AWS offering and “just works.” leverage this functionality.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS container road map on GitHub
https://github.com/aws/containers-roadmap
Captured
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
5/19/2019
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Logging and auditing the control plane
Logging of the control plane, especially around an audit trail of API
actions, is an important aspect of security.
Amazon ECS is part of the AWS offering, Kubernetes’ control plane logs include an
and the control plane logs go to AWS audit trail. With Amazon EKS, these logs are
CloudTrail just like the rest of the solution. not exposed by default, but you can (and
should) enable sending them to Amazon
CloudWatch Logs.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS security groups vs. Kube network policies
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Networking with Amazon ECS
Default/Root Namespace
You can use a security group ID as both a source and a destination for
other security group rules—both to loop back to itself and to reference
other SGs.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Private Amazon EKS control plane API endpoints
Master VPC (AWS account)
etcd
Public == false
etcd
Private == true AZ 1 AZ 2
Kubectl
Worker Worker
node node
Kubelet Kubelet
Kube-proxy Kube-proxy
AZ 1 AZ 2
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Networking with Amazon EKS
https://github.com/aws/amazon-vpc-cni-k8s
VPC
ec2.associateaddress()
ENI
10.0.0.20
10.0.0.1
10.0.0.2 10.0.0.22
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Installing a network policy provider on Kubernetes
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Network policies on Kubernetes
catsndogs-namespace
kind: NetworkPolicy
apiVersion: extensions/v1beta1
metadata:
Cats Dogs name: default-deny
spec:
podSelector:
matchLabels: {}
Frontend
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Network policies on Kubernetes
catsndogs-namespace
kind: NetworkPolicy
apiVersion: extensions/v1beta1
metadata:
Cats Dogs name: default-deny
spec:
podSelector:
matchLabels: {}
Frontend
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Network policies on Kubernetes
catsndogs-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: public-to-frontend
spec:
Frontend
port: 80
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Network policies on Kubernetes
catsndogs-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: public-to-frontend
spec:
Frontend
port: 80
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Network policies on Kubernetes
catsndogs-namespace
apiVersion: extensions/v1beta1
kind: NetworkPolicy
metadata:
name: frontend-to-cats
spec:
Cats Dogs
podSelector:
matchLabels:
role: cats
ingress:
- from:
- podSelector:
matchLabels:
role: "frontend"
ports:
- protocol: TCP
Frontend port: 80
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Tigera Secure Cloud Edition (CE)
Features:
• Enterprise support from Tigera
• Host-to-host IPSEC encryption
• Flow logs enriched with Kubernetes workload metadata
• Integration between AWS security groups and network policies
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Tigera Secure Cloud Edition (CE)
ElastiCache
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Alternative: Multiple NodeGroups or Clusters
One way that you can both assign Amazon EC2 instance-level IAM roles
(without kops or kiam) and fully trust security group-based micro-
segmentation without Tigera is to have a different set of worker nodes,
or even entirely separate Clusters, for different services or trust
boundaries.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Wildcard: Service mesh instead?
Instead of imposing network-level restrictions like AWS security groups
or Kubernetes network policies, you can use a service mesh to both
encrypt and authenticate all of your services, allowing for a flatter
more unsegmented underlying network, while still staying safe.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Why AWS App Mesh?
Control plane
Proxy
Control plane
Service Service
Translates intent to proxy config
team A team B Distributes proxy config
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Sidecar proxy with containers
Task or pod
Application
code as a
External traffic container
Proxy runs
as a container
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS App Mesh and Istio both use Envoy
OSS project
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
App Mesh control plane configures every proxy
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Mutual TLS authentication (mTLS)
Certificate Authority Client Validates Server Cert
Certificate Generation /
and
Signing for Client &
Server Validates Client Cert
Server Client Cert
Server Cert
Client Server
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS App Mesh vs. Istio
App Mesh Istio (on Amazon EKS)
• Orchestrates Envoy sidecar • Orchestrates Envoy sidecar
• Integrated with Kubernetes • Integrated with Kubernetes
• Does not yet support • Supports encryption and
encryption and mTLS mTLS
• Wider integration with AWS • Requires Kubernetes
• Regional managed service • State stored in Kubernetes’
• Fully supported by AWS control plane and etcd via
custom resources
• Best-effort support by AWS
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS AppMesh road map on GitHub
https://github.com/aws/aws-app-mesh-roadmap
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Captured
19/5/2019
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2 mode: Customer responsibilities
• Instance type and quantity to choose?
• What is the CPU-to-RAM ratio?
• Excess capacity for scaling and
availability?
• Which OS to choose?
• If Amazon Linux, we provide AMIs
• Hardening the OS (e.g., against CIS
benchmark)
• Patching of the OS, Docker, Amazon
ECS agent or kubelet, etc.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Photo & License
Security benefits of AWS Fargate
We do more, you do less.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon EC2-mode ECS shared responsibility model
Customer Data
CUSTOMER
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Amazon ECS and AWS Fargate shared responsibility
model
Customer Data
CUSTOMER
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Updating Amazon EKS
• Kubernetes has a new major version every quarter
• Kubernetes has a new minor version quite regularly
• Sometimes Kubernetes updates are security-related
• Amazon EKS has APIs to trigger an update of the
control plane
• You then need to update the worker nodes—re:
Kubernetes as well as Docker and OS
•Often the workers are in an automatically scaling
group, so this means building/updating AMIs
•We provide a regularly updated Amazon EKS node AMI
as well as scripts to build your own
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
AWS Parameter Store, AWS Secrets Manager, and
Kubernetes Secrets
AWS has both Parameter Store and Secrets Kubernetes’ built-in Secrets functionality
Manager to store your secrets. They are stores secrets in its control plane and puts
integrated into Amazon ECS, but you’ll them into running pods via environment
need to call them within the pod on variables or files in the file system. You
Kubernetes via our CLI or SDK. can’t use these outside of the Kubernetes
cluster.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shared responsibility model
Customer Data
CUSTOMER
Responsible for
security “in” the Applications Platform Identity & Access Management
cloud
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Security best practices for container images
kernel
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Security best practices for container images
glance kernel
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Image scanning
• Scan images in your registry
Docker Hub does this
On our road map to do with Amazon Elastic Container Registry
(Amazon ECR) as well
• Scan images in your build pipeline
•Clair - https://github.com/coreos/clair
•Aqua Microscanner - https://github.com/aquasecurity/microscanner
• Scan images at runtime / running containers (these can also scan in
pipeline)
•Aqua - https://www.aquasec.com/solutions/aws-container-security/
•Twistlock - https://www.twistlock.com/solutions/aws-security/
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
https://aws.amazon.com/containers/partner-solutions/
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Summing up
The customer has many responsibilities when running containers securely in AWS.
This is even more true when running Kubernetes on the platform than when
running Amazon ECS.
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Learn from AWS experts. Advance your skills and
knowledge. Build your future in the AWS Cloud.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.
Why work with an APN Partner?
APN Partners are uniquely positioned APN Partners with deep expertise in
to help your organization at any AWS services:
stage of your cloud adoption journey, AWS Managed Service Provider (MSP)
and they:
Partners
• Share your goals—focused on your APN Partners with cloud infrastructure and
success application migration expertise
• Help you take full advantage of all the AWS Competency Partners
business benefits that AWS has to offer APN Partners with verified, vetted, and validated
specialized offerings
• Provide services and solutions to
support any AWS use case across your AWS Service Delivery Partners
full customer life cycle APN Partners with a track record of delivering
specific AWS services to customers
aws-apac-marketing@amazon.com
twitter.com/AWSCloud
facebook.com/AmazonWebServices
youtube.com/user/AmazonWebServices
slideshare.net/AmazonWebServices
twitch.tv/aws
© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved.
© 2019, Amazon Web Services, Inc. or its Affiliates. All rights reserved.