PolyClaw Trading is designed from the ground up so that secrets — API keys, private keys, proxy credentials, and RPC URLs with embedded tokens — can never inadvertently end up in tracked files, build artifacts, log output, or theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/deniszidbaev-cmyk/polyclaw-trading/llms.txt
Use this file to discover all available pages before exploring further.
runtime/ state directory. This page documents every layer of that protection and the steps to take when a secret is suspected to have been exposed.
Where secrets live
Secrets are permitted in exactly two places:.env.local— a file in the project root that is listed in.gitignoreand is never committed to version control. Copy.env.exampleto.env.localand fill in only the values you need.- Environment variables — injected directly into the process environment by your shell, CI system, Docker secrets, or a secrets manager.
- Any tracked source file (
.py,.json,.md,.yml, and so on) - Log files or terminal output
runtime/files (these are generated state only — see the Runtime Files reference)~/.openclaw/openclaw.jsonexcept through the designated patching script described below- HTTP request URLs (API keys must always be sent as headers)
Build-time secret scanner
tests/test_secret_scanner.py fails the CI build if any secret-like pattern is detected in workspace-tracked files. This is an unconditional gate: the test suite cannot pass while a secret is present in a tracked file. The scanner detects API keys, private keys in PEM format, Google API keys, Telegram bot tokens, and hardcoded credential variable assignments. Common placeholder values used in .env.example are excluded from flagging to prevent false positives.OpenClaw config patching
The file~/.openclaw/openclaw.json is secret-bearing (it may contain API keys and gateway tokens). It must only ever be modified through openclaw_patch.py:
openclaw_patch.py performs the following sequence before every write:
- Reads the current
~/.openclaw/openclaw.json. - Creates a timestamped backup (e.g.
~/.openclaw/openclaw.json.20260101T120000.bak). - Applies the patch atomically.
~/.openclaw/openclaw.json is unsupported and bypasses the backup mechanism.
HTTP client security
All outbound HTTP requests made by the pipeline enforce the following rules, regardless of the endpoint:- HTTPS only. Any URL that does not begin with
https://raises aConfigErrorat startup. Hardcoded internal URLs (gamma-api.polymarket.com,clob.polymarket.com) are validated atEngineConfiginstantiation time. - No redirects. The HTTP client is configured to refuse all redirects to prevent credential forwarding to unexpected hosts.
- Official-host allowlist. Only Polymarket’s official API hostnames are permitted as targets for authenticated requests. Attempts to contact unlisted hosts are rejected.
- Response-size cap. Responses larger than
HTTP_MAX_BYTES(default 8 MB) are truncated and the request fails closed. - Credentials never in URLs. API keys and tokens are always sent as HTTP headers. The Gemini API key, for example, was moved from URL query strings to secure headers in release 0.2.0 (#46).
- Proxy credentials redacted. If
HTTPS_PROXYcontains embedded credentials, they are masked before any log output is written.
Secret redaction
The redaction layer is synchronized between two modules —openclaw_bot.io.runtime and polyclaw_engine.execution — so that both the LLM orchestration loop and the deterministic execution path apply identical masking rules.
Redaction masks the following patterns wherever they appear in log output, runtime artifacts, or subprocess output:
- OpenRouter, OpenAI, Anthropic, and Gemini API keys
- Polymarket private keys
- HTTPS proxy credentials (username:password in proxy URLs)
- Telegram bot tokens (standalone occurrences)
- Generic
keyparameters in URLs (e.g.?key=abc123) - Key-value pairs in JSON objects where the key name matches a known secret field
- Key-value pairs in shell-style assignments where the key name matches a known secret field
Dashboard safety
The Mission Control dashboard (bot/dashboard/app.py) is read-only by design:
- Loopback by default. The Flask app binds to
127.0.0.1unlessDASHBOARD_HOSTis explicitly overridden. - Auth token required for non-local binding. If
DASHBOARD_HOSTis set to a non-loopback address,DASHBOARD_AUTH_TOKENmust also be set. Requests without the correct Bearer token orX-Auth-Tokenheader receive HTTP 401. If the token is absent and the host is non-loopback, the server falls back to127.0.0.1. - Runtime filename whitelist. Files served from
runtime/are validated against a strict filename regex before the path is resolved. This prevents path traversal attacks and ensures only the known runtime JSON files can be read through the dashboard API (#1197). - No writes through the dashboard. The dashboard exposes only
GETendpoints for viewing equity, P&L, decisions, execution ledger, source health, and drawdown state.
File permissions
Sensitive local files are enforced to owner-only permissions (0600):
.env.local~/.openclaw/openclaw.json- Daily log files
tests/test_file_permissions_sentinel.py verifies these permissions programmatically so they cannot silently regress.
Vulnerability reporting
Report security vulnerabilities privately via GitHub Security Advisories. Do not open a public issue for security problems. You can expect an initial response within a few days. Only the latest release (main) is supported with security fixes.
Particularly relevant areas for this project:
- Secret leakage into tracked files, logs, or runtime artifacts.
- Bypasses of the trade gate (
trade_gate.py): dry-run/live enforcement, daily caps, circuit breaker (PANIC_STOP/ auto-panic). - Command injection in PolyClaw subprocess invocations.
- Dashboard authentication and binding weaknesses (
bot/dashboard/).
Secret rotation
If you suspect a secret has been exposed:- Rotate it immediately. Generate a new API key or private key from the relevant provider.
- Treat the associated wallet as compromised until you have verified no unauthorized transactions have occurred.
- Update
.env.localwith the new value (or set the new environment variable in your deployment environment). - Restart the pipeline. The engine will pick up the new credentials on the next cycle without requiring any code changes.
- If a private key was exposed, revoke it at the wallet level and transfer funds to a new wallet before resuming live trading.