AI Security

How to Safely Connect an AI Assistant to Your CRM Data

TL;DR: Use a token with the narrowest possible scope, route all AI‑CRM calls through a server‑side proxy that validates inputs, encrypt credentials at rest, add prompt‑level data filters, and log every request for audit. If something goes wrong, revoke the token and switch the assistant to read‑only mode.

What are the main security risks when an AI assistant talks to a CRM?

CRMs store contact details, deal values, and sometimes payment information. When an LLM can query or write that data, the following threats appear:

The OWASP GenAI Security Project lists these as part of the “Data Exposure” and “Improper Access Control” categories, which are the most relevant for CRM integrations.

Which integration pattern minimizes exposure?

Instead of giving the LLM direct access to the CRM API, route calls through a thin server‑side proxy (often called a “gateway” or “middleware”). The proxy performs three critical functions:

  1. Input validation: Strip or redact any user‑supplied text that looks like a prompt‑injection attempt.
  2. Policy enforcement: Enforce a whitelist of allowed operations (e.g., GET /contacts but not DELETE /contacts/{id}).
  3. Credential shielding: Store the CRM token in a secret manager; the LLM never sees the raw key.

This pattern follows the “defense‑in‑depth” guidance from the NIST Trustworthy AI framework, which recommends isolating high‑privilege assets behind a controlled interface.

How should I scope the API token for the proxy?

Most CRMs (Salesforce, HubSpot, Zoho) support fine‑grained OAuth scopes. Create a dedicated service account and grant only the operations the assistant truly needs. Example for HubSpot:

POST https://api.hubapi.com/oauth/v1/token
{
  "grant_type": "client_credentials",
  "client_id": "YOUR_CLIENT_ID",
  "client_secret": "YOUR_CLIENT_SECRET",
  "scope": "contacts.read deals.read"
}

Notice the absence of contacts.write or crm.objects.contacts.delete. If the assistant later needs write access, add a separate token with a short TTL and enable a manual approval step before activation.

How do I protect the token at rest and in transit?

Store the token in a secret manager (e.g., AWS Secrets Manager, GCP Secret Manager, or HashiCorp Vault). The proxy should retrieve the secret at startup and keep it in memory only. Use TLS for every request between the LLM, the proxy, and the CRM. If you are using a managed AI platform like OpenAI’s Agents API, configure the tool definition to point to your proxy URL (HTTPS) and never embed the token in the system prompt.

What prompt‑level guardrails stop the assistant from leaking data?

Before sending any CRM response back to the LLM, filter out fields that are not needed for the conversation. A simple JSON filter can remove email, phone, or any PII unless the user explicitly requests it and has the right role.

# Example Python filter
allowed_fields = {"name", "company", "title"}
filtered = {k: v for k, v in crm_record.items() if k in allowed_fields}

Additionally, prepend a system prompt that reminds the model of its data‑handling policy:

You may only return the fields "name", "company", and "title". Never reveal email addresses, phone numbers, or any other personal identifiers.

Which logs should I keep for audit and compliance?

Log every request that passes through the proxy, including:

Store logs in an immutable store (e.g., CloudWatch Logs with retention policies) and rotate them according to your compliance schedule. The OWASP Top 10 for LLM Applications recommends retaining enough context to reconstruct a security incident.

What does an incident response plan look like for a misbehaving AI‑CRM connector?

1. Detect: Alert on policy violations or abnormal request volume. 2. Contain: Immediately disable the service account or switch the token to read‑only. 3. Eradicate: Review the prompt history for injection attempts; patch the validation logic. 4. Recover: Rotate the compromised token, re‑enable only the needed scopes, and run a smoke test. 5. Post‑mortem: Document the root cause, update the guardrail checklist, and share findings with the team.

Quick deployment checklist

Following these steps lets a small team enjoy the productivity boost of an AI assistant while keeping customer data locked down. If you need a hands‑on review of your proxy design or token policies, AISecAll can run a short security assessment tailored to your stack.

Need a practical AI security review?

AISecAll reviews prompts, tool permissions, document flows, and agent behavior so small teams can use AI without guessing where the risk sits.

Book a call Discuss a project