Catégorie : Divers (Page 1 of 62)

User Namespaces in Kubernetes: Perspectives on Isolation and Escape

User Namespaces in Kubernetes are designed to improve pod isolation by mapping container users to non-root UIDs on the host. While they offer a promising sandboxing mechanism, their security implications are nuanced. For offensive security practitioners, understanding how user namespaces work opens doors to assess potential privilege escalation, misconfigurations, and runtime escape attempts in hardened clusters.


What Are Kubernetes User Namespaces?

In traditional Kubernetes setups, containers often run as root (UID 0), which also maps to root on the host unless otherwise restricted (e.g., with seccomp, AppArmor, or dropping capabilities). With User Namespaces, UID 0 inside the container can be mapped to a non-root UID (e.g., 100000) on the host, drastically reducing the risk of container breakout.

Core Concept:

Container UIDMapped Host UID
0100000
1100001
1000101000

This mapping isolates privilege levels, ensuring that root inside the container ≠ root on the host.


Offensive Security Perspective: Attack Surface & Evasion Tactics

Despite the promise of tighter isolation, user namespaces introduce complexity that can be exploited or abused if not configured properly. Let’s analyze common offensive scenarios.


1. Privilege Escalation via Misconfigured Mappings

If the UID/GID mappings are too broad, or improperly configured (e.g., overlapping ranges), an attacker could potentially:

  • Access sensitive host resources via mapped UIDs.
  • Use remapped file permissions to exploit volume mounts (e.g., hostPath or PVCs).
  • Abuse misaligned subuid/subgid ranges to escalate outside the intended sandbox.

Example Attack:

bashCopyEdit# Container UID 0 maps to Host UID 100000
# But /data is mounted with files owned by Host UID 100000
cat /data/secrets.txt

Result: UID 0 inside the container has effective access to host-owned files, violating isolation.


2. Kernel Exploits Inside Namespaces

Even with UID remapping, the container shares the kernel. User namespaces do not prevent kernel-level exploits such as:

  • DirtyPipe (CVE-2022-0847)
  • Dirty COW (CVE-2016-5195)
  • StackRot (CVE-2023-3269)

Red Team Tactic:
If CAP_SYS_ADMIN is not dropped, or seccomp filters are lax, you can test kernel exploits inside user namespaces with minimal detection due to reduced apparent privileges.

# Run DirtyPipe exploit inside a user-namespaced container
./dirtypipe /etc/passwd "root::0:0:root:/root:/bin/bash\n"

3. Anti-Forensics & Evasion with Mapped UIDs

User namespaces make detection more complex from a blue team’s perspective:

  • Logs might show actions from UID 100000+ on the host instead of UID 0.
  • Traditional forensic tooling might miss attribution of malicious activity if unaware of the mapping.

Example:

bashCopyEdit# From container: creates a backdoor as UID 0
echo "malicious_user:x:0:0::/root:/bin/bash" >> /etc/passwd

On host, this action appears as being made by UID 100000 — not obviously suspicious unless correlated with namespace mappings.


4. Side-channel and Shared Resource Attacks

Even with user namespaces, shared resources can become attack vectors:

  • cgroups/proc, and /sys access
  • Spectre/Meltdown-style attacks
  • CPU time, memory pressure side channels

Tactic:
Use PID or mount namespace escape primitives combined with user namespace to test access to host-level interfaces. For example:

lsns -t user,pid

If misconfigured, you may be able to observe or interfere with host-level processes.


What Doesn’t Work (Defense Successes)

User namespaces offer strong mitigations against:

ThreatMitigated by User Namespaces
Direct host root access
Access to host UID 0 files
CAP_SYS_ADMIN container use✅ (if dropped)
AppArmor/SELinux bypass✅ (if enforced properly)

However, they do not protect against:

  • Kernel-level vulnerabilities
  • Volume mount misconfigurations
  • Lax seccomp/bpf policies
  • Insufficient container runtime restrictions (e.g., allowing --privileged)

Offensive Testing Setup

You can simulate a user namespace-enabled cluster using:

yamlCopyEditapiVersion: v1
kind: Pod
metadata:
  name: userns-test
spec:
  securityContext:
    runAsUser: 0
    runAsGroup: 0
    seccompProfile:
      type: RuntimeDefault
  runtimeClassName: "userns"
  containers:
  - name: test
    image: alpine
    command: ["/bin/sh", "-c", "id && sleep 3600"]

Check the UID mappings inside the container:

cat /proc/self/uid_map

Use host PID or mount checks to assess boundary enforcement.


How to Defend Against Offense

Defense LayerBest Practices
UID/GID MappingUse minimal, non-overlapping ranges (subuidsubgid)
CapabilitiesDrop all except required ones (especially CAP_SYS_ADMIN)
SeccompEnforce strict syscall profiles (RuntimeDefaultCustom)
Volume ManagementAvoid hostPath; use projected volumes or CSI
RuntimeClass EnforcementUse PodSecurityAdmission or Kyverno/Gatekeeper to enforce runtimeClassName

Conclusion

While User Namespaces are a powerful isolation primitive in Kubernetes, they’re not a silver bullet. Offensive security testing shows that, when misconfigured or poorly integrated with other controls, user namespaces can be subverted or bypassed. A layered defense including syscall filtering, strict capability drops, and forensic visibility tooling — is essential.

If you’re building hardened Kubernetes platforms, test user namespaces like an attacker. Simulate kernel exploits, map UID collisions, and validate how well the telemetry captures identity mappings.

From Vision to Stage: My KubeCon Europe 2025 Experience in London, UK

Just over a year ago, I told my team that I wanted to speak at a future KubeCon. No roadmap. No CFP draft. Just a bold intention. Fast forward to April 2025, I stood on stage in London at KubeCon + CloudNativeCon Europe—sharing our security journey in front of the most vibrant, forward-thinking community in tech. It wasn’t just a milestone. It was a personal and professional transformation.

The Talk: “Platform Engineering Loves Security: Shift Down, Not Just Left!”

Co-presenting with my friend and co-speaker Mathieu, we delivered a talk that challenged the traditional “shift left” security narrative. Instead, we proposed a more pragmatic, scalable approach: “shift down into the platform, not left to your developers« .

We walked through real-world lessons from the trenches—how platform teams can embed security guardrails by design, without burning out developers or slowing delivery. We covered:

  • Real Kubernetes policy enforcement stories using OPA and Gatekeeper
  • Building paved roads for secure service onboarding
  • Why platform ownership is the missing link in cloud-native security

The feedback? Incredible. Thoughtful questions, packed room, and lots of “this is exactly what we’re facing” conversations afterward.

What Made This KubeCon Special

Every KubeCon is filled with energy, but London felt different. Maybe it was the hallway track filled with impromptu deep dives. Maybe it was the sheer volume of conversations around AI governance, multi-tenancy security, and platform responsibility.

I connected with other CNCF community leaders, fellow Microsoft MVPs, and members of the Kubernetes Security Special Interest Group (SIG) and TAG Security. We exchanged ideas on how to improve secure defaults in open source tooling and keep up with the ever-changing threat landscape.

Must-Watch Sessions

From Open Source to Open Conversations

What really makes KubeCon unforgettable isn’t just the sessions—it’s the people. Meeting folks I’ve only known online, reuniting with past collaborators, mentoring first-time attendees, and exchanging stories over coffee.

One of the standout moments this year was meeting some of the very first Golden Kubestronauts—like Sajeeva Nambadawa Vithanage. This new CNCF initiative celebrates individuals who not only achieve all CNCF certifications but also exemplify community leadership, collaboration, and a deep commitment to cloud-native innovation.

It reminded me why I care so deeply about this space: we’re not just building systems—we’re building a movement. One where security, collaboration, and open source values are not just buzzwords, but guiding principles.

✈️ What’s Next?

Coming back from KubeCon, I’m more motivated than ever:

  • To continue pushing for technical leadership recognition in security roles.
  • To help more teams adopt platform-centric security thinking.
  • To mentor others chasing their first KubeCon CFP.

And maybe… to start planning for KubeCon North America?


Whether you’re just starting out or deep into your cloud-native journey, I can’t recommend attending (or speaking at!) a KubeCon enough. It’s more than a conference—it’s a catalyst.

Let’s keep raising the bar. Together.

Maxime.

KubeCon NA 2024: Exploring the Future of Cloud Native with WASM, Platform Engineering, and Security

Hi!

KubeCon + CloudNativeCon North America 2024 in Salt Lake City was an incredible gathering of the cloud-native community. This year, three key trends stood out: WebAssembly (WASM)Platform Engineering, and Security. Here’s a day-by-day recap of my experience, culminating in reflections on the most significant themes shaping the future of Kubernetes and cloud-native development.

Sunday & Monday: Cloud Native Rejekts

Before the main event, I had the honor of speaking at Cloud Native Rejekts with Mathieu Benoit. Our session, Platform Engineering Loves Security: Shift Down to Your Platform, Not Left to Your Developers, explored the intersection of platform engineering and security. We discussed how embedding security within platforms can free developers to focus on innovation without compromising compliance.

Watch the session here: Platform Engineering Loves Security: Shift Down to Your Platform, not Left to Your Developers!

Rejekts set the stage perfectly, with many experimental ideas and deep community discussions.

Must-Watch Sessions

Tuesday: Microsoft AKS Pre-Day

Tuesday was all about the AKS Pre-Day, hosted by Microsoft. The sessions delivered an in-depth look at the Azure Kubernetes Service (AKS) roadmap, featuring advanced scaling strategies, seamless CI/CD integrations, and innovative security enhancements. Beyond the technical insights, the day highlighted Microsoft’s dedication to creating a Kubernetes platform that prioritizes developer experience and operational excellence. It also provided a fantastic opportunity to connect with fellow Microsoft MVPs, exchange ideas, and foster a stronger sense of community within the ecosystem.

Wednesday–Friday: KubeCon + CloudNativeCon NA 2024

Trend 1: WebAssembly (WASM) Rising

WASM was one of the most discussed topics, emphasizing its potential to revolutionize how workloads are run in Kubernetes environments.

  • Session HighlightMulti-Tier Security in WasmCloud by Bailey Townsend. This session showcased how WASM enables lightweight, secure, and portable applications, offering new ways to scale and secure workloads.
  • WASM’s ability to provide isolation and reduced resource consumption positions it as a key technology for the future.

Trend 2: Platform Engineering Evolution

Platform engineering emerged as a linchpin for organizations striving to empower developers while maintaining operational excellence.

Trend 3: Security Takes Center Stage

Security remained a top priority at KubeCon NA 2024, with a strong focus on automation, proactive measures, and practical solutions for real-world challenges. The conversation highlighted the need to embed security seamlessly into Kubernetes workflows to protect workloads without stifling innovation.

  • Session HighlighteBPF for Creating Least Privileged Policies by Natalia Reka Ivanko and John Fastabend. This session offered a comprehensive look at leveraging eBPF to dynamically enforce least-privilege policies, showcasing its potential to enhance runtime security.
  • Session HighlightWhy Perfect Compliance Is the Enemy of Good Kubernetes Security by Michele Chubirka, Google. This insightful talk emphasized balancing security best practices with operational realities, underscoring that striving for “perfect compliance” can sometimes hinder overall security effectiveness.
  • Session HighlightWorking Together to Improve Security Visibility in Kubernetes by Rita Zhang and Jeremy Rickard. The session explored collaborative strategies for improving observability and addressing blind spots in Kubernetes environments.

Other notable mentions included:

This year’s sessions reinforced the importance of adopting tools and strategies that make Kubernetes security not just robust but also manageable and scalable for teams of all sizes.

Must-Watch Sessions

Here are a few other standout sessions:

Final Thoughts

KubeCon NA 2024 showcased the incredible maturity and innovation of the cloud-native community. The rise of WASM, the growing influence of platform engineering, and the unwavering focus on security point to an exciting future where collaboration, creativity, and cutting-edge technology drive the ecosystem forward.

Looking ahead, I’m excited to see how these trends evolve and shape the next wave of cloud-native advancements. Mark your calendars for KubeCon + CloudNativeCon Europe 2025 in London this April — let’s continue the conversation and innovation there!

Maxime.

« Older posts

© 2025 ZiGMaX IT Blog

Theme by Anders NorenUp ↑