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:
- Data exfiltration: Prompt injection or a malicious user could trick the assistant into dumping full contact lists.
- Unauthorized writes: An agent with write permissions might create or modify records, causing financial or compliance errors.
- Credential leakage: If the API key is embedded in a prompt or stored in an insecure location, attackers can reuse it.
- Compliance violations: GDPR, CCPA, or industry‑specific rules may forbid uncontrolled sharing of personal data.
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:
- Input validation: Strip or redact any user‑supplied text that looks like a prompt‑injection attempt.
- Policy enforcement: Enforce a whitelist of allowed operations (e.g.,
GET /contactsbut notDELETE /contacts/{id}). - 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:
- Timestamp and request ID
- Authenticated user or session identifier
- Requested endpoint and HTTP method
- Outcome (success, error code, redacted response size)
- Any policy violations (e.g., attempted write operation)
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
- ✅ Create a dedicated service account with the minimal required scopes.
- ✅ Store the token in a secret manager; never hard‑code it.
- ✅ Deploy a TLS‑protected proxy that validates inputs and filters outputs.
- ✅ Add system‑prompt reminders about data‑handling rules.
- ✅ Enable structured logging for every request.
- ✅ Set up alerts for policy violations and token misuse.
- ✅ Document the incident‑response steps and test them quarterly.
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.