Set up
Self-hosting on Azure and AWS
Deploy the sovereign 0 container on Azure and AWS with persistent volumes, cloud secret stores, TLS ingress, automated backups, and upgrades.
Run 0 in your own cloud tenant to keep code analysis, findings and model conversations inside your perimeter. This guide runs the official image (ghcr.io/0sec-labs/0security) on AWS and Azure with a persistent disk, a secret store, TLS ingress, backups and upgrades.
Architecture and constraints
Section titled “Architecture and constraints”0 is a single-node application:
Internet / Corporate Network │ ▼ ┌───────────────────────────────┐ │ TLS Ingress (Ports 80/443) │ │ Caddy, AWS ALB, or AGW │ └───────────────┬───────────────┘ │ HTTPS / Reverse Proxy ▼ ┌───────────────────────────────┐ │ 0 Server Container (Docker) │ │ Runs as non-root (uid 1000) │ │ Binds 127.0.0.1:48123 │ └───────────────┬───────────────┘ │ ┌───────────────┴───────────────┐ ▼ ▼ ┌───────────────┐ ┌───────────────┐ │ /data │ │ Cloud Secrets │ │ EBS / Azure │ │ AWS SSM / SM │ │ Managed Disk │ │ Azure KeyVlt │ └───────────────┘ └───────────────┘The single-node rule
Section titled “The single-node rule”- The console stores its data in an embedded SQLite database at
/data/.0/0.db. With the data-disk override below, that file is on the host’s mounted disk. - Run one replica. SQLite needs a single owner process, so never mount the volume in more than one container.
- For recovery, rely on VM auto-recovery, volume snapshots and scheduled database backups.
Sizing
Section titled “Sizing”| Sizing | vCPU | RAM | Storage | Typical Cloud Instance |
|---|---|---|---|---|
| Minimum | 2 | 4 GB | 30 GB SSD | AWS t3.medium, Azure Standard_B2s |
| Standard | 4 | 8 GB | 60 GB SSD | AWS t3.xlarge / m7g.large, Azure Standard_D2s_v5 |
| High load | 8 | 16 GB | 120 GB SSD | AWS m7g.xlarge, Azure Standard_D4s_v5 |
Add about 1 vCPU and 1 to 2 GB of memory for each concurrent scan or fix Thread.
Run on EC2 with Docker Compose
Section titled “Run on EC2 with Docker Compose”This is the simplest setup: an EC2 instance with an attached EBS volume.
1. Provision storage and compute (untested)
Section titled “1. Provision storage and compute (untested)”- Launch an Ubuntu 24.04 LTS instance, for example
t3.xlargeorm7g.large. - Attach an EBS
gp3volume of about 50 GB as/dev/sdffor application state. - Format and mount it. The device is
/dev/nvme1n1or/dev/xvdf, depending on the instance generation.Terminal window sudo mkfs -t ext4 /dev/nvme1n1sudo mkdir -p /datasudo mount /dev/nvme1n1 /dataecho "/dev/nvme1n1 /data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstabsudo chown -R 1000:1000 /datasudo chmod 700 /data
2. IAM role and secrets (untested)
Section titled “2. IAM role and secrets (untested)”Keep credentials out of git. Use AWS Systems Manager (SSM) Parameter Store or AWS Secrets Manager.
-
Store the secrets:
Terminal window aws ssm put-parameter --name "/zero/ZERO_ACCESS_TOKEN" --type "SecureString" --value "$(openssl rand -base64 32)"aws ssm put-parameter --name "/zero/ANTHROPIC_API_KEY" --type "SecureString" --value "sk-ant-..."aws ssm put-parameter --name "/zero/GH_TOKEN" --type "SecureString" --value "ghp_..." -
Attach an IAM role with read access to the EC2 instance:
{"Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": ["ssm:GetParametersByPath","ssm:GetParameter"],"Resource": "arn:aws:ssm:*:*:parameter/zero/*"}]} -
Write the secrets to
.envbefore the container starts:Terminal window mkdir -p /opt/zeroaws ssm get-parameters-by-path --path "/zero/" --with-decryption \--query "Parameters[*].[Name,Value]" --output text | \while read -r name val; dovar_name=$(basename "$name")echo "${var_name}=${val}"done > /opt/zero/.envchmod 600 /opt/zero/.env
3. Run the application
Section titled “3. Run the application”Download the compose files:
cd /opt/zerocurl -fsSL https://raw.githubusercontent.com/0sec-labs/0security/main/deploy/compose/docker-compose.yml -o docker-compose.ymlcurl -fsSL https://raw.githubusercontent.com/0sec-labs/0security/main/deploy/compose/Caddyfile -o CaddyfileDownload the data-disk override. It puts the database on the disk you mounted at /data, not in the Docker named volume zero-data on the root disk:
curl -fsSL https://raw.githubusercontent.com/0sec-labs/0security/main/deploy/compose/docker-compose.data-disk.yml -o docker-compose.data-disk.ymlAdd your domain and network settings to /opt/zero/.env:
ZERO_DOMAIN=zero.internal.yourcompany.comZERO_PUBLIC_URL=https://zero.internal.yourcompany.comZERO_ALLOWED_HOSTS=zero.internal.yourcompany.comZERO_IMAGE_TAG=v0.41.0COMPOSE_FILE=docker-compose.yml:docker-compose.data-disk.ymlZERO_DATA_DIR=/dataCOMPOSE_FILE makes every later docker compose command in this guide use both files. ZERO_IMAGE_TAG accepts v0.41.0 or 0.41.0 (see Tags).
Start the container with automatic TLS through Caddy:
docker compose --profile proxy up -dCheck that the service is ready and the database is on the data disk:
curl -fsS http://127.0.0.1:48123/readyz # {"status":"ready"}ls -l /data/.0/0.db # the database file is on the mounted disk/readyz returns {"status":"ready"} once the database answers, and 503 while the service starts or stops. /healthz returns {"status":"ok"} and says only that the process is up.
Run on ECS (untested)
Section titled “Run on ECS (untested)”Use ECS to avoid managing host operating systems.
- Create an ECS cluster with the EC2 launch type, which allows EBS attachments.
- Define one container task using
ghcr.io/0sec-labs/0security:v0.41.0:- Mount host
/dataat container/data. - Map
secretsfrom Secrets Manager or SSM Parameter Store to environment variables such asZERO_ACCESS_TOKENandANTHROPIC_API_KEY. - Set the health check to
curl -fsS http://127.0.0.1:48123/healthz || exit 1.
- Mount host
- Create a service with
desiredCount: 1. Set minimum healthy percent to0and maximum percent to100, so ECS never starts a second container on the same volume during a deploy.
Run on a VM with Docker Compose
Section titled “Run on a VM with Docker Compose”1. Compute and disk setup (untested)
Section titled “1. Compute and disk setup (untested)”- Deploy an Ubuntu 24.04 LTS VM, for example
Standard_D2s_v5. - Attach a Premium SSD managed data disk, for example 64 GB, LRS.
- Mount the disk:
Terminal window sudo parted /dev/sdc --script mklabel gpt mkpart xfspart ext4 0% 100%sudo mkfs.ext4 /dev/sdc1sudo mkdir -p /datasudo mount /dev/sdc1 /dataecho "/dev/sdc1 /data ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstabsudo chown -R 1000:1000 /datasudo chmod 700 /data
2. Key Vault (untested)
Section titled “2. Key Vault (untested)”- Enable a system-assigned managed identity on the VM.
- In Key Vault, grant that identity the Key Vault Secrets User role.
- Store these secrets in Key Vault:
ZERO-ACCESS-TOKENAZURE-OPENAI-API-KEYGH-TOKEN
- Write the secrets to
.envat startup:Terminal window az login --identity --allow-no-subscriptionsTOKEN=$(az keyvault secret show --vault-name "kv-zero-prod" --name "ZERO-ACCESS-TOKEN" --query value -o tsv)KEY=$(az keyvault secret show --vault-name "kv-zero-prod" --name "AZURE-OPENAI-API-KEY" --query value -o tsv)cat <<EOF > /opt/zero/.envZERO_ACCESS_TOKEN=${TOKEN}AZURE_OPENAI_API_KEY=${KEY}ZERO_DOMAIN=zero.azure.yourcompany.comZERO_PUBLIC_URL=https://zero.azure.yourcompany.comZERO_ALLOWED_HOSTS=zero.azure.yourcompany.comEOFchmod 600 /opt/zero/.env
3. Ingress and firewall (untested)
Section titled “3. Ingress and firewall (untested)”- In the network security group, allow inbound TCP 80 and 443.
- Run
docker compose --profile proxy up -dto terminate TLS with Caddy. - Or put an Application Gateway or Front Door in front of port 48123, and set
ZERO_TRUSTED_PROXYto the gateway subnet.
Scheduled backups and restore
Section titled “Scheduled backups and restore”Findings and audit logs live in the SQLite database /data/.0/0.db. This section assumes the data-disk override above, so the host’s /data is the container’s /data. With the plain compose file (named volume zero-data), use the volume steps in Server mode: Back up.
1. Online safe database backup
Section titled “1. Online safe database backup”Never copy a live SQLite file with cp. Take the online backup in Server mode: Back up: the node:sqlite backup command, then docker compose cp. It leaves ./zero-backup.db. Date it for retention:
mv ./zero-backup.db ./zero-backup-$(date +%F).db2. Offsite upload to cloud object storage (untested)
Section titled “2. Offsite upload to cloud object storage (untested)”Run the backup daily from cron and upload it.
AWS S3:
aws s3 cp ./zero-backup-$(date +%F).db s3://my-org-zero-backups/$(date +%Y)/$(date +%m)/backup-$(date +%F).db \ --sse aws:kms --sse-kms-key-id alias/zero-backup-keyAzure Blob Storage:
az storage blob upload \ --account-name "zeroorgbackups" \ --container-name "db-backups" \ --file "./zero-backup-$(date +%F).db" \ --name "$(date +%Y)/$(date +%m)/backup-$(date +%F).db" \ --auth-mode login3. Cloud disk snapshots (untested)
Section titled “3. Cloud disk snapshots (untested)”A snapshot taken while 0 runs is crash-consistent only. Use it as a second line behind the database backup, or stop the service briefly first with docker compose stop zero.
- AWS: create an Amazon Data Lifecycle Manager policy for daily snapshots of the
/dataEBS volume, kept 14 days. - Azure: configure Azure Backup or a disk snapshot policy for the data disk.
4. Restore procedure
Section titled “4. Restore procedure”You need sqlite3 on the host (sudo apt-get install -y sqlite3). Run these steps from /opt/zero. We ran the file and database commands against a sample database. We did not run the compose steps and the data-disk override on a cloud host.
-
Stop the service so nothing writes to the database:
Terminal window docker compose stop zero -
Move the current database aside and remove its journal files. A leftover
-walor-shmfile from the old database would be applied to the restored one and corrupt it:Terminal window sudo mv /data/.0/0.db /data/.0/0.db.before-restoresudo rm -f /data/.0/0.db-wal /data/.0/0.db-shmIf the
mvfails because there is no database yet, continue. -
Restore the backup and set the owner and mode:
Terminal window sudo cp ./zero-backup-2026-11-21.db /data/.0/0.dbsudo chown 1000:1000 /data/.0/0.dbsudo chmod 600 /data/.0/0.db -
Check the restored file before you start. The output must be exactly
ok. If it is anything else, or an error such asfile is not a database, do not start the service. Repeat step 3 with another backup. Your previous database is still at0.db.before-restore.Terminal window sudo sqlite3 /data/.0/0.db 'PRAGMA integrity_check' -
Start the service and confirm it is ready:
Terminal window docker compose up -d zerofor i in $(seq 1 30); do curl -fsS http://127.0.0.1:48123/readyz && break; sleep 2; doneA good restore prints
{"status":"ready"}. If the loop ends without it, readdocker compose logs --tail 50 zero. -
Delete
0.db.before-restoreafter you confirm the restored data in the app. It contains findings.
Verify a release
Section titled “Verify a release”Each release publishes the standalone binaries, checksums.txt, and a CycloneDX SBOM (0-sbom.cdx.json). The release workflow also creates a GitHub build-provenance attestation for every one of those assets, so you can prove that a file was built by this repository’s release workflow and not just that it matches a hash someone served you.
With the GitHub CLI installed and logged in (gh auth login), download an asset from the release page and verify it:
gh attestation verify 0-linux-x64 --repo 0sec-labs/0securitygh attestation verify checksums.txt --repo 0sec-labs/0securityThen check the binary against the verified checksums:
sha256sum --check --ignore-missing checksums.txtOn macOS use shasum -a 256 --check --ignore-missing checksums.txt instead.
The install script does the same for you. When gh is installed and logged in it verifies the checksums.txt attestation before it trusts any hash, and it prints a clear note and falls back to the plain checksums.txt check when gh is missing. Set INSTALL_ATTESTATION=require to fail instead of falling back, or INSTALL_ATTESTATION=0 to skip the attestation on an air-gapped host or an internal mirror. Neither setting disables the checksum comparison. The FoxGuard companion is always checked against a SHA-256 pinned in the install script.
To audit the dependencies of a release, run the SBOM through the advisory check:
0 sbom check 0-sbom.cdx.jsonReproducibility: builds run on GitHub-hosted runners with pinned tool versions and a frozen lockfile, but the binaries are not bit-for-bit reproducible, so the attestation, not a local rebuild, is the evidence of origin. The SBOM lists lockfile dependencies of the tagged source and does not enumerate the bundled runtime.
To report a vulnerability, see the security policy.
Upgrades and rollbacks
Section titled “Upgrades and rollbacks”Upgrades
Section titled “Upgrades”- Take a fresh backup, as in Backups. Keep it until the upgrade is verified.
- Set the new tag in
/opt/zero/.env(ZERO_IMAGE_TAG=vfollowed by the new version). Then pull and recreate, as in Server mode: Upgrade:Database migrations run on start.Terminal window docker compose pull zero && docker compose up -d zerodocker compose logs --tail 50 zero
Rollbacks
Section titled “Rollbacks”Migrations only go forward, so a rollback needs the pre-upgrade database. Pin the previous tag in /opt/zero/.env, for example ZERO_IMAGE_TAG=v0.41.0. Then run the restore procedure with the pre-upgrade backup. Step 5 runs docker compose up -d, which applies the pinned tag.
Security hardening checklist
Section titled “Security hardening checklist”- Run as the
ubuntuuser (uid 1000). Never setuser: root. - Mount the host volume with mode
0700, owned by1000:1000. - Behind a local reverse proxy such as Caddy, bind the container port to
127.0.0.1:48123only. Never expose port 48123 on0.0.0.0without TLS termination. - Set
ZERO_ALLOWED_HOSTSto exactly your public hostname. A request with any otherHostheader gets 403. - Set
ZERO_PUBLIC_URL=https://...so session cookies carry theSecureattribute.