Aegis

Security

Aegis builds and runs code. Anyone who can call its deploy API can run programs as the daemon’s user, so every way in is authenticated. This page covers how, and how to expose the web API safely.

What is protected, and how

Entry point Who can use it Protection
gRPC (127.0.0.1:50051) The local CLI Loopback only. The daemon refuses a non-loopback daemon.host. Any local account can reach it, as with Docker’s socket; on shared machines restrict who can log in.
HTTP API (/api/v1) Signed-in users and API tokens Login required on every route except POST /api/v1/auth/login.
Webhooks (/hooks/github/{project}) GitHub HMAC-SHA256 signature with a per-project secret.
GET /healthz Anyone who can reach the port Returns ok and nothing else.
Admin commands (aegis-daemon admin …) Whoever can read and write the database file Filesystem permissions.

Accounts and sessions

Users and roles

Each person signs in with their own account, so the audit log records who did what (actor = user:<name>). Every account has one role; each includes the ones before it:

Role Can
viewer Read everything except credentials: apps, releases, deployments, logs, events, metrics, domains. View the aegis.toml an app would get. Change their own password.
deployer Also deploy, roll back, and start, stop or restart apps.
admin Everything: create apps, change settings, variables, secrets, domains, schedules, webhooks and limits; manage deploy keys, scan server folders and import apps; manage API tokens, users and backups.

Limiting apps per user, and hidden apps

API tokens

Audit log

Every change made over the API is a domain event with an actor field: user:admin, token:ci, webhook:github, or cli for the local CLI. Sign-ins, sign-outs, failed sign-ins, password changes and token creation/revocation are recorded too. Read them with GET /api/v1/events or aegis timeline. Passwords, tokens and webhook secrets never appear in events. Open event and log streams re-check their credential every 15 seconds and close once it is revoked or the password changes.

Request checks

Exposing the web API

The daemon refuses to start with a configuration that would expose the API unsafely:

aegis-daemon check-config runs the same checks without starting.

Option A: SSH tunnel (no public exposure)

Keep the defaults (127.0.0.1:8420) and connect through SSH:

ssh -N -L 8420:127.0.0.1:8420 you@your-server

Aegis stays on loopback, and Caddy (or nginx with certbot) terminates HTTPS:

[web]
enabled = true
host = "127.0.0.1"
port = 8420
behind_proxy = true
allowed_hosts = ["aegis.example.com"]
# /etc/caddy/Caddyfile
aegis.example.com {
    reverse_proxy 127.0.0.1:8420
}

With behind_proxy = true, cookies are marked Secure, responses carry HSTS, and login throttling uses the client address from X-Forwarded-For. Aegis trusts that header only from a loopback peer, and uses its last entry. The proxy must therefore set or append that header on every request, as Caddy and nginx’s $proxy_add_x_forwarded_for do. A proxy that passes a client-supplied header through unchanged would let clients choose their throttling address. The per-username limit still applies either way. install.sh --server --domain aegis.example.com writes this configuration and prints the Caddy snippet.

Streaming endpoints (/events/stream, /logs/stream) need the proxy not to buffer responses. Caddy streams them by default; for nginx, set proxy_buffering off; for /api/v1/.

Option C: TLS in Aegis

[web]
enabled = true
host = "0.0.0.0"
port = 8443
allowed_hosts = ["aegis.example.com"]

[web.tls]
cert_path = "/etc/letsencrypt/live/aegis.example.com/fullchain.pem"
key_path  = "/etc/letsencrypt/live/aegis.example.com/privkey.pem"

TLS 1.2/1.3 via rustls, with HTTP/2 and HTTP/1.1. Aegis re-reads the files within a minute when they change, so certificate renewals need no restart (a restart would restart every app). A certificate and key that don’t match, as can happen mid-renewal, are ignored until they do. The aegis user must be able to read the key file. Aegis does not obtain certificates itself: use certbot, or Option B.

Forwarded headers and trusted proxies

This is about the built-in app proxy ([proxy]), not the web API’s behind_proxy above.

By default the app proxy trusts no one: it replaces X-Forwarded-Proto and X-Forwarded-Host on every request with what it saw itself (the listener the request arrived on, and the requested host), appends the connecting peer’s address to X-Forwarded-For, and removes X-Real-IP and Forwarded (RFC 7239). A client can put anything in the earlier X-Forwarded-For entries, but never remove or replace the last one, so apps should only believe the entries added by proxies they trust (the last one, when the Aegis proxy is the only proxy).

When Aegis runs behind another reverse proxy that terminates TLS (nginx, Caddy), every request arrives from that proxy over plain HTTP, so apps would always see http. [proxy] trusted_proxies fixes that: for a peer in the list, the incoming X-Forwarded-Proto and X-Forwarded-Host are passed through (when well formed: http/https and a plain host[:port], sent once), and X-Forwarded-Proto: https also stops the proxy from redirecting the request to HTTPS again.

What this trusts, and the risks:

App environment: variables, secrets and env files

Webhooks

  1. Give the project a repository_url (webhook deployments clone it).
  2. Signed in, call POST /api/v1/projects/{project}/webhook. It returns the payload path and a secret, shown once. Calling it again replaces the secret.
  3. In GitHub, add a webhook with payload URL https://aegis.example.com/hooks/github/<project-id>, content type application/json, that secret, and the “push” event.

Only pushes to the project’s branch deploy, and always from the project’s configured repository_url at the pushed commit, never a URL from the payload. Deliveries without a valid X-Hub-Signature-256 get 401. Redeliveries of the same X-GitHub-Delivery are ignored, and so are pushes for commits that already have a release, so a captured signed payload can’t be replayed to roll the app back. Repository URLs that git could treat as options or command-running remote helpers (ext::) are rejected. Private repositories are cloned with the app’s deploy key, for webhook and scheduled deployments too.

Deploy keys

A private repository is cloned with a per-app SSH deploy key (dashboard: Settings → Repository, or the new app wizard when Aegis can’t read a repository; API: POST/GET/DELETE /api/v1/projects/{p}/deploy-key, POST …/deploy-key/test). The trust model:

Scanning folders on the server

Scan a folder on the server (POST /api/v1/apps/scan) and Import selected (POST /api/v1/apps/import) are for signed-in admins only. They only look inside the folders listed in [apps] import_dirs or [apps] env_file_dirs (empty: off), after resolving symbolic links; a link leading outside them is not followed. A scan goes two levels deep and looks at no more than 5000 entries. It never runs git or any other program, and never writes. Per app folder it reads, read-only:

Importing registers the selected apps (ProjectCreated, ProjectSettingsUpdated, and one AppsImported with their ids and names) without deploying them.

The service (install.sh --server)

Self-update

See upgrading.md for the procedure.

Known limitations

The web dashboard

The dashboard’s HTML, JavaScript and CSS are compiled into the daemon and served without authentication, because they contain no data. Everything it shows comes from /api/v1 with the session cookie, and every change it makes carries the CSRF token, so it has exactly the access the signed-in user has. It builds pages from DOM nodes (never innerHTML with data), loads nothing from third parties, and runs under a policy that blocks inline scripts. The CSRF token is kept only in memory: the page fetches it from /auth/session after a reload.