Api Key Least Privilege Audit Tool logo

Api Key Least Privilege Audit Tool

Community
HimanshuJ16
api-key-least-privilege-audit-tool

Use before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft.

Overview

PublisherHimanshuJ16
RepositoryAlgo-Trading-Skills
Skill nameapi-key-least-privilege-audit-tool
Stars
50
Forks
7
Bundled files
5
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by HimanshuJ16 on GitHub. Read the source before you install it.

Installation

Install the Api Key Least Privilege Audit Tool AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/api-key-least-privilege-audit-tool
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/HimanshuJ16/Algo-Trading-Skills.git /tmp/Algo-Trading-Skills
mkdir -p .claude/skills
cp -r /tmp/Algo-Trading-Skills/skills/api-key-least-privilege-audit-tool .claude/skills/api-key-least-privilege-audit-tool
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Api Key Least Privilege Audit Tool in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Api Key Least Privilege Audit Tool on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Api Key Least Privilege Audit Tool is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

When to Use

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.

When NOT to Use

  • Brokers without granular permission scopes: If the broker exposes only a single all-or-nothing API key with no scope metadata to audit, this tool cannot perform meaningful analysis. Use network-level isolation (IP allowlisting, VPN) instead.
  • Pre-deployment key creation: This skill audits existing keys, it does not create or modify broker API key scopes. Use broker-specific key creation tooling.
  • Secrets storage or rotation: This skill does not handle credential storage, encryption, or rotation. See secrets-rotation-without-bot-downtime and crypto-wallet-key-custody-security.
  • OAuth or session-based auth: The auditor checks static API key scopes, not OAuth token scopes or session permissions. OAuth flows require their own scope validation.
  • As an enforcement control: This is a client-side gate. It cannot revoke, downgrade or constrain a key, and an attacker holding a withdrawal-capable key calls the broker directly without ever running it. It catches misconfiguration before deployment; the broker's own scope selection and IP restriction are what actually constrain the key.

Prerequisites

  • Broker API key metadata or active permissions response, from either the venue's key-permission endpoint (probed) or an operator-maintained record of how the key was configured (declared). Not every venue offers the former — see references/standards.md for which do.
  • Target bot role definition (MARKET_DATA_ONLY, EXECUTION_BOT, PORTFOLIO_MONITOR, or ADMIN_SUPERVISOR).
  • A mapping from the venue's native scope names onto the canonical scope names used by the policy matrix.

Workflow

  1. Define Role Security Policy:

    • Establish required, allowed and forbidden permissions per bot role (e.g. EXECUTION_BOT requires ["read_market_data", "place_orders", "cancel_orders"] and forbids ["withdraw_funds", "account_admin", "transfer"]).
    • The check is deny-by-default: any scope absent from the role's allowed set is a violation even when it is not explicitly forbidden. This is what makes an unmapped broker-native scope name fail closed.
    • ADMIN_SUPERVISOR is the only role permitted administrative scopes (account_admin, api_key_manage), and still forbids withdrawal/transfer permissions.
  2. Establish the Granted Scope Set — and read the key's permissions, not the account's:

    • Binance Spot: GET /sapi/v1/account/apiRestrictions (returns enableWithdrawals, enableInternalTransfer, permitsUniversalTransfer, ipRestrict, …).
    • Coinbase Advanced Trade: GET /api/v3/brokerage/key_permissions (returns can_view, can_trade, can_transfer).
    • Kraken and Zerodha Kite document no endpoint returning the calling key's own permissions. Take the scope set from an operator-maintained record instead, and mark the audit as declared — it proves the record is compliant, not that the live key is.
    • Map native scope names onto the canonical names before auditing. Both venues above return boolean flags, not a scope list — pass only the flags whose value is true. Handing the raw response (or its keys) to the auditor audits the field names, so a key with enableWithdrawals: false is flagged as holding withdrawal rights.
  3. Audit Excess Privileges:

    • Compare granted key scopes against the role policy.
    • All comparisons are case-insensitive; blank entries are discarded.
    • A wildcard * permission is always flagged as a critical violation regardless of role — unrestricted access must never be granted to an automated bot.
    • Malformed input is rejected, not audited: a bare string is iterable, and auditing "read_market_data" character by character would yield a confident report about scopes that do not exist.
  4. 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: see references/standards.md. Printable pre-flight checklist: see assets/checklist.md.

Common Pitfalls

  • Auditing the account instead of the key: Binance 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.
  • Treating an empty scope set as a safe key: a failed or partially-authenticated probe returns nothing, and an empty set contains no forbidden scope. A gate that inspects only excess_violations sees an empty list and deploys. The auditor never reports an empty set as compliant and says so explicitly in the warning.
  • Wildcard Permission Defaults: Using default broker "Full Access" or * permission settings during key creation. The auditor always flags * as a critical violation.
  • Ignoring IP Whitelisting: Treating scope reduction as sufficient while failing to bind keys to specific static IP addresses. Binance makes IPv4 access restriction mandatory to enable withdrawal permission — but that coupling is venue product policy, not a general rule, so verify IP binding on every venue independently.
  • Unmonitored Sub-Account Keys: Overlooking API keys created on master accounts that inherit master withdrawal rights.
  • Case-Sensitive Scope Mismatch: Broker APIs may return scopes in varying case (e.g., Read_Market_Data vs read_market_data). The auditor normalizes all scopes to lowercase before comparison.
  • Admin Keys with Withdrawal Rights: Even ADMIN_SUPERVISOR roles must not possess withdrawal or transfer permissions — admin access is for oversight, not capital movement.
  • String-matching the warning message: security_warning is human-readable prose and its wording changes. Gate on report.severity / report.has_critical_violation.

Verification

  • Submit over-privileged key metadata (possessing withdraw_funds on an execution bot) and verify security violation detection with severity == "CRITICAL_VIOLATION".
  • Submit a key with wildcard * permission and verify it is flagged as a critical violation for every role.
  • Verify a properly scoped execution key passes with severity == "COMPLIANT".
  • Verify an under-privileged key reports INSUFFICIENT_PERMISSIONS and not a critical violation.
  • Verify an empty scope set is non-compliant and its warning names the failed-probe possibility.
  • Verify an unmapped broker-native scope (enableWithdrawals, can_transfer) is flagged rather than ignored.
  • Verify case-insensitive matching (Read_Market_Data is accepted for read_market_data).
  • Verify a bare string or None passed as granted_permissions raises TypeError.
  • Verify report list ordering is identical across PYTHONHASHSEED values.
  • Run python -m unittest discover -s skills/api-key-least-privilege-audit-tool/scripts and confirm 100% pass rate.

Related Skills

  • crypto-wallet-key-custody-security
  • secrets-rotation-without-bot-downtime
  • token-lifecycle-live-probing
  • sandbox-credential-leakage-prevention
  • exchange-withdrawal-whitelist-enforcement

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Api Key Least Privilege Audit Tool AI skill do?

Use before deploying a live bot, to audit existing broker API keys for scopes they do not need. Flags withdrawal, transfer and admin rights that turn a leaked execution key into theft.

Why use Api Key Least Privilege Audit Tool on TypingMind?

Because you install it once and use it with any model. Api Key Least Privilege Audit Tool is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Api Key Least Privilege Audit Tool in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/HimanshuJ16/Algo-Trading-Skills/tree/main/skills/api-key-least-privilege-audit-tool. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Api Key Least Privilege Audit Tool?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Api Key Least Privilege Audit Tool?

As many as you like. As long as a model supports skills, you can use Api Key Least Privilege Audit Tool with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Api Key Least Privilege Audit Tool AI skill free?

Yes. It is published on GitHub by HimanshuJ16 under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇