Subscribe to the Non-Human & AI Identity Journal

How should organisations govern AI agents that need database access?

Organisations should give AI agents narrow read access by default, separate write privileges from query privileges, and require human approval for any session that can modify data. That keeps agent activity inside a clearly bounded role while preserving auditability and reducing the chance of unsupervised state change.

Why This Matters for Security Teams

AI agents with database access are not just another service account problem. Their behaviour is goal-driven, dynamic, and often hard to predict, which makes static IAM assignments too blunt for real governance. A read-only agent can still leak sensitive records, chain queries across systems, or trigger downstream actions if its tool permissions are too broad. Current guidance suggests treating the agent as a workload with tightly scoped intent, not as a human surrogate with a standing role.

That distinction matters because agent access often outgrows the original use case. NHIMG research on the AI Agents: The New Attack Surface report shows that only 52% of companies can track and audit the data their AI agents access, leaving a large compliance blind spot. The risk is not theoretical, and OWASP Agentic AI Top 10 and the NIST AI Risk Management Framework both reinforce the need for runtime controls, traceability, and context-aware limits. In practice, many security teams encounter overbroad agent database access only after records have already been queried, copied, or modified outside the intended workflow.

How It Works in Practice

The practical model is to govern the agent’s database session the same way an organization would govern any high-risk workload: by separating identity, authorization, and transaction scope. The agent should authenticate with a workload identity, not a shared secret, and that identity should be bound to a narrowly defined purpose. For AI systems, best practice is evolving toward runtime authorization based on what the agent is trying to do, rather than a static role that assumes the future in advance.

For database access, that usually means three layers:

  • Read queries are allowed by default only against approved schemas, tables, and views.
  • Write, update, delete, or schema-changing actions require a separate approval path, ideally with human review for each privileged session.
  • Credentials or tokens are issued just in time, scoped to the task, and revoked when the task ends.

That pattern aligns with the identity and lifecycle discipline described in NHIMG’s Ultimate Guide to NHIs and with the agent-specific risks in the OWASP NHI Top 10. In implementation terms, teams should prefer short-lived tokens, fine-grained SQL permissions, row-level filters where appropriate, and immutable audit logs that capture the prompt, action, and resulting query path. These controls tend to break down when the agent is allowed to call multiple tools in a single chain because privilege can expand step by step across otherwise separate systems.

Common Variations and Edge Cases

Tighter database control often increases operational overhead, requiring organisations to balance faster agent execution against stronger approval and audit requirements. That tradeoff is most visible in environments where agents support analysts, customer service, or DevOps workflows and need mixed read and write paths. There is no universal standard for this yet, so current guidance suggests deciding privilege by use case, not by agent label.

A few edge cases deserve extra care. First, retrieval-only agents can still become dangerous if they are allowed to query broad datasets that include secrets, PII, or regulated records. Second, agents that generate follow-up tasks may indirectly cause writes through another system, so “read-only” at the database layer does not always mean “read-only” in practice. Third, long-lived credentials are especially risky because autonomous workloads can retry, branch, and resume after failures, extending the exposure window far beyond a normal human session.

The strongest control pattern is to treat the database as one boundary in a wider trust chain that includes tool access, secret storage, and audit evidence. That is why NHIMG’s The State of Secrets in AppSec is relevant here: secret fragmentation and delayed remediation make agent governance harder, not easier. For broader threat modeling, the CSA MAESTRO agentic AI threat modeling framework and NIST AI Risk Management Framework both support context-aware policy and continuous oversight.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Agentic AI Top 10 A2 Agent tool misuse and overbroad access are central to database-governed agents.
CSA MAESTRO TA-2 Threat modeling agent workflows helps expose database privilege escalation paths.
NIST AI RMF GOV-3 Governance controls are needed to assign ownership and accountability for agent data access.

Constrain tool and data access per task, with approvals for any action that can alter records.