Agent Communication Security
How the agent communicates securely with the central server.
Transport Security
All agent-to-server communication uses HTTPS/TLS:
- The agent uses the
requestslibrary withverify=True(certificate validation enabled) - Request timeout: 15 seconds
- Self-signed certificates can be used by placing the CA cert in the
certs/directory
Authentication
Every authenticated request includes three headers:
X-API-Key— 48-byte URL-safe token (generated during enrollment)X-Device-ID— Device UUIDX-Agent-Version— Agent software version
API Key Security
- Keys are generated using
secrets.token_urlsafe(48)(cryptographically secure) - The plaintext key is returned to the agent only once during enrollment
- The server stores a SHA-256 hash — the plaintext is never stored
- Lost keys cannot be recovered; the device must be re-enrolled
- Retired devices have their keys invalidated (API returns 403)
Offline Resilience
When the server is unreachable:
- The agent sets
offline_mode = True - Policy enforcement continues using the last-known
policy.json - Alerts are queued to disk in the
queue/directory - When connectivity resumes, queued alerts are pushed in batches of up to 50
- The heartbeat cycle retries every 60 seconds
Request Validation
The server validates on every request:
X-API-Keyheader is presentX-Device-IDheader is present- Device exists in the database
- SHA-256 hash of the provided key matches the stored hash
- Device status is not
retired