Console Login

Container Security Post-Log4j: Hardening Docker and Kubernetes in 2022

The Panic Was Real. Now Let's Fix the Infrastructure.

If you were working in DevOps during December 2021, you didn't sleep much. Log4Shell (CVE-2021-44228) wasn't just another vulnerability; it was a systemic failure of trust. We trusted libraries. We trusted default configurations. We trusted that isolation mechanisms would hold. For many, they didn't.

I saw production clusters in Oslo grind to a halt—not because of the exploit itself, but because the mitigation scanners saturated the I/O of cheap, shared hosting environments. That’s a failure of architecture.

It is January 2022. The dust has settled. If you are still running containers as root or neglecting syscall restrictions, you are negligent. Here is how we lock down infrastructure for Norwegian enterprise standards, assuming that the next zero-day is already on the network.

1. The "Non-Root" Mandate

By default, Docker containers run as root. This maps to the root user on the host kernel. If an attacker breaks out of the container (container escape), they own your node. This is not theoretical; exploits like CVE-2019-5736 showed us exactly how runc could be compromised.

Stop writing lazy Dockerfiles. Define a user. Enforce it.

# The Wrong Way
FROM node:16-alpine
WORKDIR /app
COPY . .
CMD ["node", "index.js"]

# The Right Way
FROM node:16-alpine
WORKDIR /app
# Create a group and user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
COPY . .
# Change ownership
RUN chown -R appuser:appgroup /app
# Switch context
USER appuser
CMD ["node", "index.js"]

When you deploy this on CoolVDS, our KVM virtualization adds a hardened layer between your instance kernel and the physical hardware. But inside the VM, you are the captain. Don't let your application run with privileges it doesn't need.

2. Immutable Infrastructure: Read-Only Filesystems

Hackers love to write files. They want to download crypto miners, compile exploits, or modify configuration files. Make their life miserable by making your container filesystem read-only.

Most applications only need to write to specific directories (logs, temp, cache). Mount those as volumes and freeze the rest.

docker run --read-only \
  --tmpfs /run \
  --tmpfs /tmp \
  -v /var/log/app:/var/log/app \
  -p 8080:8080 \
  my-secure-image:latest

If you execute a shell inside this container and try touch /app/hack.sh, it fails immediately. This simple flag eliminates an entire class of persistence vectors.

3. Limiting the Blast Radius: Dropping Capabilities

Linux capabilities divide the privileges of root into distinct units. A web server does not need to modify kernel modules (CAP_SYS_MODULE) or change system time (CAP_SYS_TIME). Yet, Docker grants many of these by default.

Drop everything. Add back only what is strictly necessary. This is the definition of least privilege.

version: '3.8'
services:
  nginx:
    image: nginx:1.21-alpine
    cap_drop:
      - ALL
    cap_add:
      - NET_BIND_SERVICE
      - CHOWN
      - SETGID
      - SETUID
    ports:
      - "80:80"
Pro Tip: If you are unsure which capabilities your app needs, use tools like capsh within a test environment to audit syscall failures. Do not debug in production.

4. Network Policies and the Norway Context

In a Kubernetes cluster, the default behavior is that every pod can talk to every other pod. This is a flat network. If your frontend is compromised, the attacker has a direct line to your backend database.

You must implement a default-deny NetworkPolicy. Whitelist traffic explicitly.

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: default-deny-all
  namespace: default
spec:
  podSelector: {}
  policyTypes:
  - Ingress
  - Egress

The Data Sovereignty Factor

Since the Schrems II ruling in 2020, moving personal data outside the EEA is a legal minefield. The Norwegian Data Protection Authority (Datatilsynet) is watching. When you host containers, the physical location of the CPU matters.

We see developers pushing containers to US-owned cloud giants, ignoring that the CLOUD Act can compel data access. Hosting on CoolVDS ensures your data resides physically in Oslo or nearby European data centers, governed by Norwegian and EU law. It simplifies your GDPR compliance strategy significantly.

5. Kernel Isolation vs. Container Isolation

Containers share a kernel. If a kernel panic occurs in one container, the whole node goes down. This is the "noisy neighbor" problem on steroids.

For critical workloads, we don't rely solely on namespaces and cgroups. We use CoolVDS NVMe instances because they run on KVM (Kernel-based Virtual Machine). Each VDS has its own kernel.

Feature Shared Container Hosting CoolVDS (KVM)
Kernel Isolation Shared (Weak) Dedicated (Strong)
I/O Performance Unpredictable Dedicated NVMe
Security Vulnerable to Escapes Hardware-assisted Virt

Conclusion: Security is Latency's Twin

Security scanners, encryption overhead, and rigorous logging consume CPU cycles. If your underlying infrastructure is slow, your secure application becomes unusable. I've seen security agents add 200ms of latency simply because the disk I/O couldn't keep up with the logs.

Don't compromise. Lock down your Dockerfiles, restrict your syscalls, and run them on metal that respects your need for speed and sovereignty.

Ready to harden your stack? Spin up a CoolVDS NVMe instance in Oslo today. Total isolation, zero excuses.