/algo-trading-skills:api-key-least-privilege-audit-toolfrom algo-trading-skills
Audits broker API keys for excessive scopes before deploying live trading bots. Flags withdrawal, transfer, and admin rights that turn a leaked key into theft.
Ships in algo-trading-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Invoke this skill prior to deploying any live trading bot or data pipeline to verify that API credentials strictly adhere to the principle of least privilege. Granting unnecessary permissions (such as account withdrawal, funds transfer, or administrative management) to an execution or data-ingestion bot creates catastrophic security vulnerabilities. If a key is leaked or compromised, excess privileges enable external theft.
secrets-rotation-without-bot-downtime and crypto-wallet-key-custody-security.references/standards.md for which do.MARKET_DATA_ONLY, EXECUTION_BOT, PORTFOLIO_MONITOR, or ADMIN_SUPERVISOR).Define Role Security Policy:
EXECUTION_BOT requires ["read_market_data", "place_orders", "cancel_orders"] and forbids ["withdraw_funds", "account_admin", "transfer"]).ADMIN_SUPERVISOR is the only role permitted administrative scopes (account_admin, api_key_manage), and still forbids withdrawal/transfer permissions.Establish the Granted Scope Set — and read the key's permissions, not the account's:
GET /sapi/v1/account/apiRestrictions (returns enableWithdrawals, enableInternalTransfer, permitsUniversalTransfer, ipRestrict, …).GET /api/v3/brokerage/key_permissions (returns can_view, can_trade, can_transfer).enableWithdrawals: false is flagged as holding withdrawal rights.Audit Excess Privileges:
* permission is always flagged as a critical violation regardless of role — unrestricted access must never be granted to an automated bot."read_market_data" character by character would yield a confident report about scopes that do not exist.Branch on Severity, Not on Warning Text:
CRITICAL_VIOLATION (report.has_critical_violation) — the key holds scopes it must not have. Block deployment and revoke the key; it is dangerous whether or not it ships.INSUFFICIENT_PERMISSIONS — the key lacks scopes the role needs. Block deployment and re-issue. Not a revocation event.COMPLIANT — scope policy satisfied. Verify IP binding separately before treating this as a clean bill of health.Full procedure: see
references/workflows.md. Standards reference: seereferences/standards.md. Printable pre-flight checklist: seeassets/checklist.md.
GET /api/v3/account returns canTrade / canWithdraw / canDeposit, which describe the account, not the API key's granted scopes — Binance does not document them as key-permission flags. Coinbase GET /api/v3/brokerage/accounts likewise lists accounts, not permissions. Auditing either reads a payload that cannot contain a violation, so every key passes.excess_violations sees an empty list and deploys. The auditor never reports an empty set as compliant and says so explicitly in the warning.* permission settings during key creation. The auditor always flags * as a critical violation.Read_Market_Data vs read_market_data). The auditor normalizes all scopes to lowercase before comparison.ADMIN_SUPERVISOR roles must not possess withdrawal or transfer permissions — admin access is for oversight, not capital movement.security_warning is human-readable prose and its wording changes. Gate on report.severity / report.has_critical_violation.withdraw_funds on an execution bot) and verify security violation detection with severity == "CRITICAL_VIOLATION".* permission and verify it is flagged as a critical violation for every role.severity == "COMPLIANT".INSUFFICIENT_PERMISSIONS and not a critical violation.enableWithdrawals, can_transfer) is flagged rather than ignored.Read_Market_Data is accepted for read_market_data).None passed as granted_permissions raises TypeError.PYTHONHASHSEED values.python -m unittest discover -s skills/api-key-least-privilege-audit-tool/scripts and confirm 100% pass rate.crypto-wallet-key-custody-securitysecrets-rotation-without-bot-downtimetoken-lifecycle-live-probingsandbox-credential-leakage-preventionexchange-withdrawal-whitelist-enforcementWhat SKILL.md sets; muted values are Claude Code's defaults
36 skills in this plugin
/alpaca-paper-live-key-separationUse when a bot connects to the Alpaca Trading API and must never cross paper keys with the live endpoint; pins the base URL per environment, checks the key prefix, probes /v2/account and requires an explicit ALLOW_LIVE_TRADING flag./broker-account-margin-call-handlingUse when a bot trades a Reg T, portfolio or futures margin account and must act before the broker liquidates: tiered maintenance-margin warnings cross-checked against broker excess liquidity, initial-margin order gating and liquidity-aware de-leveraging./broker-agnostic-adapter-interfacenpx claudepluginhub himanshuj16/algo-trading-skills --plugin algo-trading-broker-integrationOther plugins' skills for the same job