Security First

Security System

APEX is built with security at its core. From permission rulesets to sandboxed execution, every layer is designed to keep you safe.

Permission System

Ruleset-based permission system where each tool can be set to ALLOW, DENY, or ASK. Supports wildcards and per-agent configuration. Each agent has its own permission profile.

Key Features

  • Per-tool permission controls (read, edit, bash, websearch, task)
  • Per-agent permission profiles (Coder, Architect, Planner, Reviewer, Shell)
  • Three permission levels: ALLOW (always permit), ASK (prompt user), DENY (block completely)
  • Wildcard pattern support for flexible rule matching
  • Configurable via .apex/config.yaml or CLI flags
  • Permission checks happen before every tool execution

Configuration

yaml
# .apex/config.yaml
permissions:
  default: ask
  rules:
    - tool: read_file
      action: allow
    - tool: run_command
      action: ask
      patterns:
        - "rm *"     # Always ask for rm
        - "sudo *"   # Always ask for sudo
    - tool: delete_file
      action: deny  # Never allow file deletion

Rate Limiting

Prevent excessive API usage and control costs with configurable rate limiting. Supports both Memory and SQLite backends for persistence.

Key Features

  • Configurable rate limits per model and per session
  • Memory backend for fast, in-process rate tracking
  • SQLite backend for persistent rate limiting across sessions
  • Token-based and request-based limiting
  • Automatic backoff and retry logic
  • Cost threshold alerts and budget limits

Configuration

yaml
# .apex/config.yaml
rate_limiting:
  enabled: true
  backend: sqlite  # or "memory"
  limits:
    - model: "anthropic/*"
      requests_per_minute: 60
      tokens_per_minute: 100000
    - model: "openai/*"
      requests_per_minute: 100
  budget:
    daily_limit: 10.00    # $10/day
    monthly_limit: 200.00 # $200/month

Shell Security

Every shell command is analyzed and classified before execution. Dangerous patterns are blocked or require explicit approval.

Key Features

  • Command analysis and classification before execution
  • Pattern-based dangerous command detection (rm -rf, sudo, chmod 777)
  • Blocklist of known dangerous commands
  • Allowlist for trusted command patterns
  • Shell injection prevention
  • Command audit logging for compliance

Configuration

yaml
# .apex/config.yaml
shell_security:
  enabled: true
  block_patterns:
    - "rm -rf /"
    - "dd if=* of=/dev/*"
    - ":(){ :|:& };:"
    - "chmod 777"
    - "> /dev/sda"
  ask_patterns:
    - "sudo *"
    - "pip install *"
    - "npm install -g *"
  allow_patterns:
    - "git *"
    - "pytest *"
    - "ls *"

API Key Management

Workspace-based key storage with SHA-256 hashing. Keys are never logged, never included in prompts, and are encrypted at rest.

Key Features

  • Workspace-based key storage with SHA-256 hashing
  • Keys never appear in logs or conversation history
  • Automatic key rotation support
  • Key validation on startup
  • Support for multiple keys per provider (load balancing)
  • Key usage tracking and audit log

Configuration

yaml
# ~/.apex/.env (encrypted at rest)
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...

# Key rotation
apex /key rotate anthropic
apex /key validate
apex /key status

Path Traversal Protection

Prevents directory traversal attacks. All file operations are restricted to the project workspace and configured safe paths.

Key Features

  • All file paths resolved against the project root
  • Symlink resolution and validation
  • Blocking of ../ traversal patterns
  • Configurable allowed and denied paths
  • Protection against absolute path injection
  • Workspace boundary enforcement

Configuration

yaml
# .apex/config.yaml
path_security:
  enabled: true
  allowed_paths:
    - "."           # Project root
    - "/tmp/apex"   # Temp directory
  denied_paths:
    - "/etc"
    - "/root"
    - "~/.ssh"
    - "~/.gnupg"
  resolve_symlinks: true
  max_path_length: 4096

Billing & Cost Tracking

Real-time cost tracking with model-specific pricing and three plan tiers (Free/Pro/Enterprise). Monitor usage, set budgets, and get alerts when limits are approached.

Key Features

  • Model-specific pricing with accurate per-token cost calculation
  • Real-time cost display in TUI and CLI
  • Session cost tracking with /cost command
  • Three billing plans: Free, Pro ($200/mo), Enterprise (custom)
  • Daily and monthly budget limits with alerts
  • Cost breakdown by model and provider
  • Export cost reports as CSV or JSON

Configuration

yaml
# Check costs
apex /cost

# Cost output:
# Session:  $0.42 (1,234 tokens)
# Today:    $3.21
# This month: $47.89 / $200.00 budget

# Budget configuration
budget:
  daily: 10.00
  monthly: 200.00
  alert_threshold: 0.8  # Alert at 80%

Sandbox Execution

Run code in isolated sandboxed environments. Untrusted code never touches your filesystem or network.

Key Features

  • Isolated execution environments for untrusted code
  • Support for Python, JavaScript, Bash, Ruby, Go, Rust
  • Configurable timeout (default: 30 seconds)
  • Memory and CPU limits
  • Network isolation by default
  • Output capture and return

Configuration

yaml
# Code runs in sandbox
apex "Run this Python code: print('hello')"

# Sandbox config
sandbox:
  enabled: true
  timeout: 30
  max_memory_mb: 512
  max_output_chars: 10000
  network: disabled

HTTP API Security

Secure headless agent access with Bearer token or X-API-Key authentication, per-endpoint rate limiting, and automatic cost tracking integrated with the billing system.

Key Features

  • Bearer token or X-API-Key authentication
  • Per-endpoint rate limiting
  • Automatic cost tracking per request
  • Shell security integration for API-initiated commands
  • CORS and origin validation
  • Request logging and audit trail

Configuration

yaml
# Start secure HTTP API server
from apex.http_api import HTTPServer

server = HTTPServer(
    host="127.0.0.1",
    port=8080,
    require_auth=True,
)

# API key required for all requests
# Authorization: Bearer <api-key>
# or X-API-Key: <api-key>

Security Reporting

Found a Security Vulnerability?

We take security seriously. If you discover a vulnerability, please report it responsibly.

  1. 1. Do NOT publicly disclose the vulnerability.
  2. 2. Email security@apex-ai.dev with details.
  3. 3. Include: affected version, steps to reproduce, potential impact.
  4. 4. We will acknowledge within 48 hours and provide a fix timeline.
  5. 5. We will credit you in the security advisory (unless you prefer to remain anonymous).

Supported Versions

v2.0.0Active
Full support, security patches
v2.0.0Active
Current production release