Cloud Security
1. Cloud Native Security
Overview
- Followed a layered approach that is based on defense in depth approach.
- The 4C layers of Cloud Native Security
- Cloud Datacenter
- Cluster (Kubernetes)
- Container
- Code
Cloud Data Center
- Cloud Provider: Their hardware their policy
- In-house infrastructures
- Physical security
- Network access
- Database access (
etcdfor Kubernetes)
Cluster (Kubernetes)
- RBAC Authorization
- Authentication
- Encryption
- Network Policies
- TLS for Kubernetes Ingress
Container
- Vulnerability Scanner/OS Dependencsy Security
- Privilege Control/Disabling
- Container runtime isolation
Code
- Secure communication over TLS
- Port range limitation
- Security of external library dependency
- Static code analysis
- Dynamic code security (SQL injection, cross-site scripting, ...)
2. Cluster Security: Kubernetes
Authentication
- Users:
- Normal users (managed by host system/remote management like LDAP)
- Service accounts (internal to K8s)
- Users can present a valid certificate signed by the cluster's CA (Certificate Authority) are considered authenticated.
Authentication hands-on
Extract configuration information
- Keep a record of the following fields (or do this in separate terminals)
certificate-authority-dataserverclient-certificate-dataclient-key-data
Create a new user account
- New user account is called
student:
- Try running
kubectlcommands now:
Setup authorization to access K8S
- As
student, run the following command:
- Next, create a file called
configinside.kubewith the following contents:- Replace
COPY_FROM_ABOVEwith the corresponding values of the corresponding fields above.
- Replace
apiVersion: v1
clusters:
- cluster:
certificate-authority-data: COPY_FROM_ABOVE
server: COPY_FROM_ABOVE
name: kubernetes
contexts:
- context:
cluster: kubernetes
user: student
name: student@kubernetes
current-context: student@kubernetes
kind: Config
preferences: {}
users:
- name: student
user:
client-certificate-data: COPY_FROM_ABOVE
client-key-data: COPY_FROM_ABOVE
- Try running
kubectlcommands now:
Challenge
Adding at least another Kubernetes cluster from one of your classmates' experiment to your
student account. In other words, one account can have access to multiple K8S cluster.
RBAC Authorization
- Kubernetes uses the
rbac.authorization.k8s.ioAPI group to drive RBAC-based authorization decisions, - By default, Kubernetes clusters are often launched with RBAC:
- RBAC API: Role, ClusterRole, RoleBinding, ClusterRoleBinding.
- Role: sets permissions within a particular namespace
kubectl get role --all-namespaces
kubectl describe role system::leader-locking-kube-controller-manager -n kube-system
- ClusterRole: set permission for non-namespaced resources
- RoleBinding binding grants the permissions defined in a role to a user or set of users.
- ClusterRoleBinding grants that access cluster-wide.
- What
resourcesare available and whatverbsare applicable?
Kubernetes Ingress
- Ingress exposes HTTP and HTTPS routes from outside the cluster to services within the cluster.
- Traffic routing is controlled by rules defined on the Ingress resource.
- Ingress is managed by Ingress Controllers.
- There are many diffferent Ingress Controllers
3. Container Security
Pod Security Standards
- Pod security will influence container security.
- Three policies:
- Privileged
- Baseline
- Restricted
- Cummulative and range from highly permissive to highly restrictive
Privileged
- Purposely open, entirely unrestricted
- Enable system- and infrastructure-level workloads
- Implied understanding that these workloads are run as privileged/trusted users.
- Absence of restrictions and allow-by-default mechanism
Baseline
- Streamline adoption for common containerized workloads
- Prevent known privilege escalations
- Example capabilities (Linux capabilities) enabled in baseline
- AUDIT_WRITE
- CHOWN
- DAC_OVERRIDE
- FOWNER
- FSETID
- KILL
- MKNOD
- NET_BIND_SERVICE
- SETFCAP
- SETGID
- SETPCAP
- SETUID
- SYS_CHROOT
- Linux full capability list
Restricted
- Enforce Pod hardening best practices at the expense of compatibility
- Target security-critical applications and lower-trust users
- Example policy:
- Disable privilege escalation
- Containers must run as non-root
- Drop ALL capabilities and only allow
NET_BIND_SERVICE.


