-
Notifications
You must be signed in to change notification settings - Fork 1
Security Model
Amadeus is designed with defence-in-depth across authentication, network isolation, secret management, prompt injection resistance, and tool execution safety.
v4.0.0 introduced the centralized Tool Policy Engine for deterministic safety gates.
| Aspect | Implementation |
|---|---|
| Algorithm | JWT HS256 via python-jose
|
exp claim |
Required in production; accepted without exp in development |
| Rate limiting | Keyed by sub (user ID); falls back to IP for unauthenticated requests (SlowAPI) |
| Redis fallback | If Redis is unreachable at startup, rate limiter falls back to in-memory storage (v3.2.1+) |
| RBAC |
admin / user / guest roles enforced per route |
File: src/infra/tools/policy.py
The ToolExecutor now passes every request through a deterministic policy layer before execution. This engine evaluates the tool's RiskLevel against the active PermissionProfile.
| Level | Description | Example Tools |
|---|---|---|
LOW |
Read-only, safe local operations |
get_time, list_tasks, get_cpu_usage
|
MEDIUM |
Modifies local non-system state |
add_task, set_volume, create_note
|
HIGH |
Network external or sensitive local |
send_email, web_search, delete_file
|
CRITICAL |
System destructive or code execution |
terminate_process, execute_python_script
|
-
READ_ONLY Profile: Automatically blocks all
HIGHandCRITICALtools. Blocks any tool withmodifies_filesystem=Trueormodifies_system_state=True. -
Destructive Guard: Ensures tools tagged as
CRITICALalways have therequires_confirmationflag set. -
Process Protection: Explicitly blocks attempts to terminate protected system processes (e.g.,
explorer.exe,kernel). -
Argument Tokenization: Inspects shell commands for forbidden tokens like
rm -rf /ormkfs.
TelegramAdapter._handle_message() enforces a MASTER_TELEGRAM_CHAT_ID allowlist. Set comma-separated chat IDs in .env:
MASTER_TELEGRAM_CHAT_ID=123456789,987654321Messages from any other chat_id receive "Unauthorized." and are dropped before processing.
All user task text is sanitised before entering the ReAct prompt:
- Wrapped in
<user_task>...</user_task>XML boundary tags - ReAct control tokens found in the user input (
Action:,Thought:,Action Input:,Observation:,FINISH) are replaced with[BLOCKED:TOKEN]markers
This prevents users from injecting LLM directives via Telegram, WhatsApp, or the HTTP API to make the agent execute arbitrary tools.
- All API keys loaded from environment variables — never hardcoded.
-
.env.prod,.env.staging,.env.localare in.gitignore. - GitGuardian pre-commit hook scans for leaked secrets before every commit.
-
SEC-06 (v3.2.1+):
SECRET_KEYauto-generates a cryptographically-secure 32-byte ephemeral key at startup if not set. AWARNINGis logged urging operators to set a persistent key. -
IPC Token (v3.2.1+):
data/ipc_secret.token(chmod 600). Corruption (non-UTF-8, empty, OS error) is caught specifically; aCRITICALlog entry names the file path and warns that connected IPC clients will need to re-authenticate before regenerating.
Destructive tools require explicit approval with a 60-second timeout (auto-deny on timeout):
terminate_process · terminate_program · delete_file · execute_python_script
fs_write_file · send_outlook_email · send_email · send_slack_message
copy_file, move_file, and create_folder all call _assert_in_allowed_dirs() which resolves the full canonical path and validates it against SEARCH_ALLOWED_DIRS:
# .env
SEARCH_ALLOWED_DIRS=/home/user/Documents,/home/user/DownloadsPath traversal attempts (e.g. ../../etc/passwd) return "Access denied: path …" without touching the filesystem.
Amadeus supports both Docker and a lightweight local sandbox. Set SANDBOX_MODE in .env:
| Mode | Technology | Best For |
|---|---|---|
docker |
Ephemeral Containers | High-security, Linux-based production |
local |
Multiprocessing | Windows, restricted environments, development |
auto |
Auto-detect | Default: prefers Docker, falls back to local |
The local sandbox uses Restricted Globals (disabling __import__, open, eval) and runs code in a separate process for isolation.
| Port | Exposed to Host? |
|---|---|
6379 (Redis) |
❌ Internal only |
5432 (PostgreSQL) |
❌ Internal only |
8000 (API) |
✅ Exposed |
Both data services are internal to the amadeus-network Docker bridge. There is no route from the internet to Redis or PostgreSQL without going through the application layer.
| Aspect | Detail |
|---|---|
| Log format | JSON via structlog
|
| Request tracing |
request_id UUID attached to every request; returned as X-Request-ID header |
| Sensitive data | API keys, raw prompts, auth tokens are never logged (OWASP-hardened) |
| Log files |
data/logs/amadeus.log (rotating, 10 MB, 5 backups) |
| Metrics |
/api/v1/metrics includes amadeus_tool_executions_total for per-tool result breakdown |
| Episodic Memory | Every plan step and reflection is stored in the database for post-hoc behavioral audit. |
See SECURITY.md for the responsible disclosure process.
Amadeus-AI · v6.0.0· Apache License 2.0 · Report a Bug
Getting Started
Architecture
Reference
Integrations
Operations
Development
Project
Links