Kailash Bohara bio photo

Kailash Bohara

Senior Cybersecurity Engineer and ethical hacker in Nepal with 9+ years in penetration testing, security architecture, cloud security, and data security. OWASP Kathmandu chapter leader and CVE researcher.

Twitter LinkedIn Github

Why Container Security Matters

Containers share a kernel. Unlike virtual machines, they are not hard boundaries they are namespaced processes with optional control group limits and Linux security modules layered on top. When we treat containers like as “VMs,” and think it inherit controls like VMs such as internal traffic is trusted, root inside the container is harmless this does not satisfies in Kubernetes.

In a monolithic application architecture, compromise might mean one server. But in Kubernetes:

  • One privileged pod can read host filesystems, access cloud metadata APIs, or pivot to the node IAM role.
  • One poisoned image in CI can deploy to every environment that trusts the pipeline.
  • One missing NetworkPolicy can leave the entire cluster open to internal reconnaissance between microservices.

Compliance and Customer Trust

Regulators and auditors expect evidence that production workloads are built from verified artifacts, run with least privilege, encrypt sensitive data, and leave an audit trail when configurations change. Frameworks such as SOC 2, ISO 27001, HIPAA, and PCI DSS all map to concrete Kubernetes practices: signed images and SBOMs for supply chain integrity, RBAC and secret management for access control, NetworkPolicies for segmentation, and centralized logging for monitoring and incident response. Below are basic controls that auditors might ask evidence for:

  • Signature verification logs at deploy time
  • SBOM + vulnerability scan reports per release
  • Least-privilege RBAC and secret handling
  • Use of non-root user and no privileged pods
  • Kubernetes audit logs for who changed cluster resources and when
  • Scan report that align with CIS Benchmarks and Pod Security Standards

Cost of Getting It Wrong

Missing Controls Typical Impact
Root + privileged pod Node compromise, cluster takeover
:latest tag in production Uncontrolled rollbacks, unknown CVE exposure
Secrets in ConfigMaps Credential theft, data exfiltration
No network segmentation Lateral movement after initial foothold
Weak CI/CD identity Supply chain compromise at scale

Defense in Depth: How the Control Domains Fit Together

The security controls below are not separate items to pick and choose from. They work together like layers of one system.

flowchart TB
    subgraph Layer1["Layer 1: Supply Chain & Deployment"]
        A1[Signed Images]
        A2[SBOM Validation]
        A3[GitOps + Approvals]
        A4[Separate Build/Deploy Identity]
    end

    subgraph Layer2["Layer 2: Cluster & Infrastructure"]
        B1[API Server Hardening]
        B2[etcd Encryption]
        B3[Node Hardening]
        B4[Admission Controllers]
    end

    subgraph Layer3["Layer 3: Workload Configuration"]
        C1[Non-Root / PSS Restricted]
        C2[Resource Limits & QoS]
        C3[Network Policies]
        C4[Service Mesh mTLS]
    end

    subgraph Layer4["Layer 4: Runtime & Detection"]
        D1[Image Scanning]
        D2[Runtime Anomaly Detection]
        D3[Falco Alerts]
        D4[Audit Logging]
    end

    Layer1 --> Layer2 --> Layer3 --> Layer4

    style Layer1 fill:#e8f4fd
    style Layer2 fill:#d4edda
    style Layer3 fill:#fff3cd
    style Layer4 fill:#f8d7da

Secure Reference Architecture

The following diagram illustrates a production-grade secure container platform.

flowchart LR
    Git[Git Repository] --> CI[CI Pipeline<br/>Build · Scan · Sign · SBOM]
    CI --> Reg[(Private Registry)]
    Reg --> CD[GitOps Deploy<br/>+ Prod Approval]
    CD --> K8s[(Kubernetes Cluster)]
    K8s --> Policy[Policy Layer<br/>Admission · PSS · Network]
    K8s --> Observe[Observability<br/>Logs · Metrics · Runtime]
    K8s --> Identity[Identity<br/>Secrets · Service Accounts]
    style CI fill:#e8f4fd
    style CD fill:#d4edda
    style K8s fill:#fff3cd

Internal cluster traffic is not automatically secure. We should implement Network Policies and service mesh mTLS for identity-aware communication.

flowchart TB
    subgraph Ingress["Ingress Layer"]
        WAF[WAF / API Gateway]
        TLS[TLS Termination]
    end

    subgraph NS_Frontend["Namespace: frontend"]
        FE[Frontend Pods]
    end

    subgraph NS_API["Namespace: api"]
        API[API Pods]
    end

    subgraph NS_Data["Namespace: data"]
        DB[(Database Pods)]
    end

    subgraph Egress["Egress Control"]
        EGW[Egress Gateway / Firewall]
        Ext[External APIs]
    end

    Internet((Internet)) --> WAF --> TLS --> FE
    FE -->|"NetworkPolicy: allow 443"| API
    API -->|"NetworkPolicy: allow 5432"| DB
    API -->|"Restricted egress"| EGW --> Ext

    FE -.->|"mTLS via Service Mesh"| API
    API -.->|"mTLS via Service Mesh"| DB

    style NS_Frontend fill:#e8f4fd
    style NS_API fill:#d4edda
    style NS_Data fill:#fff3cd

Why Golden Images Matter

A golden image is a pre-approved, minimal base image that every team should builds instead of pulling random public images. Think of it as the standard front door every application must use—same locks, same thickness, same inspection before anyone moves in.

Why security teams care:

  • Smaller attack surface : A slim base image contains fewer packages, which means fewer known vulnerabilities to patch and fewer places for attackers to hide tools.
  • Consistent hardening : Non-root user, dropped capabilities, and security patches are applied once in the golden image, not reimplemented (or forgotten) by every development team.
  • Faster, reliable scanning : When all apps share a known base, vulnerability scans are repeatable. You scan the golden image and every app built on top of it inherits that baseline.
  • Audit and compliance : Auditors can review one approved image pipeline instead of hundreds of one-off Dockerfiles. You can show exactly what is allowed to run in production.
  • Supply chain control : Only blessed images from your private registry get deployed. Unknown or tampered public images never reach the cluster.

Implementation Roadmap

Prioritize controls by risk reduction vs effort. The phased approach below mirrors what most security engineering teams deploy successfully.

flowchart TB
    subgraph P1["Phase 1 — Foundation (Weeks 1–4)"]
        direction TB
        P1A[Non-root users and resource limits]
        P1B[Private registry with pinned tags]
        P1C[RBAC review and service accounts]
        P1D[Centralized logging]
    end

    subgraph P2["Phase 2 — Policy (Weeks 5–10)"]
        direction TB
        P2A[Image scanning in CI]
        P2B[Pod Security Standards]
        P2C[Admission controllers]
        P2D[Default-deny Network Policies]
    end

    subgraph P3["Phase 3 — Supply Chain (Weeks 11–16)"]
        direction TB
        P3A[Signed images and SBOM]
        P3B[GitOps with production approvals]
        P3C[Separate build and deploy identities]
    end

    subgraph P4["Phase 4 — Advanced (Ongoing)"]
        direction TB
        P4A[Encrypted service-to-service traffic]
        P4B[Runtime threat detection]
        P4C[Automated benchmark compliance scans]
    end

    P1 --> P2 --> P3 --> P4

    style P1 fill:#e8f4fd
    style P2 fill:#d4edda
    style P3 fill:#fff3cd
    style P4 fill:#f8d7da

Phase 1 — Easy to implement (Weeks 1–4)

  • Enforce non-root, drop capabilities, read-only root FS where feasible
  • Eliminate :latest; pin image digests
  • Define CPU/memory limits on all workloads
  • Enable centralized logging and basic monitoring alerts
  • Audit RBAC; remove broad admin access where possible

Phase 2 — Policy Enforcement (Weeks 5–10)

  • Deploy admission policies to block privileged pods and unapproved registries
  • Adopt Pod Security Standards (restricted for new workloads)
  • Implement default-deny NetworkPolicies per namespace
  • Integrate image scanning in CI

Phase 3 — Supply Chain Integrity (Weeks 11–16)

  • Sign images; verify signatures at admission
  • Generate and store SBOMs per release
  • Use GitOps with branch protections and production approval workflows
  • Split CI build identity from CD deploy identity

Phase 4 — Runtime & Zero Trust (Never ending process)

  • Encrypt service-to-service traffic for sensitive tiers
  • Runtime anomaly detection and automated response playbooks
  • Continuous benchmark compliance scanning
  • Secret rotation automation

Threat Model: Before and After Hardening

flowchart LR
    subgraph Before["Before Hardening"]
        T1[Attacker] --> I1[Compromised App]
        I1 --> P1[Privileged Pod]
        P1 --> N1[Node + IAM Role]
        N1 --> C1[Cluster Admin / Cloud Account]
    end

    subgraph After["After Hardening"]
        T2[Attacker] --> I2[Compromised App]
        I2 -->|NetworkPolicy blocks| X1[Blocked Lateral Move]
        I2 -->|Non-root + seccomp| X2[Escalation Failed]
        I2 -->|Runtime alert| SOC[SOC Detects & Isolates]
        I2 -->|Scoped SA only| X3[No Cloud Metadata Access]
    end

    style Before fill:#f8d7da
    style After fill:#d4edda

Conclusion

Container security is not a single tool. It is architecture, process, and culture expressed through enforceable controls. The checklist your organization is implementing spans runtime isolation, resilient operations, observability, supply chain integrity, identity, network zero trust, runtime detection, governance, and platform hardening. Each domain reinforces the others.

As a security engineer, my advice is direct: start with what attackers exploit first privileged pods, public images, missing network segmentation, and over-permissioned CI/CD and automate denial of bad configurations at admission time. Scanning and monitoring catch what policy misses.