Security Architecture & Threat Model¶
StackPilot manages security-sensitive container infrastructure across multiple Linux nodes. This document defines the threat model, primary assets, and defensive mitigations; it does not replace host hardening or deployment-specific risk assessment.
1. Threat Model Diagram¶
flowchart TD
attacker["Potential adversary\nMitM, injection, traversal"]
proxy["Reverse proxy and forward auth\nTraefik, Caddy, Nginx, Authentik, Authelia"]
hub["StackPilot Hub\nCSP, CSRF protection, RBAC, scoped tokens"]
agent["StackPilot agent\nPinned TLS and managed-path controls"]
systemd["systemd user services\nRootless workload execution"]
attacker -. "Blocked by CSP and CSRF" .-> proxy
proxy -->|"Trusted proxy identity headers"| hub
hub <-->|"Pinned TLS and agent token"| agent
agent <--> systemd
2. Asset Classification & Defense Controls¶
Host Root Integrity¶
- Risk: Container breakout leads to full root control of the host machine.
- Defense: Rootless user namespaces (UID mapping). The container process running as UID 0 inside the container maps to an unprivileged host UID (e.g. 100000+). No root Docker daemon is required.
Host Filesystem Protection¶
- Risk: Malicious path parameters (
../../etc/shadowor../../.ssh/id_rsa). - Defense: Canonical path resolution via
os.path.realpath. Requests attempting to read or write files outside configured stack directories are terminated immediately with403 Path Traversal Prohibited.
Web Dashboard & Session Security¶
- Risk: Cross-Site Scripting (XSS), Cross-Site Request Forgery (CSRF), clickjacking.
- Defense:
- Dynamic Content Security Policy (CSP) with unique cryptographic nonces per request.
- Double-submit signed CSRF cookies (
csrf-csrf). X-Frame-Options: DENYvia Helmet.- Strict input sanitization and dynamic DOM updates via
.textContent.
Host Communications & Agent Impersonation¶
- Risk: Rogue agents registering with the Hub or Man-in-the-Middle eavesdropping.
- Defense: Pinned TLS CA certificates, SHA-256 TLS cert fingerprint registration during onboarding, and rotating
X-Agent-Tokenbearer credentials with0600permissions.