- Update docs/appctl.md to cover core_manifest.py, Schema v1.0, Class A/B source provenance, and two-axis status output. - Align docs/architecture.md, docs/secrets-and-state.md, and docs/operations.md with P1 mail topology (Stalwart on smtp.<domain>, SnappyMail in ~/Sites, workload state under ~/var/lib/homelab/<app>/). - Remove external vault path references from docs/decisions/README.md and scrub remaining personal domains/usernames across docs/ and SECURITY.md. - Extend platform genericism security invariant test to guard docs/ and root markdown/flake files.
3.4 KiB
3.4 KiB
🛡️ Homelab Core — Security Controls & Hardening
This document outlines the security controls, container isolation rules, and operational boundaries implemented in Homelab Core.
1. Implemented Security Controls
A. Docker Socket Isolation (socket-proxy)
- Direct container mounts of
/var/run/docker.sockare restricted. - Only the dedicated
socket-proxycontainer mounts/var/run/docker.sock:ro. - State-modifying and execution API endpoints are disabled in HAProxy (
POST=0,DELETE=0,BUILD=0,EXEC=0,COMMIT=0,CONFIGS=0,DISTRIBUTION=0,NODES=0,PLUGINS=0,SECRETS=0,SWARM=0,SYSTEM=0). - Traefik and Dozzle query Docker metrics and metadata via
tcp://socket-proxy:2375rather than direct socket mounts.
B. Identity & Access Management (lldap & authelia)
- Directory Service: User accounts and group memberships are stored in LLDAP (
users.${HOMELAB_DOMAIN}). - ForwardAuth: Traefik intercepts incoming HTTP/HTTPS requests and validates sessions with Authelia (
auth.${HOMELAB_DOMAIN}) before routing to protected backends. - MFA Support: Supports TOTP and FIDO2 authentication.
C. Network Segmentation
proxy-net: Bridge network connecting Traefik to backend application containers.socket-net: Restricted bridge network connecting infrastructure daemons tosocket-proxy. Workload applications in~/Sitesare not attached tosocket-net.
D. Webhook Admission Controls
- HMAC-SHA256 Signatures: Webhook requests are verified using
hmac.compare_digestagainst/run/secrets/gitops/webhook_secret. - Trusted Name Resolution: Webhook payloads specify logical repository names; filesystem path traversal (
..,/) and symlink escapes are rejected. - Non-Shell Execution: Deployment commands execute as fixed argument lists without
shell=True. Custom shell commands fail validation closed. - Revision-Consistent Validation: Manifest deployment policy is re-validated directly on the deployed commit immediately post-pull.
E. Declarative Secrets Encryption (sops-nix)
- Secrets are stored encrypted in
nixos/secrets.yamlusing Age keys derived from the host SSH key (/etc/ssh/ssh_host_ed25519_key). - Decrypted secrets reside in RAM-backed ephemeral filesystems (
/run/secrets/,/run/credentials/) and are not committed to unencrypted persistent files.
2. Threat Model & Operational Considerations
Host Access
- SSH root login is disabled (
PermitRootLogin = "no"). Access is authenticated via ED25519 public keys. - Unneeded services (such as printing, bluetooth, sleep/suspend targets) are disabled at the NixOS configuration level.
ACME Certificates
- Let's Encrypt keys in
config/letsencrypt/acme.jsonare maintained with mode0600.
Workload Containment
- Applications run in dedicated containers attached to
proxy-net. - Application manifests cannot request arbitrary host commands through the GitOps engine.
3. Verification Checklist
- Secrets encrypted in
nixos/secrets.yamlvia Age / SOPS. - User identities managed in LLDAP (
users.${HOMELAB_DOMAIN}). socket-proxyconfigured withPOST=0,DELETE=0,BUILD=0,EXEC=0.- Webhook HMAC signature verification active on port 9000.
- Invariant test runner (
./scripts/test) passing on changes. config/letsencrypt/acme.jsonpermissions set to0600.- Host firewall ports restricted to declared services in
nixos/modules/homeserver.nix.