# Security Overview

> How the platform is built for security, for a customer's security review: privileges at runtime, containers and GPUs, network exposure, credentials, vulnerability handling, backups, logs and the supply chain; what is in place in this release and what is not yet.

How the platform's two parts are built for security, written to answer the questions a
customer's security review asks: privileges, containers, vulnerability handling, backups,
logs and the supply chain. Each statement describes the current release and is checked
against the code it names. Where something is not in place yet, this document says so; it
promises nothing that is not delivered.

> No privileged containers. This is enforced: the inference node's own service cannot
> create a container with privileges, added capabilities, host namespaces or host mounts,
> even if it is compromised. Root is kept by a few small programs with one job each and
> named below: three on an inference node (`container-admission-control`,
> `collect-machine-identity`, `update-root-programs`) and two on the control plane's
> machine (`container-admission-control`, `directory-preparation`). Every other process
> runs as an unprivileged user.

## Deployment model

- The platform has two parts. The **control plane** (the web pages, the API, MCP and the
  records) runs as a Docker Compose deployment on one machine. Each **inference node**
  (a machine with GPUs) runs the inference node's service under systemd (launchd on
  macOS) and starts model containers through Docker, or model engines as processes.
- Kubernetes is not required and not used. Questions about service accounts, RBAC and
  pod security map onto the platform as described below: an unprivileged service account
  in place of a pod's service account, a proxy that checks every Docker request in place
  of RBAC and Pod Security admission.
- Each part has its own program: `onprem-ai-ctl` installs, updates and removes the
  control plane; `onprem-ai-node` installs, updates and removes an inference node.

## Privileged access at install

- The one-line installer (`curl -fsSL https://get.onprem.ai/platform | sh`)
  starts as the operator's user. The argument checks, the release lookup, the downloads
  and the digest checks run without root (`release/install.sh`).
- Root is used only for the steps the installer's notice names: `onprem-ai-ctl install`
  and `onprem-ai-ctl join-token` for the control plane (later, on the machine, also
  `start`, `stop`, `restart`, `status`, `update`, `doctor` and `uninstall`, because only
  root reaches the container engine), `onprem-ai-node install` and
  `onprem-ai-node uninstall` for an inference node. Before them, the installer prints
  what it installs as root and why, and starts all of them with one `sudo` call. The
  installer does not use `sudo -E`: the proxy settings go to the programs as options.
- The programs run as root are not run from the operator's directory. As root, the
  installer copies each one into a root-owned temporary directory, checks its digest
  against the release manifest again, and runs that copy, so no process of the
  operator's user can replace a program after its check.
- Run as root already (`| sudo sh`, cloud-init, CI), the installer calls no `sudo`.
  With no terminal and no root, it tries `sudo -n` and stops with the instruction to run
  it as root when that fails. With no `sudo` on the machine, it stops and says so.

## Privileged access at runtime

**On an inference node** (Linux):

- The inference node's service runs as its own unprivileged account (`onprem-ai`), not as
  root. Its unit hardens the service with `ProtectSystem=full`
  (`planes/inference/lifecycle-manager/internal/installer/service.go`). The account owns
  only the node's own directories (`docs/architecture/inference-node-file-layout.md`).
- The account is not in the `docker` group and never holds the Docker socket.
- The account is in the `systemd-journal` group (`SupplementaryGroups=` of its unit,
  where the machine has the group): it reads the system journal, every service's log
  lines included, so its error reports can carry the kernel's lines of a restart and
  of a replica killed for lack of RAM. It writes nothing there. What it reads into an
  error report is redacted like its other logs.
- A root oneshot unit, `onprem-ai-crash-kernel-log.service`, copies the end of the
  newest kdump kernel log (root's, mode 0600) into `/run/onprem-ai` for the account's
  group before every start of the node. It runs `/bin/sh` with the script in the unit,
  reads only `/var/crash` and writes only `/run/onprem-ai`.
- Four small programs run as root, each with one job
  (`/opt/onprem-ai/libexec/`, written only by root):
  1. **`container-admission-control`**: the node's only path to Docker. It forwards an allowlist of
     operations (no `exec`, no image build, no administration of the daemon) and checks
     every container and network it creates against the shape the node sends, field by
     field (`planes/inference/container-admission-control/admission.go`): no privileged mode, no added
     capabilities or security options, no host network, PID, IPC, UTS, user or cgroup
     namespace, no devices other than GPUs, ports bound to the loopback address only,
     bind mounts only of paths the service account owns, outside the machine's system
     trees, never a socket, an OOM score adjustment only from 0 to 1000 (a container
     can make itself the kernel's first choice when memory runs out, never shield itself),
     and no supplementary group but `onprem-ai-readers`, by the id the machine gives it.
     A field the node never sends is refused by name.
  2. **`collect-machine-identity`**: reads the machine identity facts only root may read
     (serial numbers, the TPM's public key) once at every boot, and writes them where
     the service reads them.
  3. **`directory-preparation`**: prepares the model weights directory an operator
     moves from the control plane, when the service requests it, and nothing else
     (`planes/inference/directory-preparation`). The request names one path; root gives
     the account only a directory it creates, one the account owns already, or the
     empty top directory of a mounted disk, never another account's data or an
     existing directory of the machine's own, and records the directory's SELinux
     label rule. It refuses the machine's system trees (the same list the container
     admission control refuses to mount), a link anywhere on the path, and a path
     through another account's directory; every path component is opened relative to
     the one before and never through a link. Before every start of the node it also
     prepares the directories the node's containers read, inside the node's data
     directory: the service account's and the group `onprem-ai-readers`'s, 2750, with
     what the account owns inside made group-readable (never writable by the group,
     never readable by others, never the replicas' env files). The group has no
     members; the node adds it to its containers, so a container reads the files it is
     given whatever user its image runs as, and no other user of the machine reads
     model weights.
  4. **`update-root-programs`**: replaces `container-admission-control`, `directory-preparation` and
     itself from a verified release and rewrites the units of the services that run as
     root, when the service requests it, and nothing else. `collect-machine-identity` is
     written by the installer, not carried by a release.
- Installing, updating the root programs and uninstalling need root; everything an
  operator does after the install (deploying models, updates, diagnostics) runs as the
  unprivileged account, from the control plane.

**On the control plane's machine:**

- Every service of the control plane names the user it runs as in the release's compose
  file, and none of them is root but the two below: uid 1000 for the backend, the API
  gateway, the certificate writer, the inference node endpoint, the address detector,
  the edge proxy, the object storage, the metrics store, its alerting and Alertmanager;
  `nobody` for the update-sidecar; the database (70) and Redis (999) as their images'
  own users. No service is privileged, and none but the two below has an added
  capability. The release refuses a compose file in which a service names no user or
  another service is root (`planes/control/deploy/render-compose.sh`).
- The edge proxy binds the two published ports without root and without a capability:
  its own network namespace lets every user bind every port
  (`net.ipv4.ip_unprivileged_port_start=0`), which reaches nothing outside the container.
- Two small containers run as root, each with one job:
  1. **`container-admission-control`**: the one container with the container engine's
     socket. It answers its own small vocabulary and creates exactly one kind of
     container, the update job, writing the container's description itself: never a
     description a caller sent (`planes/inference/container-admission-control/updatejob.go`).
  2. **`directory-preparation`**: at every start, before the services that use them, it
     creates the directories the unprivileged services need and gives them their owner,
     mode and SELinux label, from the list the release ships
     (`planes/control/deploy/directory-preparation.list`), then exits. It has no network,
     every capability dropped but `CHOWN`, `DAC_OVERRIDE` and `FOWNER`, and
     `no-new-privileges`; it acts only inside the folders the compose file hands it,
     never deletes or moves anything, never follows a symbolic link, and inside a
     directory changes at most the owner, for a data volume the list marks
     (`planes/inference/directory-preparation`, its `control-plane` policy; the
     program imports only the Go standard library).
- One program runs as root on the host, outside the containers: the keeper,
  `onprem-ai-ctl run`, run by the systemd unit `onprem-ai-control-plane.service` that
  `onprem-ai-ctl install` and `start` enable (with `onprem-ai-control-plane-shutdown.service`,
  which only stops the services in order at shutdown). It starts the installed release at boot,
  starts again a service that is missing or stopped, and restarts a stateless service
  that stays unhealthy; it reports the stateful ones instead. It talks to the container
  engine only through the control plane's own stack (the compose project of the
  installed release), downloads nothing, changes no configuration, and holds the same
  lock as an update, so it never acts while one runs. The unit runs with
  `ProtectSystem=strict` (it writes only the install directory), `PrivateTmp` and
  `NoNewPrivileges` (`planes/control/ctl/internal/controlplane/unit.go`).
- The update job, which replaces the control plane with a new release, runs with every
  capability dropped but `CHOWN`, `DAC_OVERRIDE` and `FOWNER` (needed to write root's
  secrets directory and give a new secret to the user that reads it) and with
  `no-new-privileges`. Its image holds only the `onprem-ai-ctl` program and the Docker
  CLI: no shell, no package manager.
- The container engine runs as root (Docker, or Podman as root), without user
  namespaces: a process that is root inside a container would be root on the machine
  if it escaped, which is why only the two containers above are. Mapping containers to
  an unprivileged range of the machine's user ids is not in place yet.
- Two ports are published: the inference port (443 by default) and the control plane
  port (3443). Nothing else listens on the machine's network.

## Containers and GPUs

- **No container is privileged.** Model containers receive only the GPUs the control
  plane placed on them: through the NVIDIA Container Toolkit (a device request naming
  those GPUs), or AMD's `/dev/kfd` and `/dev/dri`.
- GPU memory is managed by placement, not by privileges: the control plane books each
  replica's memory on the GPUs it assigns (`docs/architecture/gpu-memory-allocation.md`).
- Model containers mount only the inference node's own files: their model weights and the
  deploy profile's files. Every deploy profile in the built-in catalog mounts them
  read-only; a deploy profile may ask for a writable mount, still only of the node's own
  files. Containers publish their ports on the loopback address only; the inference API
  reaches them through the node's outbound connection to the control plane.
- The GPU metrics exporter (NVIDIA DCGM) runs as a container with GPU access, its
  configuration mounted read-only and its port on the loopback address.
- Containers run as their image's own user. Not every model engine image runs as a
  non-root user inside its container; that is not a privilege on the machine (no
  capabilities, no host namespaces), and it is the image publisher's choice.

## Network exposure

- Inference nodes connect out to the control plane; nothing connects in to an inference
  node. Their connection is TLS 1.3 with a certificate per inference node, issued by the
  control plane's own certificate authority at join time
  (`docs/architecture/inference-node-transport.md`, `certificate-management.md`).
- Everything works with plain IP addresses, without DNS
  (`docs/architecture/network-requirements.md`).
- The control plane can present certificates from its own root, or certificates the
  customer provides (`docs/guides/certificates-and-network/provisioned-certificates.md`).

## Data and credentials

- Passwords are stored as Argon2 hashes; control plane API keys as SHA-256 digests (keys
  are random and long, shown once).
- Stored secrets (environment file values, the license key, the root certificate's private
  key) are encrypted with AES-GCM under a key kept outside the database
  (`secrets/config_encryption_key`).
- Where each kind of data lives: `docs/architecture/data-architecture.md`.

## Backup and recovery

- What to back up (the database, the object storage and the secrets together; the metrics
  optional), how to make an application-consistent backup, and how to restore onto the
  same or a new machine: the operator guide
  `docs/guides/machine-administration/backup-and-restore.md`. The procedure was
  run end to end: a backup, a wipe of the control plane, a restore; accounts, keys and
  error report packages came back, and the inference node reconnected without a new join
  token.
- Inference nodes need no backup: what they run is the control plane's record, and their
  model weights download again.
- A test of the restore in the automated machine test: not in place yet.

## Logs and audit

- The audit log records every change made through the control plane, with the account,
  the control plane API key used and the client address.
- The database refuses every change and deletion of an audit record: triggers reject
  UPDATE, DELETE and TRUNCATE of the audit table, for every role and code path
  (`planes/control/backend/migrations/versions/0090_audit_log_insert_only.py`). The
  table's owner could drop the triggers; a separate insert-only database role for the
  control plane and an off-host copy (syslog, SIEM or write-once storage) are
  not in place yet.
- Audit records, operational logs, error reports and metrics are separate streams with
  separate storage: audit records in the database, operational logs in the containers'
  and the service's logs (rotated by Docker and journald), error reports in the database
  and object storage, metrics in VictoriaMetrics. Which failures write an error report is
  configurable (`docs/guides/errors-and-debugging/error-trace-policy.md`). The
  audit log is complete by design and is not filtered.

## Vulnerability management

- How to report a vulnerability: `SECURITY.md`.
- Every dependency is pinned by hash; no version younger than 7 days enters the
  repository, except a fix for a known advisory read by a person (`SECURITY.md`,
  supply-chain policy). `pip-audit`, `govulncheck` and `npm audit` (the libraries the
  web pages run) run on every change, and a known high or critical advisory fails the
  build. The web pages' libraries and their build carry no known advisory of any
  severity; a finding that remains would be listed with its reason in `SECURITY.md`.
- Supported releases, patch times by severity, components we do not build, and how
  customers are told: `SECURITY.md` (Vulnerability handling). In short: the latest
  minor release of the current major is supported, and the previous one for 30 days;
  a fixed release within 14 days for a critical vulnerability (a mitigation within 7),
  30 for high, 90 for medium, and the next release for low; a vulnerability on CISA's
  Known Exploited Vulnerabilities list is treated as critical whatever its score.
- The control plane's container images are scanned (Trivy) before a release is
  assembled, and a known high or critical vulnerability with a fixed version fails the
  release. Their base images are pinned by digest, and every operating system package
  they upgrade or add is pinned to an exact version. They carry no known vulnerability
  with a severity rating, and accept none; a finding no fixed version can be taken for
  would be accepted only for one binary, with its reason and an expiry date
  (`.trivyignore.yaml`). Not in place yet: showing the model engine images' known vulnerabilities,
  re-scanning published releases for new advisories, and naming security fixes in the
  update offer.

## Supply chain

- Every release has a record (`manifest.json`) listing every file with its SHA-256 and
  every image by digest. The one-line installer, `onprem-ai-ctl` and `onprem-ai-node`
  check every downloaded file against it, and the record against a digest given by the
  control plane's update offer or the installer's own download; images are pulled by
  digest.
- Model engine images are pinned by digest in every shipped and every stable deploy
  profile. A profile that is not stable may name one by its tag only; each inference
  node then resolves the tag at its first pull and keeps that digest until the image is
  removed, and reports it (`SECURITY.md`, Supply-chain policy).
- The record is not cryptographically signed yet.
- A software bill of materials per release: one CycloneDX document per program archive
  and per image, published with the release and listed in its record with its SHA-256
  (`release/README.md`, Software bills of materials). The first release built with this
  workflow publishes them.
- Air-gapped installation: today through a mirror of the distribution service and of the
  image registry (the control plane's setting `DISTRIBUTION_BASE_URL`, and
  `--software-release-url` of the one-line installer and of the inference node's
  install); an offline bundle per release is not in place yet.

## Keeping this document true

This document is part of the repository's current-state documentation: a change to
privileges, the root programs, network exposure, data placement or the supply chain
updates it in the same change. It is the one description of how the platform is built
for security: `SECURITY.md` and the installer's notice link to it or say only what it
says.
