Skip to content

Security

Marc Pope edited this page Oct 8, 2026 · 4 revisions

Security

Borg Backup Server (BBS) is designed with a security-first architecture. This document describes how BBS protects your backup infrastructure, data, and credentials.

Immutable Backups (Append-Only)

BBS-hosted storage: enforced automatically

For repositories stored on the BBS server itself, every agent SSH key is registered in authorized_keys with a forced command that execs:

borg serve --append-only --restrict-to-path /var/bbs/home/{agent_id}

Combined with the SSH restrict directive (no port forwarding, no PTY, no agent forwarding), this means:

  • Agents can only create new backup archives — they cannot delete, modify, or overwrite existing ones
  • Agents are restricted to their own directory — they cannot access other clients' data
  • No shell access — agents cannot execute arbitrary commands on the server

Even if a client machine is fully compromised, the attacker cannot delete or tamper with existing backups. Only the BBS server itself (via the web interface or scheduler) can prune old archives according to retention policies — it uses a separately-privileged key path that doesn't carry the append-only restriction.

Remote SSH hosts: you configure it on the provider

When a repository lives on a third-party SSH host (rsync.net, BorgBase, Hetzner Storage Box, etc.), BBS orchestrates the transfer but does not own the remote's authorized_keys file. The forced-command restriction has to be set up on the provider side — BBS cannot inject it remotely.

Every major borg-friendly provider supports this: BorgBase has an "Append-only" checkbox in the UI, rsync.net and Hetzner expose authorized_keys directly, and any custom SSH server can use the standard command="borg serve --append-only …" pattern.

See Remote-Storage#append-only-mode-on-remote-hosts for step-by-step instructions per provider. If you skip that step, a compromised agent can delete archives on the offsite repo — the offsite repo is only as tamper-resistant as whatever restriction the provider's key enforces.

Zero Trust: Server Has No Access to Clients

BBS operates on a pull model — agents poll the server for work. The BBS server never initiates SSH connections to client machines and holds no credentials for client systems. This eliminates an entire class of lateral movement attacks: compromising the backup server does not give an attacker access to your production infrastructure.

Agent Authentication & Isolation

Each agent authenticates with a unique API key over HTTPS. Agents are fully isolated from each other:

  • Unique SSH user per client — each agent gets a dedicated system user (bbs-{id}) with its own home directory
  • Job ownership verification — agents can only retrieve and report on their own jobs
  • Rate-limited API — failed authentication attempts are rate-limited (20 attempts per 5 minutes) to prevent brute force

Encryption at Rest

All repository passphrases, SSH private keys, and TOTP secrets are encrypted in the database using AES-256-GCM with a server-specific APP_KEY. Repository data itself is encrypted by Borg using the user's chosen encryption mode (default: repokey-blake2 with AES-256).

Passwords are hashed with bcrypt and never stored in plaintext. Two-factor recovery codes are also bcrypt-hashed.

Web Application Security

The BBS web interface follows OWASP best practices:

  • SQL injection prevention — all database queries use parameterized prepared statements (PDO with emulated prepares disabled)
  • CSRF protection — all forms include a per-session token verified with constant-time comparison, plus SameSite=Strict cookies
  • XSS prevention — all user-supplied data is escaped with htmlspecialchars before rendering
  • Command injection prevention — all shell arguments are escaped with escapeshellarg and validated against allowed paths
  • Session security — cookies are HttpOnly and SameSite=Strict; session IDs are regenerated on login
  • Brute force protection — login (5 attempts/5 min), 2FA verification (10 attempts/5 min), and agent API endpoints are all rate-limited by IP

Role-Based Access Control

BBS enforces fine-grained permissions:

  • Admin — full system access including settings, user management, and notification services
  • User — limited to assigned clients with granular permissions (trigger backup, manage repos, manage plans, restore, repo maintenance)

Every API request verifies job and agent ownership — agents can only interact with their own data.

See User-Management for details on roles and permissions.

Two-Factor Authentication

BBS supports TOTP-based two-factor authentication compatible with any authenticator app (Google Authenticator, Authy, 1Password, etc.). Admins can enforce 2FA for all users. Recovery codes are bcrypt-hashed and single-use.

See Two-Factor-Authentication for setup instructions.

Automatic Updates

Agents stay current with the latest security patches through managed updates:

  • Agent updates — new agent versions are deployed from the web interface (single or bulk) with automatic validation and rollback
  • Borg updates — Borg binary versions are managed centrally and can be updated individually or in bulk
  • Verified Borg downloads (BBS 2.98.6 and later): before the server installs a Borg binary, it checks the download against the SHA-256 digest GitHub publishes for it, and against the Borg project's signature where the release has one. Builds hosted on the BBS server need a valid signature from the BBS release key. Borg 1.4.1 and older cannot be installed this way, because GitHub publishes no digest for them.
  • Signed agent updates: an agent installs an update only if it carries a valid signature from the project's key. See Signed agent updates below.
  • Server updates — BBS checks for new releases daily and can be upgraded from the web UI or CLI

See Updating-BBS for update procedures.

Data Protection & Offsite Backups

BBS protects against data loss at multiple levels:

  • Nightly server backups — the BBS database, configuration, and encryption keys are backed up daily with 7-day retention
  • S3 offsite sync — server backups and individual repositories can be automatically synced to S3-compatible storage (AWS, Wasabi, Backblaze B2, etc.) for geographic redundancy
  • S3 disaster recovery — repositories can be restored from S3 in two modes: replace (overwrite local) or copy (create new repo), with orphaned repository detection for full server rebuilds
  • Append-only protection — even if the server's local disk fails, offsite copies in S3 remain intact and recoverable

See Server-Backup-and-Restore and S3-Offsite-Sync for configuration details.

Notes for Administrators

  • Docker: set a real email on the admin account. The default admin on a Docker install has the placeholder address admin@localhost.invalid, which cannot receive mail. Installs that still had admin@borgbackupserver.com were moved to it in BBS 2.98.5. Password reset does not send links to placeholder addresses, so until you set a real address in your profile, password resets and email notifications will not reach you.
  • Remote SSH hosts are admin-only. Only admins can add or edit a Remote SSH host, or place a repository on one, because the host's key is shared by every repository on it. Host, user and Remote Borg Path are checked when saved and again before each use.
  • Offsite sync to an SSH host or a storage location is admin-only. Other users can set up S3 destinations only.

See Remote Storage and S3 Offsite Sync.

Vulnerability Scanning

Every push to main and every pull request runs an automated security scan in GitHub Actions. It also runs weekly, to catch new advisories for dependencies that have not changed.

  • composer audit checks the PHP dependencies for known vulnerabilities.
  • gitleaks checks the repository history for committed secrets.
  • Semgrep runs static analysis on the PHP, JavaScript and Python code.

A failed composer audit or gitleaks check fails the build. Semgrep findings are reviewed by the maintainer. A separate check verifies the agent's signature on every push.

Security Architecture Summary

Layer Protection
Client → Server Append-only SSH, restricted to borg serve, no shell access
Client → Remote host Append-only when the provider's key is configured for it ([[Remote-Storage#append-only-mode-on-remote-hosts
Server → Client None — server never connects to clients (zero trust)
Agent API HTTPS + API key auth + rate limiting + job ownership checks
Web Interface CSRF tokens, bcrypt passwords, session security, rate limiting
Data at Rest AES-256-GCM (credentials), AES-256 Borg encryption (archives)
Database Parameterized queries, no raw SQL, emulated prepares disabled
Access Control Role-based (admin/user) + per-agent permissions
Offsite S3 sync with disaster recovery and orphaned repo detection
Updates Centrally managed agent + Borg updates from web UI; agent updates signed, Borg downloads verified

Reporting a Vulnerability

If you discover a security vulnerability in Borg Backup Server, please do not open a public issue.

Instead, report it privately:

Please include:

  • A description of the vulnerability
  • Steps to reproduce
  • Potential impact
  • Suggested fix (if you have one)

You should receive an acknowledgment within 72 hours. Security fixes go into the latest release only, so keep your server up to date.

Scope

The following are in scope:

  • Authentication and session management
  • SQL injection, XSS, CSRF, and other OWASP Top 10 vulnerabilities
  • Agent API authentication bypass
  • Passphrase or credential exposure
  • Privilege escalation (user to admin)
  • Remote code execution

Out of Scope

  • Vulnerabilities in third-party dependencies (report these upstream)
  • Denial of service attacks
  • Issues requiring physical access to the server
  • Social engineering

Disclosure

We follow coordinated disclosure. The fix ships in a release first. The advisory is then published on the repository, and the release notes name it (for example GHSA-6423-m3jr-236x). The reporter is credited in both unless they prefer to remain anonymous.

Signed agent updates (BBS 2.96.1, agent 2.96.1)

The agent updates itself by downloading bbs-agent.py from the server. From agent 2.96.1 that download is installed only if it carries a valid signature from the project's signing key, so a server that has been broken into cannot push code to the clients it backs up.

How it works:

  • The last line of agent/bbs-agent.py and agent/bbs-agent-start.sh is # bbs-signature: v1 <base64>, an Ed25519 signature over every byte before it. The public key is inside the agent (AGENT_SIGNING_KEYS) and in agent/signing-key.pub; the private key lives on the maintainer's machine only.
  • Before replacing itself, the agent verifies the signature and refuses the update if it is missing, malformed, or made with another key. It also refuses a version older than the one it runs, so a signed but superseded release cannot be replayed. The job fails with a message that says which check failed, and the running agent is left as it was.
  • Verification is done in plain Python with no libraries, so it works on every Python the agent supports. It takes about a quarter of a second.
  • Every commit that changes the agent is re-signed by a pre-commit hook, and a GitHub Action verifies the signature on every push, so an unsigned agent cannot reach a release.

What it does not cover: a server that has been broken into can still send the client any job the agent knows how to run, including shell hooks and restores. Signing closes the update path only. Keep the server itself protected, and keep an offsite copy of your repositories that the server cannot delete.

If you run a fork of the agent with your own changes, set require_signed_updates = false under [agent] in the client's config.ini (or BBS_REQUIRE_SIGNED_UPDATES=0 for a containerised agent). The setting is on the client, so the server cannot change it. Better: sign your fork with your own key and add its public key to AGENT_SIGNING_KEYS.

Clone this wiki locally