For the complete documentation index, see llms.txt. This page is also available as Markdown.

Security Best Practices

This guide covers security considerations for deploying ChronDB in production environments.

Network Security

Bind to Specific Interfaces

By default, ChronDB binds to 0.0.0.0 (all interfaces). In production, bind to specific interfaces:

:servers {
  :rest {:host "127.0.0.1" :port 3000}       ;; Localhost only
  :redis {:host "10.0.0.5" :port 6379}       ;; Internal network only
  :postgresql {:host "10.0.0.5" :port 5432}  ;; Internal network only
}

Disable Unused Protocols

Only enable the protocols your application uses:

# REST API only
clojure -M:run --disable-redis --disable-sql

# Redis only
clojure -M:run --disable-rest --disable-sql

Or in config.edn:

Firewall Rules

Restrict access to ChronDB ports from trusted networks only:

TLS Termination

ChronDB does not handle TLS directly. Use a reverse proxy for HTTPS:

nginx example:

For the Redis and PostgreSQL protocols, use stunnel or a similar TLS wrapper if encryption in transit is required.


Authentication

PostgreSQL Protocol

The PostgreSQL wire protocol supports username/password authentication:

Change the default credentials before deploying to production.

REST API

The REST API does not include built-in authentication. Implement authentication at the reverse proxy layer:

  • Basic Auth: via nginx auth_basic or similar

  • OAuth2/JWT: via an API gateway (Kong, Envoy, AWS ALB)

  • mTLS: mutual TLS at the proxy layer for service-to-service communication

Redis Protocol

The Redis protocol does not currently support the AUTH command. Protect it via network isolation (bind to internal interfaces, firewall rules).


File System Permissions

Data Directory

The data directory contains the Git repository and Lucene index. Restrict access:

Configuration File

The configuration file may contain credentials (PostgreSQL password, SSH key paths):


Docker Security

The official Docker image follows security best practices:

  • Non-root user: runs as the chrondb user (not root)

  • Minimal base image: Debian 12 slim with only required dependencies

  • No shell access needed: entry point is the compiled binary

Additional Hardening

Kubernetes Security Context


Remote Git Security

When using remote Git synchronization, ChronDB connects to a remote repository. Secure this connection:

SSH Keys

Use deploy keys with minimal permissions:

Configure in config.edn:

Key Permissions

Repository Access

  • Use a dedicated repository for ChronDB data (not a shared repo)

  • Grant minimal permissions (deploy key with write access only to the data repo)

  • Enable branch protection on the remote to prevent force pushes

  • Enable audit logging on your Git hosting to track access


Backup Security

Backup Storage

  • Store backups in a different location than the primary data (different disk, cloud storage)

  • Encrypt backups at rest if they contain sensitive data:

Backup Access Control

  • Restrict who can trigger backup/restore via the REST API

  • The /api/v1/backup and /api/v1/restore endpoints should be behind authentication

  • Consider disabling these endpoints in production and using CLI-based backups instead


Audit Trail

ChronDB's Git-based storage provides a built-in audit trail:

  • Every write creates an immutable Git commit with timestamp and metadata

  • Transaction metadata (user, origin, flags) is stored in Git notes (refs/notes/chrondb)

  • History cannot be altered without detection (Git hash chain integrity)

Inspecting the Audit Trail

Enriching the Audit Trail

Always set transaction metadata headers on write operations:


Security Monitoring

What to Monitor

Signal
Metric / Log
Action

High error rate

chrondb_occ_conflicts_total

May indicate concurrent modification attacks

Unusual write volume

chrondb_documents_saved_total spike

May indicate unauthorized bulk writes

Failed connections

Application logs

May indicate port scanning or brute force

Disk space exhaustion

/health disk check

May indicate DoS via document flooding

WAL backlog

chrondb_wal_pending_entries

May indicate storage issues or attack

Log Review

Regularly review ChronDB logs for:

  • Unknown client connections

  • Unusual query patterns

  • Repeated errors on specific documents

  • Operations from unexpected origins (check Git notes)

Last updated

Was this helpful?