Giving an AI agent access to company data safely: permissions and secrets

Updated · 5 min read

Service account or acting as the user

There are two common ways an agent reaches your systems. It can run under its own service account, a non-human identity with fixed permissions. Or it can act on behalf of a signed-in user and inherit that user’s rights. Both are valid, and the choice depends on whether the work belongs to the business or to one person.

A service account suits shared jobs such as sorting a support inbox. Keep its rights small and its actions logged under its own name. Acting as the user suits tasks like drafting a reply in someone’s own mailbox. In that case the agent must never see more than that user can see, and it must stop when the user’s session ends.

Per-user permissions and row-level limits

Permission should be enforced where the data lives, not only in the agent’s instructions. An instruction that says “only show customers in this region” can be ignored, bypassed by a clever message or simply misread. A query that filters by region in the database cannot be talked out of it.

Most business systems, including many CRM and database tools, can restrict which rows a user or role may read and which fields they may change. Map the agent’s role to those rules, test them with a user who has limited access, and confirm that the agent cannot retrieve a record that a restricted user could not open.

  • Read access and write access are separate permissions. Grant only what the task needs.
  • Fields holding bank details, identity numbers or health information need their own, tighter rule.
  • Actions that send, delete or pay anything should require a separate approval, not just a permission.

Separating test, staging and live environments

Build and test an agent against copies of the data that have personal details removed or replaced with realistic fake values. Use separate keys, separate accounts and separate tool endpoints for each environment, so a test run cannot write to a live customer record.

Label every environment clearly in the configuration, and make the live credentials available only to the production deployment. Many incidents happen when a test key reaches production or a test tool points at the live database. A simple check at startup that refuses to run when the environment and the credentials do not match prevents much of this.

Keeping secrets out of prompts and code

An API key, password or access token must never appear in an instruction, a prompt, a log or a shared document. If it does, anyone who sees that text has the key, and the model may repeat it in a reply. Store secrets in your cloud platform’s secrets manager or in a protected environment setting, and read them inside the tool code.

Rotate keys on a schedule and immediately after a staff member with access leaves or a key may have been exposed. Keep a list of which agent uses which key, so you can revoke one without stopping everything else. Check the provider’s current guidance on key handling, since the recommended practice changes.

Reviewing access regularly

Access drifts. A permission granted for a pilot stays after the pilot ends, and a new tool gets added to an agent without anyone reviewing the whole set. Review each agent’s permissions every quarter and whenever its scope changes, and remove anything the current task does not use.

Read the logs as part of the review. Look for reads of records outside the normal pattern, repeated failed calls and actions taken at unusual times. A logged permission error is not a problem by itself, but a pattern of them may show that the agent is trying to reach data it should not have.

Protecting against instructions hidden in the data

An agent that reads emails, web pages or uploaded files may meet text written to manipulate it, such as a line telling the agent to forward the file to an outside address. Treat all content the agent reads as data, not as instructions, and do not give the agent a tool that sends data to new destinations without an approval step.

Keep the tools narrow. An agent that can only draft replies cannot be tricked into sending them, and one that can only read one folder cannot be pointed at another. This is the most effective single control for agents that read untrusted content.

How Hundred Seas helps

Hundred Seas is a product studio in Taipei that builds AI agents and AI CRM systems on Claude and on OpenAI models. Access design is part of every agent we scope: which identity the agent uses, which rows and fields it can reach, where the keys are stored and which environment each deployment is allowed to touch.

We start with a scope step of about one week at a fixed price, ending in a written plan and a firm quote. The build follows in weekly releases, with permissions tested before anything goes live, and a monthly run plan keeps the access reviewed as the business changes.

Questions

Should an AI agent use my own login?
Generally, no. A personal login gives the agent everything you can see and makes its actions look like yours in the logs. Use a service account with narrow permissions for shared work, and reserve acting as the user for tasks that really belong to that person, with the session ending when they do.
Can I just tell the agent not to show certain data?
Not reliably. An instruction can be ignored, misread or bypassed by content the agent reads. Enforce the limit in the database or the tool, so the restricted records are never returned in the first place, and treat the instruction as a second layer.
Where should I keep the API keys my agent uses?
Keep them in a secrets manager or a protected environment setting on the server that runs the agent. Never paste them into prompts, shared documents or chat messages. Rotate them on a schedule and keep a record of which agent uses which key.
How often should agent permissions be reviewed?
Review them every quarter and whenever the agent’s scope changes. Remove any permission the current task does not use, and read the logs for reads outside the normal pattern. The review should have a named owner who signs it off.

Have a project in mind?

Tell us what you want to build. We reply with a plan, not a sales call.

AboutGiving an AI agent access to company data safely: permissions and secrets