Skip to main content
Glama
CRM MCP server

CRM MCP server

by lilizu-cyber

Okta least-privilege PoC for AI agents

What it proves: even when an AI agent is hijacked by a prompt injection, Okta-scoped access limits what it can do. Okta enforces this at two layers:

  1. Okta authorization server. The agent can't get a token with scopes its access policy doesn't grant (invalid_scope).

  2. MCP server (resource). Each tool checks the Okta token for the scope it needs. Every call, allowed or denied, is written to audit.log with the agent's client ID.

 support ticket ──► AI agent ──(client credentials)──► Okta  (issues only crm.read)
   (with prompt                │
    injection)                 └──(Bearer token)──► CRM MCP server
                                                    list/get      → crm.read   ✓
                                                    update email  → crm.write  ✗
                                                    delete        → crm.delete ✗
                                                    export all    → crm.export ✗

Files

File

Purpose

server.py

MCP server ("CRM") with per-tool Okta scope checks and audit log

okta_verifier.py

Validates Okta JWTs (signature via JWKS, issuer, audience, expiry)

agent.py

Scripted agent that follows a hijacked plan, so the demo is repeatable

mock_okta.py

Local Okta stand-in for rehearsing offline

run_demo.sh

Starts everything and runs the demo

Related MCP server: GTM Connector MCP Server

1. Rehearse offline (no Okta needed)

python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
./run_demo.sh mock

Sample output (offline mock run)

Layer 1 – Okta: agent asks Okta for 'crm.read crm.write crm.delete crm.export'
   invalid_scope: One or more scopes are not configured for the authorization server resource.
   → Okta refuses to issue scopes the agent's policy doesn't allow.

Agent requests its normal scopes: 'crm.read'
   granted scopes: crm.read
   token: cid=support-agent  scp=['crm.read']  aud=api://crm-mcp  expires in 3599s

Layer 2 – MCP server: each tool checks the token's scopes

Agent executes its (hijacked) plan:
  ✓ ALLOWED list_customers
  ✓ ALLOWED get_customer{'customer_id': 2}
  ✗ DENIED  export_all_customers        Okta token lacks scope 'crm.export'
  ✗ DENIED  delete_customer{'customer_id': 3}   Okta token lacks scope 'crm.delete'
  ✗ DENIED  update_customer_email{...attacker@evil.example}   Okta token lacks scope 'crm.write'

Result: 2 allowed, 3 blocked. No data was exported, deleted or changed beyond the agent's Okta scopes.

audit.log (one JSON line per decision):

{"agent_client_id": "support-agent", "tool": "export_all_customers", "required_scope": "crm.export", "token_scopes": ["crm.read"], "decision": "DENIED", "detail": "missing scope crm.export"}

On Windows, run run_demo.sh from Git Bash or WSL.

2. Configure your Okta preview tenant

a. Authorization server. Go to Security → API → Authorization Servers. Use default or create one named crm-mcp.

  • Audience: api://crm-mcp

  • Scopes tab: add crm.read, crm.write, crm.delete, crm.export

b. Agent app. Go to Applications → Create App Integration → API Services.

  • Name it support-agent.

  • Client authentication: Public key / Private key (recommended) or Client secret (quicker to set up).

  • If DPoP is required by default, turn it off for this PoC. The agent doesn't send DPoP proofs.

c. Access policy. On the authorization server's Access Policies tab:

  • Policy AI agents, assigned to client support-agent

  • Rule support-agent read-only: grant type Client Credentials, scopes crm.read only

d. Optional: register the agent as an AI agent identity. If your tenant has Okta for AI Agents (look for AI agents under Directory), register support-agent there, link it to the API Services app above, and assign yourself as the human owner. This adds the governance story: owner, lifecycle and access certifications. Menu names vary by release, so follow your tenant's UI.

e. .env

cp .env.example .env
# set OKTA_ISSUER=https://<your-org>.oktapreview.com/oauth2/<auth-server-id>
# set AGENT_CLIENT_ID and AGENT_CLIENT_SECRET (or AGENT_PRIVATE_KEY_PATH + AGENT_PRIVATE_KEY_KID)
./run_demo.sh okta

3. Demo script (about 5 minutes)

  1. The risk. Show the ticket: a normal request with a hidden instruction to export, delete and change data.

  2. Layer 1. The agent asks Okta for every scope and gets invalid_scope. Okta policy, not the agent's code, decides what it can request.

  3. Layer 2. The agent's token holds only crm.read. Reads succeed. Export, delete and write are blocked by the MCP server.

  4. Audit. cat audit.log shows each decision tied to the agent's client ID. Okta's System Log shows the token issuance and the refused scope request.

  5. Contrast (optional). Add crm.write to the agent's rule in Okta and rerun with AGENT_SCOPES="crm.read crm.write". Now the injected email change succeeds. Over-scoping is the vulnerability, and it's fixed centrally in Okta without touching code.

Talking point: this maps to OWASP Agentic Top 10 ASI03 (Identity & Privilege Abuse) and the principle of least agency.

Notes and next steps

  • Tokens are validated locally (JWKS), so they stay valid until expiry. To demo a kill switch (revoke the agent, next call fails), switch the verifier to Okta token introspection or use short token lifetimes. This is a natural next story.

  • Other extensions: put Okta Agent Gateway in front of the MCP server, or use Cross App Access for agents acting on behalf of a signed-in user.

  • The MCP SDK is pinned to v1 (mcp<2) because v2 renamed several APIs.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Enables governed access to a canonical Customer Graph across CRM and customer-service records, with per-field provenance, propose-only identity merges, field-level masking, records-only reply drafting, tiered policy and kill-switch enforcement, and hash-chained receipts for auditable reads and internal writes.
      9
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Gives clients scope-gated access to mock CRM records, call notes, and Slack account messages, logging an audit receipt for every tool call and idempotent write. It enables drafting renewal briefs whose claims are checked against their cited source or audit records.
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables Claude to safely look up customers, orders and support tickets through typed, parameterized read-only tools with row limits and truncation flags, plus resources, a triage prompt and an audit trail. The only mutation path is a two-step guarded ticket-status change that requires a preview and a matching confirmation token, with every call logged.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP clients to triage support tickets, search and update CRM records, run guarded read-only SQL queries, and route high-risk actions through human approval with PII masking and audit logging.
      MIT