Uncategorized

My homelab’s zero-trust edge: Cloudflare Access + Authentik + YubiKey + Cloudflared (PVE stays private via Tailscale)

Building a Zero-Trust Homelab: A Real-World Example

As someone who designs zero-trust security architectures for a living, I decided to create a similar setup for my homelab. In this post, I’ll share my journey of building a zero-trust edge using Cloudflare Access, Authentik, YubiKey, and Cloudflared, with a focus on simplicity and security.

Goals and Motivation

I wanted to achieve a few key goals with my homelab setup: zero-trust at the edge, hardware-backed authentication, no open inbound ports, separate public and admin paths, and first-class internal TLS. I also aimed to keep the setup simple to operate and maintain.

High-Level Architecture

My setup consists of several components: Cloudflare Access, Authentik, YubiKey, Cloudflared, and Tailscale. Cloudflare Access provides DNS, WAF, and zero-trust access, while Authentik serves as the identity provider (IdP) with WebAuthn and YubiKey enforcement. Cloudflared creates an outbound tunnel from a small VM inside my LAN, eliminating the need for inbound NAT. Tailscale provides a private overlay for admin-only services.

Request Flows and Architecture

When a public user tries to access a service like Pi-hole, the request flows through Cloudflare Edge, which evaluates the policy and challenges the user with OIDC. Authentik then prompts the user for WebAuthn (YubiKey) or OTP, and returns a token to Access. The session is then injected and forwarded through the Cloudflared tunnel to the LAN.

Admin User Flow

For admin users, the flow is different. They connect to Tailscale, which provides access to internal services like Proxmox VE and Proxmox Backup Server. These services are not exposed to the public internet and are only accessible via Tailscale.

Edge Hardening and Security Measures

To harden my edge, I’ve implemented several security measures, including segmentation (VLANs), inter-VLAN policy, and WAN edge protection. I’ve also set up DNS egress control, IPS/IDS, and DoS protections. Additionally, I’ve disabled UPnP and DHCP guard to prevent unauthorized access.

Tooling and Software

I’m using a range of tools and software to manage my homelab, including Cloudflare DNS, Cloudflare Tunnel, Cloudflare Access, Authentik, YubiKey, Tailscale, and Caddy. I’ve also set up a private PKI using step-ca to issue internal server certificates.

What This Setup Buys You

This setup provides several benefits, including a reduced attack surface, protection against phishing and credential theft, and simplicity of operation. It also provides resilience, with public logins pausing if Authentik is down, and admin access still available via Tailscale.

What I’d Improve Next

There are a few areas I’d like to improve in the future, including adding client-cert (mTLS) at the edge, setting up SIEM hooks for Access/IdP logs, and implementing service posture checks.

Conclusion

In conclusion, building a zero-trust homelab requires careful planning and execution. By using a combination of Cloudflare Access, Authentik, YubiKey, and Cloudflared, I’ve created a secure and simple setup that meets my needs. I hope this post has provided a useful example of how to build a zero-trust edge and has inspired you to take steps to secure your own homelab.

Budowanie zero-trust homelabu: przykład z życia

Jako osoba, która projektuje architektury bezpieczeństwa zero-trust dla dużych firm, postanowiłem stworzyć podobny system dla swojego homelabu. W tym poście opiszę moją podróż budowania zero-trust edge przy użyciu Cloudflare Access, Authentik, YubiKey i Cloudflared, z naciskiem na prostotę i bezpieczeństwo.

Cele i motywacja

Chciałem osiągnąć kilka kluczowych celów z moim setupem homelabu: zero-trust na krawędzi, uwierzytelnianie oparte na sprzęcie, brak otwartych portów wejściowych, oddzielne ścieżki publiczne i administracyjne oraz pierwszorzędne wewnętrzne TLS. Chciałem również utrzymać setup w prosty sposób, aby był łatwy w obsłudze i utrzymaniu.

Architektura na wysokim poziomie

Mój setup składa się z kilku komponentów: Cloudflare Access, Authentik, YubiKey, Cloudflared i Tailscale. Cloudflare Access zapewnia DNS, WAF i dostęp zero-trust, podczas gdy Authentik służy jako dostawca tożsamości (IdP) z WebAuthn i YubiKey. Cloudflared tworzy tunele wychodzące z małej maszyny wirtualnej wewnątrz mojej sieci LAN, eliminując potrzebę NAT wejściowego. Tailscale zapewnia prywatną warstwę dla usług administracyjnych.

Przepływy żądań i architektura

Gdy użytkownik publiczny próbuje uzyskać dostęp do usługi, takiej jak Pi-hole, żądanie przepływa przez Cloudflare Edge, który ocenia politykę i wyzywa użytkownika do OIDC. Authentik następnie wyświetla monit o WebAuthn (YubiKey) lub OTP i zwraca token do Access. Sesja jest następnie wstrzykiwana i przekazywana przez tunele Cloudflared do sieci LAN.

Przepływ użytkownika administracyjnego

Dla użytkowników administracyjnych przepływ jest inny. Łączą się oni z Tailscale, który zapewnia dostęp do usług wewnętrznych, takich jak Proxmox VE i Proxmox Backup Server. Usługi te nie są narażone na publiczny Internet i są dostępne tylko za pośrednictwem Tailscale.

Zabezpieczenia krawędzi i środki bezpieczeństwa

Aby zabezpieczyć moją krawędź, wdrożyłem kilka środków bezpieczeństwa, w tym segmentację (VLAN), politykę między VLAN, ochronę krawędzi WAN, kontrolę wyjścia DNS, IPS/IDS i ochronę przed atakami typu DoS. Dodatkowo, wyłączyłem UPnP i DHCP, aby zapobiec nieautoryzowanemu dostępowi.

Narzędzia i oprogramowanie

Używam różnych narzędzi i oprogramowania do zarządzania moim homelabem, w tym Cloudflare DNS, Cloudflare Tunnel, Cloudflare Access, Authentik, YubiKey, Tailscale i Caddy. Ustawiam również prywatną infrastrukturę kluczy (PKI) przy użyciu step-ca, aby wydawać wewnętrzne certyfikaty serwerowe.

Co ten setup daje

Ten setup zapewnia kilka korzyści, w tym zmniejszenie powierzchni ataku, ochronę przed phishingiem i kradzieżą poświadczeń oraz prostotę obsługi. Zapewnia również odporność, z publicznymi logowaniami, które zatrzymują się, jeśli Authentik jest niedostępny, a dostęp administracyjny nadal jest dostępny za pośrednictwem Tailscale.

Co można poprawić

Jest kilka obszarów, które chciałbym poprawić w przyszłości, w tym dodanie certyfikatu klienta (mTLS) na krawędzi, ustawienie haków SIEM dla logów Access/IdP oraz wdrożenie kontroli postawy usługi.

Podsumowanie

Podsumowując, budowanie zero-trust homelabu wymaga starannego planowania i wykonania. Korzystając z kombinacji Cloudflare Access, Authentik, YubiKey i Cloudflared, stworzyłem bezpieczny i prosty setup, który spełnia moje potrzeby. Mam nadzieję, że ten post dostarczył przydatnego przykładu, jak zbudować zero-trust edge i zainspirował Cię do podjęcia kroków w celu zabezpieczenia własnego homelabu.

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Appliance - Powered by TurnKey Linux