Skip to main content

Agent Permission Linter (apl) — v0.1.0

Early release (v0.1.0). Feedback welcome — open an issue or see SECURITY.md for private reports.

Checks the configs and files you give it for AI agents that hold more power than their declared task needs. A finding is granted capability exceeding required capability.

apl reads your MCP client configs (Claude Desktop, Claude Code, VS Code, Cursor, Windsurf), an optional agent.yaml that declares what the agent is for, saved tools/list results, and optionally your Entra app registrations through Microsoft Graph.

  • MCP (Model Context Protocol): the protocol AI clients use to connect an agent to tool servers.
  • Entra (Microsoft Entra ID, formerly Azure AD): Microsoft's identity service, where app registrations and their Microsoft Graph permissions live.
  • tools/list: the MCP request that returns a server's tools, with their names, descriptions, input schemas and annotations. apl reads a saved copy of the response; see Saved tools/list files.

Client caveats: the Windsurf docs now redirect to Devin, and the documented config path is ~/.config/devin/mcp_config.json (ASSUMPTIONS A5). VS Code settings.json → mcp.servers is not in the current official VS Code docs; apl still parses it but marks every server from it as an unverified format (A3).

It reports, for example, an agent whose purpose is "write release notes" but that can delete repositories, or an Entra app granted Mail.ReadWrite behind a server whose tools only read mail.

Read-only. It never starts or contacts an MCP server (--connect is refused). Entra access is optional and GET-only, with the token held in memory. There is no apply command. Secrets are redacted at parse time and again on every output; only env var names are stored. Redaction can miss some secrets: see limits 5 to 7 and 10 in docs/THREAT_MODEL.md.

Privacy. Reports never print raw tenant, client, or object IDs. They print pseudonyms (app-3f9a1c, tenant-9b02e4) keyed by a per-install salt (APL_ID_SALT, or a file under %APPDATA%\apl on Windows / ~/.config/apl elsewhere). With no usable salt, apl refuses to print rather than leak the raw ID. See src/apl/idmask.py and R19 in docs/ASSUMPTIONS.md.

Quickstart (5 minutes)

1. Install

Python 3.11 or later.

git clone https://github.com/Shrebibelagur/agent-permission-linter.git && cd agent-permission-linter
python -m venv .venv
# Windows: .venv\Scripts\activate    Linux/macOS: source .venv/bin/activate
pip install -e '.[dev]'

PowerShell:

git clone https://github.com/Shrebibelagur/agent-permission-linter.git; cd agent-permission-linter
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -e '.[dev]'

2. Run the offline demo

No tenant, no credentials, no network:

apl scan -c tests/fixtures/configs/claude_desktop.json \
  -a tests/fixtures/agents/release_notes_bot.yaml \
  -t tests/fixtures/tools/claude_desktop_tools.json \
  --format md --out report.md --fail-on high
echo $?   # 1: at least one finding at or above "high"

PowerShell:

apl scan -c tests/fixtures/configs/claude_desktop.json -a tests/fixtures/agents/release_notes_bot.yaml -t tests/fixtures/tools/claude_desktop_tools.json --format md --out report.md --fail-on high
$LASTEXITCODE   # 1: at least one finding at or above "high"

It prints warning: github/delete_repository: possible prompt injection in tool metadata. That is deliberate: the fixture's description for that tool contains an injection phrase, to show that apl notices it and does not act on it.

Then the Entra demo, over saved Graph-shaped responses:

apl scan -c tests/fixtures/entra/mcp.json -t tests/fixtures/entra/tools.json \
  --entra-mock tests/fixtures/graph

PowerShell:

apl scan -c tests/fixtures/entra/mcp.json -t tests/fixtures/entra/tools.json --entra-mock tests/fixtures/graph

It reports an over-scoped Mail.ReadWrite grant, ownerless apps and expired or long-lived credentials.

The well-scoped fixture produces no findings (tests/snapshots/clean.md). The same command works in bash and PowerShell:

apl scan -c tests/fixtures/clean/mcp.json -a tests/fixtures/clean/agent.yaml -t tests/fixtures/clean/tools.json

3 checks run and 3 are not evaluated there, so "no findings" covers only the 3 checks that ran.

3. Scan your own tenant (read-only)

Create a dedicated app registration for the scanner. Live mode has been tested only against Graph-shaped fixtures, not a real tenant, so try it in a lab tenant first.

  1. In the Microsoft Entra admin center: App registrations → New registration. Single tenant, no redirect URI.

  2. API permissions → Add a permission → Microsoft Graph → Application permissions. Add exactly these two:

    Permission Type Used for
    Application.Read.All Application applications, service principals, owners, app role assignments
    Directory.Read.All Application oauth2PermissionGrants (delegated consents); least privilege for that call

    Remove the default delegated User.Read; the scanner does not use it. Then Grant admin consent. Do not add any ReadWrite permission: apl never writes.

  3. Certificates & secrets → New client secret, with the shortest expiry that suits you. Copy the value once. Do not save it in a file.

  4. Set the three variables in the shell that runs apl. apl does not read .env files.

    PowerShell:

    $env:TENANT_ID = "<directory (tenant) id>"
    $env:CLIENT_ID = "<application (client) id>"
    $env:CLIENT_SECRET = Read-Host -MaskInput "client secret"
    

    -MaskInput needs PowerShell 7.1 or later. In Windows PowerShell 5.1, use this instead. It also never echoes the secret:

    $s = Read-Host -AsSecureString "client secret"
    $env:CLIENT_SECRET = [System.Net.NetworkCredential]::new("", $s).Password
    Remove-Variable s
    

    bash:

    export TENANT_ID=... CLIENT_ID=...
    read -rs CLIENT_SECRET && export CLIENT_SECRET
    
  5. Scan:

    apl scan -c ~/.cursor/mcp.json -a agent.yaml -t tools.json --entra --format sarif --out apl.sarif
    

    tools.json is a saved tools/list result for your servers; see the next section.

  6. When you are done, clear the secret from your session (Remove-Item Env:CLIENT_SECRET in PowerShell, unset CLIENT_SECRET in bash), then delete the client secret, or the whole app registration.

The token is fetched with the OAuth2 client-credentials flow over REST and kept in memory. The HTTP client refuses anything but GET https://graph.microsoft.com/.... Details: G1 to G12 in docs/ASSUMPTIONS.md.

Saved tools/list files

apl never contacts a server, so it cannot list tools itself. Save the tools/list JSON response from your MCP client or server, and pass it with -t. The file can be any of these (ASSUMPTIONS S9):

  • the JSON-RPC response: {"result": {"tools": [...]}}

  • the bare result: {"tools": [...]}

  • a map from server name (as in the client config) to either of the above. This is apl's own format, not the spec's:

    { "github": { "result": { "tools": [] } }, "filesystem": { "tools": [] } }
    

    A server in your config with no matching entry is reported as "no tool list; capabilities unknown".

The first two only apply when the config has exactly one server; otherwise the file is ignored with a warning. For several servers, use the map. resultType must be missing or "complete", and the file is assumed to hold the full list (pagination is ignored, S3). A server with no tool list is reported as "capabilities unknown".

Declaring the purpose: agent.yaml

Rules compare what an agent can do with what it says it needs. Without agent.yaml, rules that need a purpose report "not evaluated" instead of passing.

name: release-notes-bot
purpose: Read merged pull requests in one repo and draft release notes as a GitHub issue.
owner: release-team@contoso.example
invokers: single            # or multiple; APL-002 skips without it
servers:
  - server: github
    required_capabilities: [read, write]
    required_tools: [create_issue]   # listed tools count as declared, even if powerful
    justification: Read PRs; create one issue with the draft.
    approval_gate: true
  - server: mail
    required_capabilities: [network]
    entra_app_id: <application (client) id>   # links the server to its Entra app
justifications:             # APL-006: why each high-risk permission is needed
  Mail.Send: Sends the weekly digest to the team list.

Unknown keys are rejected. Fields are defined in AgentSpec and ServerPurpose in src/apl/models.py; a full example is tests/fixtures/agents/release_notes_bot.yaml.

Sample report

From the offline demo above. Excerpt of report.md (full report: tests/snapshots/dirty.md):

| Severity | Violations | Review required |
|---|---:|---:|
| critical | 0 | 0 |
| high | 2 | 0 |
| medium | 3 | 0 |
| low | 0 | 1 |
| info | 0 | 0 |
| **total** | **5** | **1** |

| ID | Severity | Status | Confidence | Tool / server | Title |
|---|---|---|---:|---|---|
| `APL-007:3bad258035a6` | high | violation | 0.90 | `github/delete_repository` | Tool capability exceeds declared purpose |
| `APL-007:809789a2e28a` | high | violation | 0.90 | `graph/runGraphQuery` | Tool capability exceeds declared purpose |
| `APL-007:c07f49f8482e` | medium | violation | 0.70 | `filesystem/move_file` | Tool capability exceeds declared purpose |
| `APL-007:ac981277f1c4` | medium | violation | 0.70 | `filesystem/write_file` | Tool capability exceeds declared purpose |
| `APL-007:13097d7d2403` | medium | violation | 0.70 | `github/push_files` | Tool capability exceeds declared purpose |
| `APL-007:6eb85aaeb952` | low | review_required | 0.00 | `graph/frobnicate` | Review required: tool capability could not be established |

| Rule | Subject | Reason |
|---|---|---|
| APL-001 | `github` | not evaluated: missing granted scopes (run with --entra or --entra-mock) |
| APL-002 | `release-notes-bot` | not evaluated: missing agent.yaml invokers |
| APL-010 | `github` | not evaluated: missing auto-approve list (no autoApprove/alwaysAllow in config) |

Each finding also gets a fix, its evidence (file and JSON pointer), a confidence with its reason, and framework references labelled "suggested mapping". A rule that lacks its input is listed under Not evaluated, never passed silently.

Rules

Rule Finds Needs
APL-001 Granted scope broader than any tool on the server needs --entra or --entra-mock, tools
APL-002 Maker-mode (the agent runs on one person's own token, such as a PAT, so every invoker gets that person's access) or shared credential: one token for every invoker agent.yaml invokers
APL-004 Entra app linked to a server has no owner Entra
APL-005 Linked credential with no expiry, expired, or lifetime over 180 days Entra
APL-006 High-risk Graph permission with no justification in agent.yaml Entra, agent.yaml
APL-007 Tool capability exceeds the declared purpose tools, agent.yaml
APL-010 High-impact tool auto-approved with no human gate tools, autoApprove/alwaysAllow in config

The gaps in the numbering are rules that are planned but not built: APL-003 and APL-009 (Entra data) and APL-008 (missing audience binding, ASSUMPTIONS S7).

apl scan flags

Option Meaning
-c/--config MCP client config (repeatable). JSONC accepted.
-a/--agent agent.yaml: the declared purpose (optional; some rules skip without it)
-t/--tools saved tools/list result(s), offline (optional; capability rules skip without it)
-f/--format md (default), json (schema_version 1.0), sarif (2.1.0; SARIF is the standard JSON format for static-analysis results, which code-scanning tools import)
-o/--out write the report to a file instead of stdout
--fail-on none (default), low, medium, high
--entra-mock DIR read saved Graph responses from DIR (no network, no credentials)
--entra read Entra live through Graph, GET only. Needs TENANT_ID, CLIENT_ID, CLIENT_SECRET
--connect refused in v0.1 with exit code 2: apl never contacts an MCP server
--show-ids print real Entra ids, for local debugging only. Warns on stderr and marks the report. Secrets stay redacted, and finding ids do not change
--show-urls print full URLs, for local debugging only. Warns on stderr and marks the report: a first line in md, "contains_real_urls": true in json, and a note in sarif. By default every URL prints as scheme://host/[path-redacted], as a path can hold a secret. Userinfo and query strings are always removed
--anonymise-names replace Entra display names and server, agent and owner names with pseudonyms. In apl inventory, command, url and args become [cmd-N], [url-N] and [arg-N], so nothing derived from them prints; [REDACTED] args stay as they are. Free text prints as written: purpose, justification text and env_keys, so review before sharing; apl scan and apl inventory say so on stderr, and reports say so in their limits. Also still prints: finding titles; permission names, including custom ones that may name your organisation (Contoso.Frobnicate); tool names, including those that contain a server name (payroll_search); environment variable and header names; config file paths; capabilities, severities, rule ids and evidence dates; and, in apl inventory, the agent's data_classification and justifications, plus required_tools and required_graph_permissions

Exit codes: 0 no finding at or above --fail-on · 1 at least one (use in CI) · 2 parse, write or Entra error, or --connect.

apl inventory -c ... [-a ...] [-t ...] prints the parsed, redacted inventory as JSON. It takes --show-ids, --show-urls and --anonymise-names too.

Identifiers and APL_ID_SALT

Reports never print a full tenant, client or object id. They print a pseudonym such as app-3f9a1c: a keyed hash, the same on every run of one install. Secrets are different: they are removed as [REDACTED] and are never hashed.

The key is a salt, which is what stops someone who has a report from checking a guessed id. It comes from the APL_ID_SALT environment variable, at least 16 characters. If that is not set, apl creates a random one on first use and keeps it outside the repo: %APPDATA%\apl\id_salt on Windows, $XDG_CONFIG_HOME/apl/id_salt (default ~/.config/apl/id_salt) elsewhere.

  • Never commit it. apl scrubs it from its own output like a secret.
  • Set the same value on CI. Finding ids for Entra apps depend on the salt, so laptops and CI with different salts report different ids for the same finding, and baselines and SARIF deduplication break. Changing or losing it changes those ids and every pseudonym.
  • No usable salt stops the scan with exit code 2: apl does not fall back to printing raw ids.
python -c "import secrets; print(secrets.token_hex(32))"

Random-looking tokens

Known token shapes are always removed. On top of that, any token of 20 or more characters in a server's command or args becomes [REDACTED] if it looks random (mixed case and digits, high entropy). Only that token goes, so C:/keys/<token>/run.exe keeps its path. No flag brings it back. It can over-redact a random-looking build id. Low-entropy secrets, single-case hex, anything under 20 characters, anything split by separators, and exact-match secrets under 8 characters are missed (THREAT_MODEL limit 7). See R22 in docs/ASSUMPTIONS.md.

Limits and honesty

The classifier

APL-001, APL-007 and APL-010 depend on a classifier that turns each tool into capabilities (read, write, delete, execute, network) from its name, its MCP annotations and the names of its inputSchema parameters. Descriptions are never used. A name with no recognised verb is unknown with "review required", not guessed.

No number below is an accuracy number. Every corpus in this repo has been used to develop the classifier, so these are regression checks. A real accuracy figure needs a new held-out set of real tools, labelled blind and measured once. That has not been done.

A held-out set is a corpus kept apart from development, to test the classifier on tools it was not tuned on. Current results, classifier v2 (ASSUMPTIONS E7):

Corpus Tools Exact Missing (understated) Missing + unclassified
main 48 37 (77%) 2 (4%) 5
held-out #1 45 33 (73%) 2 (4%) 6
held-out #2 43 26 (60%) 1 (2%) 17
held-out #3, name only 36 12 (33%) 3 (8%) 22
held-out #3, name + schema 36 11 (31%) 3 (8%) 12

The closest thing to an independent measure is each held-out set's first run, before anything was changed in response to it:

  • Held-out #2 (E3), names only: 21/43 exact (49%), 3 missing (7%), 18 unclassified (42%). About 4 in 10 tools needed human review.
  • Held-out #3 (E6), the first set with parameter names: with schema signals, 10/36 exact, 4 missing, 13 extra, 9 unclassified. Schema signals cut "no answer" from 19 to 9 but added false writes: all 6 read tools with generic parameter names (text, data, content) gained a false write. Those now give low reviews, not violations (E7), but the false capability remains.

"Missing" means the classifier understated a tool, the dangerous error. "Unclassified" is flagged for review, not silent.

Where the numbers come from: hand-labelled corpora in tests/fixtures/tool_corpus*.yaml, bucketed by tests/corpus_report.py. Reproduce them with:

pytest -s tests/test_classifier_corpus.py tests/test_classifier_holdout*.py

PowerShell does not expand * for native commands, so list the files:

pytest -s tests/test_classifier_corpus.py (Get-ChildItem tests/test_classifier_holdout*.py).FullName

The corpora are hand-written tool names, not tools from real servers, and are small (36 to 48 tools each). History and caveats for every row: E1 to E7 in docs/ASSUMPTIONS.md.

What else it cannot do

  • A server that lies consistently is not caught. Tool names are chosen by the server. Renaming run_pipeline to run_report turns a high violation into a low review; a name and parameters that agree are trusted.
  • Live Entra mode is untested against a real tenant.
  • Pseudonymous, not anonymous. Permission names (including custom ones that name the organisation), tool names, env var and header names, and config paths still print. Pseudonyms are 24 bits and can be confirmed by anyone who holds the salt. Free text (purpose, justification text, env_keys) prints as written. (THREAT_MODEL limits 5 and 8.)
  • Secrets with no known shape can print, and a URL with no scheme is not shortened.
  • network is coarse: it does not say where data goes.

The full list, with what proves each protection: docs/THREAT_MODEL.md.

How the output guards are checked

Passing tests do not prove a guard works. tools/mutation/ breaks each output guard on purpose, in a throwaway copy, and checks that a test fails. Last run: 94 guards broken, 94 caught. It takes 10 to 15 minutes, so it is not part of pytest:

python tools/mutation/guards.py run

Development

pytest && ruff check .
python tools/release_check.py   # before a release

See CONTRIBUTING.md. Report vulnerabilities privately: SECURITY.md. Every format and design assumption, with its verification status and source: docs/ASSUMPTIONS.md. How apl compares with existing MCP scanners: docs/competitor-teardown.md. Changes: CHANGELOG.md.

Not yet built: rules APL-003 and APL-009, live tool listing, and an LLM reasoning layer.

License

Apache-2.0. See LICENSE.

Metadata

Release files for agent-permission-linter 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-permission-linter 0.1.0
File Size Uploaded Provenance Actions
agent_permission_linter-0.1.0.tar.gz 178.8 kB Without provenance Details for agent_permission_linter-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for agent-permission-linter 0.1.0
File Interpreter ABI Platform Actions
agent_permission_linter-0.1.0-py3-none-any.whl Python 3 none any Details for agent_permission_linter-0.1.0-py3-none-any.whl

Total release size: 260.0 kB

Release files / agent_permission_linter-0.1.0.tar.gz

Download URL agent_permission_linter-0.1.0.tar.gz
Size 178.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a92d37ded3266258490aafa36eb0c11f0b0db5e6ac28baef2a15386cea6ef49b
BLAKE2b-256 checksum
How to use checksums
00134bc9184f57e6b416c69fbf5fbfbc4e8150c51d86e95a77717f218928e927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Release files / agent_permission_linter-0.1.0-py3-none-any.whl

Download URL agent_permission_linter-0.1.0-py3-none-any.whl
Size 81.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d8a79a2f8cbdd671b77574c8518e6cbc9e8067c6db00e61b15a70cf9a955c8b
BLAKE2b-256 checksum
How to use checksums
7fb7346a0a800534899b35cb5c2ed7df32b4ba0a20e95305b335ffa6a1fc3002
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.3

Security for agent-permission-linter 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page