TLS Certificate Pinning & Token Authentication¶
StackPilot secures all communication between the Central Hub and remote Host Agents using cryptographic certificate pinning and rotating bearer tokens.
1. Dual-Phase Host Enrollment Flow¶
2. Pinned CA Verification¶
When the Central Hub operates over HTTPS:
1. The Hub's public TLS certificate is embedded directly into the installer script dynamically.
2. All download operations (curl) and Python API calls (urllib.request) enforce --cacert verification against the embedded CA certificate.
3. This prevents active adversary MitM attacks on local networks during initial node onboarding.
The initial command that downloads the installer also verifies TLS. It uses the operating-system trust store and never adds curl -k. A Hub using a private or self-signed certificate must therefore be accessed through a trusted reverse proxy, have its CA installed on the target host, or be downloaded with an explicitly supplied --cacert /path/to/hub-ca.pem option obtained through a separate trusted channel.
3. Token Storage & Permissions¶
- Agent Host: The runtime bearer token is written exclusively to
~/.stackpilot_agent_tokenwith strict permissions: - Central Hub: Stored in
~/.config/stackpilot/agent-tokens.json(also permissions0600). - Rotation: Tokens can be rotated at any time from the Hub's host settings without restarting host containers.
4. Agent Listener Security¶
The agent fails closed if its TLS certificate or private key cannot be created, read, or loaded. It does not silently expose the management API over plaintext HTTP.
Installed services set these defaults explicitly:
STACKPILOT_AGENT_BIND may be set to a specific management-interface address to reduce network exposure.
Plain HTTP is available only for local development by setting STACKPILOT_AGENT_ALLOW_INSECURE_HTTP=true. In that mode, the agent accepts only a loopback bind address such as 127.0.0.1 or ::1; it refuses to start if configured on a non-loopback address.