Skip to content

Security: wnstify/rostr

Security

docs/SECURITY.md

Security

Security best practices for rostr.

Secrets Management

Environment Variables Only

rostr requires all secrets to be stored in environment variables. The application will refuse to start if it detects secrets in config.yaml.

Required variables:

# For Uptime Kuma integration
export ROSTR_UPTIMEKUMA_DB_PASS='your-secure-password'

# For registration API
export ROSTR_REGISTRATION_TOKEN='your-secure-token'

Never Commit Secrets

The following files should never be committed to version control:

  • .env
  • config.yaml (use config.yaml.example as template)
  • Any file containing passwords, tokens, or API keys

Secret Detection

rostr automatically detects these patterns in config.yaml:

  • db_pass:
  • password:
  • token:
  • secret:
  • api_key:

If detected with non-empty values, rostr exits with an error.

SSH Security

Key-Based Authentication

rostr assumes SSH key-based authentication. Never use passwords in automation.

# Generate SSH key if needed
ssh-keygen -t ed25519 -C "rostr"

# Copy to servers
ssh-copy-id user@server

SSH Config Permissions

Generated SSH config should have restricted permissions:

chmod 600 ~/.rostr/generated/ssh_config
chmod 700 ~/.rostr/generated

Host Key Verification

For automation (audit-os), rostr uses -o StrictHostKeyChecking=no. For interactive use, maintain proper host key verification.

File Permissions

Recommended permissions:

chmod 700 ~/.rostr
chmod 600 ~/.rostr/config.yaml
chmod 600 ~/.rostr/inventory/groups/*.yaml
chmod 700 ~/.rostr/generated
chmod 600 ~/.rostr/generated/*
chmod 700 ~/.rostr/backups
chmod 700 ~/.rostr/logs

Registration API Security

Network Access

IMPORTANT: The registration API listens on port 8888. Proper firewall configuration is critical.

Option 1: Private Network (Recommended)

If your rostr server and n8n are on the same private network, no firewall changes needed.

Option 2: Public Server with Firewall

WARNING: If your rostr server is on a public network, you MUST whitelist your n8n server's IP.

# UFW - allow only n8n server
sudo ufw allow from <n8n-server-ip> to any port 8888

# iptables
sudo iptables -A INPUT -p tcp -s <n8n-server-ip> --dport 8888 -j ACCEPT

NEVER expose port 8888 to the entire internet. Unauthorized access could allow attackers to register malicious servers in your inventory. Always restrict to your n8n server's IP address only.

Authentication

All /register requests require the X-Registration-Token header.

Allowed Groups

Restrict which groups can be registered via API:

export ROSTR_ALLOWED_GROUPS='production,staging'

Rate Limiting

Implement rate limiting in your webhook service, not in rostr.

Rootless Docker Security

When you run rostr setup monitoring, it installs Docker in rootless mode:

Benefits

  • No root daemon - Docker daemon runs as your user, not root
  • User namespace isolation - Container processes map to unprivileged UIDs
  • Reduced attack surface - Container escape has limited impact
  • No sudo required - Manage containers without elevated privileges

Important Notes

  • Never use sudo with rootless Docker commands
  • Container UID 1000 maps to a high host UID (100999+)
  • ICMP ping requires slirp4netns (installed automatically)

Database Security

Uptime Kuma Database

  • Use strong passwords (32+ characters)
  • Never expose MariaDB port to public
  • Rootless Docker provides additional isolation

Credential Storage

# Generate strong password
openssl rand -base64 32

# Store in environment file (not committed)
echo 'ROSTR_UPTIMEKUMA_DB_PASS=...' >> ~/.config/rostr/env
chmod 600 ~/.config/rostr/env

Git Security

Git Sync

When using git sync:

  • Use SSH keys for git authentication
  • Never commit secrets
  • Review commits before pushing

Repository Visibility

If using a private repository:

  • Limit access to authorized users
  • Review access periodically

Backup Security

Encrypted Backups

For sensitive inventories, encrypt backups:

# Create encrypted backup
rostr backup
gpg -c ~/.rostr/backups/latest.csv
rm ~/.rostr/backups/latest.csv

Offsite Storage

Store encrypted backups offsite:

  • Cloud storage (encrypted)
  • Separate server
  • Local encrypted drive

Logging

Log Contents

Logs contain:

  • Operation timestamps
  • Hostnames and IPs
  • Error messages

Logs do NOT contain:

  • Passwords
  • Tokens
  • SSH keys

Log Retention

Implement log rotation:

# Example logrotate config
/home/user/.rostr/logs/*.log {
    weekly
    rotate 4
    compress
    missingok
    notifempty
}

Network Security

Firewall

Restrict access to:

  • Registration API (port 8888) - private network only
  • Uptime Kuma (port 3001) - as needed
  • MariaDB (port 3306) - localhost only

TLS

Use HTTPS for:

  • Webhook endpoints
  • Uptime Kuma web interface

Updates

Keep Updated

rostr update

Or for pipx:

pipx upgrade rostr

Dependency Updates

Periodically update dependencies:

cd ~/.rostr
pip install --upgrade -e .

Incident Response

Compromised Token

If registration token is compromised:

  1. Generate new token: openssl rand -hex 32
  2. Update environment variable
  3. Restart registration API
  4. Update webhook service
  5. Review registration logs

Compromised SSH Key

If SSH key is compromised:

  1. Generate new key pair
  2. Revoke old key on all servers
  3. Deploy new key
  4. Audit for unauthorized access

Automation Security

When using rostr setup automation:

Token Security

  • Tokens are auto-generated (64 hex characters)
  • Stored in config.yaml and systemd service
  • Displayed once during setup - save securely

Cloud-Init Templates

Generated templates include:

  • Your SSH public key
  • Registration token
  • Webhook URL

Store templates securely - they contain authentication credentials.

Service Isolation

The registration API runs as a systemd user service:

  • No root privileges required
  • Runs in your user context
  • Logs to ~/.rostr/logs/api.log

Audit Checklist

Regular security audit:

  • Secrets in environment variables only
  • No secrets in version control
  • File permissions correct
  • SSH keys are ED25519 or RSA 4096
  • Registration API on private network
  • Strong tokens/passwords (32+ chars)
  • Logs reviewed for anomalies
  • Dependencies updated
  • Backups encrypted and tested

There aren’t any published security advisories