2. Cloud Security Overview


Secure

- app

- K8s platform

During

- build

- deployment

- runtime

Learning Objectives

security @ cloud production env

system and cluster hardening

security @ container supply chain

Monitor and Log security events

Skills

- package manager

- Git and Github

SIG

K8s has 118 SIG

- Kubernetes Security Profiles Operator SIG : https://github.com/kubernetes-sigs/security-profiles-operator to make managing and applying seccomp and AppArmor profiles more easy and straight forward in Kubernetes

- CNCF Special Interest Group for Security: https://github.com/cncf/sig-security enable secure access, policy control, and safety for operators, administrators, developers, and end-users across the cloud native ecosystem

Security Process:

-- Asset Life Cycle

-- SDLC

-- procedure and policy

-- Roles and Responsibilities 

Security Principles

- Assessment: More risk with (1) SSO, (2) additional staff, (3) centralized service

- Prevention:

1. technical control: HW and SW

2. procedural control: processes and policies

3. physical control: key card, locks

Asset wise protection

* Service : Available

* Data : Confidential

* Software: Integrity of executable 

- Detection:

Easiest and most cost effective

Most expensive and difficult to execute

--- Monitoring: remote logging, system statistics, and performance metrics

--- Intrusion Detection and Prevention Systems (IDPS)

--- Incident detection methods 

1. signature-based, 

2. statistical anomaly-based, 

3. stateful protocol analysis (monitoring) 

- Reaction 

-- Adding firewall rules, 

-- Adding scanners, 

-- Re-implementing the systems, or 

-- Shutting down certain components

RCA

Attack Types

White Hat: ethical hacker, non-malicious reason

Black Hat

Script Kiddie: non-expert

Hacktivist: DoS. To announce message

Nation State:  intelligence agencies and cyber warfare operatives 

Organized Crime

Bots: Automated Software Tools

1. Active Attack

* DoS

* Spoofing Attack : ARP, IP, MAC, DNS are susceptible for spoofing

* ARP storms

* session hijacking

* packet injection

1.1 alter system resources to compromise integrity.

1.2 affect system operation to compromise availability.

2. Passive Attack: Learn system to compromise confidentiality 

The 4 Cs of Security

- code, container, cluster, cloud

1. Code: Trusted code

2. Container: 

* container vulnerability scanning, 

* image signing to ensure nothing has been modified, 

* preventing the leveraging of elevated privileges past the least privileges required.

3. Cluster: 

* etcd database

* networks: API end points, ports

* worker node: kubelet and kubeproxy

Security Agency and Security Resource

NIST Cyber Security Framework. 

- 5 Security activities: Identify, Protect, Detect, Respond, and Recovery

- 6 categories of each activities

1. Asset Mgmt

2. Business Env

3. Governance

4. Risk Assessment 

5. Risk Mgmt Strategy

6. Supply Chain Risk Mgmt

CNCF Project Categories

1. Graduated: Kubernetes, Prometheus, Envoy, Helm, Fluentd, Jaeger, etc.

2. Incubating: CNI, CRI-O, Linkerd, OpenTracing, Thanos, etc.

3. Sandbox: Artifact Hub, k3s, in-toto, Keylime, Parsec, etc.

4. Archived: rkt

* Artifact Hub: Package management directory 

* in-toto: A framework to secure the integrity of software supply chains

* Keylime: scalable trust system harnessing TPM Technology

* Parsec: Platform AbstRaction for SECurity: common API to hardware security and cryptographic services in a platform-agnostic way.

Parsec aims to define a universal software standard for interacting with secure object storage and cryptography services, creating a common way to interface with functions that would traditionally have been accessed by more specialized APIs.

Acronyms 

BOD: Binding Operational Directives

CIS: Center for Internet Security

CISA: Cybersecurity and Infrastructure Security Agency

CSF: Cybersecurity Framework

CSRC: Computer Security Resource Center

FIPS: Federal Information Processing Standard

HVA: High Value Asset 

NIST: National Institute of Standards and Technology

NVD: National Vulnerability Database

PARSEC: Platform AbstRaction for SECurity

SAML: Security Assertion Markup Language 

SELinux: Security-Enhanced Linux

------------------------

SELinux:  a security architecture for Linux systems that allows administrators to have more control over who can access the system

Kerberos : Network authentication protocol

SAML: an open standard for exchanging authentication and authorization data between parties (identity provider and a service provider.)

Securing kube-controller-manager


Please execute this command at master node, to see the values of configuration parameters / flags for K8s Controller Manager

ps -ef | grep kube-controller-manager

As per section 1.3 of CIS Benchmark below table describe (1) parameter (2) its default value and (3) its desired value

Flags Default Value
--terminated-pod-gc-threshold 12500 (pods) set appropriate
--profiling TRUE FALSE
--use-service-account-credentials FALSE TRUE
--service-account-private-key-file Not Set Appropriate
--root-ca-file Not Set Appropriate
RotateKubeletServerCertificate TRUE TRUE
--bind-address 0.0.0.0 127.0.0.1

when --use-service-account-credentials=true with RBAC, it ensures, control loop runs with minimum privilege. 

Securing kube-scheduler


 Please execute this command at master node, to see the values of configuration parameters / flags for K8s Scheduler

ps -ef | grep kube-scheduler

As per section 1.4 of CIS Benchmark

* --profiling should be change from default true to false

* --bind-address should be change from 0.0.0.0 to 127.0.0.1 

Additional tips not in CIS Benchmark

* Ensure that AppArmor is not disabled for kube-scheduler.

* AllowExtTrafficLocalEndpoints feature is disabled using --feature-gates

Securing etcd


Please execute this command at master node, to see the values of configuration parameters / flags for etcd

ps -ef | grep etcd

As per section 2 of CIS Benchmark below table describe (1) parameter (2) its default value and (3) its desired value

Flags Default Value
--cert-file not set Appropriate
--key-file not set Appropriate
--client-cert-auth FALSE TRUE
--auto-tls FALSE FALSE
--peer-client-file Not Set Appropriate
--peer-key-file Not Set Appropriate
--peer-client-cert-auth FALSE TRUE
--peer-auto-tls FALSE FALSE

* --trusted-ca-file: this value should be different from --client-ca-file for API Server

Additional tips not in CIS Benchmark

* Restrict node access: Use Linux firewalls to ensure that only nodes that need access to etcd are allowed access.

* Encrypt data at rest: --encryption-provider-config is passed to the API server to ensure that data is encrypted at rest in etcd.

Securing kubelet


Please execute this command at master node, to see the values of configuration parameters / flags for kubelet. This is for first column. 

ps -ef | grep kubelet | grep config

The default configuration path can be found from /etc/systemd/system/kubelet.service.d/10-kubeadm.conf This is for second column. 

As per section 4.2 of CIS Benchmark below table describe (1) parameter with desired value (2) its default value


Command line arguments Config File Default
--anonymous-auth=false authentication: anonymous: disabled true
KUBELET_AUTHZ_ARGS --authorization-mode!=AlwaysAllow authorization: mode!=AlwaysAllow AlwaysAllow
KUBELET_AUTHZ_ARGS --authorization-mode=Webhook authorization: mode=Webhook
KUBELET_AUTHZ_ARGS --client-ca-file authentication: x509: clientCAFile
KUBELET_SYSTEM_PODS_ARGS --read-only-port=0 readOnlyPort:0 0 or 10255
KUBELET_SYSTEM_PODS_ARGS --streaming-connection-idle-timeout=NON-ZERO streamingConnectionIdleTimeout=NON-ZERO 4 hrs
KUBELET_SYSTEM_PODS_ARGS --protect-kernel-defaults=true protectKernelDefaults=true fasle
KUBELET_SYSTEM_PODS_ARGS --make-iptables-util-chains=true makeIPTablesUtilChains=true true
KUBELET_SYSTEM_PODS_ARGS --hostname-override=ABSENT ABSENT
KUBELET_SYSTEM_PODS_ARGS --event-qps=0 OR APPROPRIATE eventRecordQPS:0 OR APPROPRIATE 5
--rotate-certificates=true rotateCertificates=true true
KUBELET_CERTIFICATE_ARGS --rotateserver-certificates=true RotateKubeletServerCertificate=true false
--tls-cipher-suites TLSCipherSuites
KUBELET_CERTIFICATE_ARGS --tls-cert-file
KUBELET_CERTIFICATE_ARGS --tls-private-key-file

* --tls-cipher-suites : kubelet supports a wide range of cipher suits : TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
One should select a stonger cipher suite

Additional tips not in CIS Benchmark

* the APIs exposed by kubelet shall be accessible by K8s API Server only, using RBAC

* Enable the NodeRestriction admission controller: The NodeRestriction admission controller only allows kubelet to modify the node and pod objects on the node it is bound to.