October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

How to Securely Give AI Agents Access to a Database

Secure database access for AI agents starts with a separate, least-privilege identity—and authorization enforced outside the model.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Give an AI agent a separate database identity with only the access its task requires. Prefer read-only access, limit it to the necessary data, and enforce permissions in database and application code—not in the agent’s instructions. Validate every tool call against the user’s authorization and treat database content as untrusted, since prompt injection can influence an agent’s behavior.

Start by defining what the agent is allowed to do

Write down the agent’s job in terms of data and operations before connecting it to a database. Specify which records it needs, which actions it may take, and whose permissions should govern each request. An agent that answers product questions, for example, may need to read product details but not change them.

As an Amazon Associate I earn from qualifying purchases.

This scope is the basis for both the database grants and the tools the agent can call. A broad connection paired with a prompt telling the model to “be careful” is not an access-control boundary: the model’s behavior does not restrict what the database identity can do. OWASP’s AI Agent Security Cheat Sheet and Database Security Cheat Sheet recommend limiting accounts and privileges to the required task.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Give the agent a distinct, least-privilege database identity

Create a service identity for the agent or workload rather than sharing a human login or using an administrator account. Separate identities make it possible to grant task-specific permissions and attribute database activity to the workload that performed it.

#1 Best Overall
Thetis FIDO2 Security Key (USB-A, 2-Pack) - Hardware MFA & Passkey Access for Business, School ERP & Employee Accounts | Compatible with Windows, Google Workspace, Apple ID, Coinbase, Salesforce
  • FIDO2 & Passkey Ready: Business-ready and FIDO2 L1 certified. This key is supported by major management suites and is ideal for both individual and enterprise deployment. Works seamlessly with Gmail, Facebook, GitHub, Dropbox, Coinbase, and more.
  • Universal Connectivity (USB-A ): Features a built-in USB-A connector—simply unfold the key and plug it into your compatible PC or laptop for seamless authentication on the go.
  • Dedicated Manager App: Use the Thetis Manager App for the initial hardware PIN setup. Setting the PIN on the device first ensures a smooth registration process. Once the PIN is configured, you can begin registering the key across your favorite FIDO2-compatible online services.
  • Ultra-Durable & Portable: Featuring a rotating metal cover, this key is water, crush, and tamper-resistant. It fits easily on a keychain and requires no batteries or network connectivity.
  • Check FIDO2 compatibility before purchase - Known limitations: ID Austria is not supported (requires FIDO2 Level 2). Windows Hello login only works with Windows Enterprise editions that support Entra ID, and NFC is NOT supported.

Prefer read-only access for retrieval and analysis

If the agent only needs to look up or summarize information, do not grant insert, update, or delete privileges. OWASP’s excessive-agency example describes a product-recommendation agent that needs read access to a products table, not write access or access to unrelated tables. See OWASP LLM06:2025 Excessive Agency.

Limit which data it can reach

Restrict grants to the required database objects, and narrow access by row or column where the database and task support it. A restricted view can expose only the fields an agent needs while keeping underlying tables outside its route of access. Treat a view as part of the boundary: ensure the agent cannot reach the broader tables through another grant or connection.

Rank #2
Sale
Thetis Nano-A FIDO2 Security Key Hardware Passkey Device with USB Type A, TOTP/HOTP, FIDO2.0 Two Factor Authentication 2FA MFA, Works with Windows/mac/iOS/Android/Linux/Gmail/Facebook/GitHub/Coinbase
  • Ultra-Compact FIDO2 Security Key - Plug-and-stay or carry on a keychain. This USB-A hardware security key offers portable, always-on protection for desktop and mobile use. (Item Size: 0.75 X 0.74 IN x 0.25 IN)
  • USB-A Hardware Key for All Devices - Works with USB-A ports on PC, Mac, Android, and other laptop/notebook device. Enables secure, cross-platform login with FIDO2.0 passkey support.
  • FIDO Certified Security Key - Meets FIDO and FIDO2 standards. Works with Google, Microsoft, GitHub, Dropbox, and more. Please check service compatibility before purchase.
  • Passwordless Login with Passkey - Supports passkey login via WebAuthn and CTAP2. Enjoy password-free sign-ins where supported. Not all websites or services currently support passkeys.
  • Advanced Multi-Factor Authentication - Offers 200 FIDO2 passkey slots and 50 OATH-TOTP slots. Strong, flexible 2FA/MFA support across various apps and authentication platforms.

Choose a connection design by its enforced boundaries

There is no universal winner between connecting an agent directly to a database and putting an API or tool layer in front of it. The important question is whether the chosen design reliably enforces the same limits: permitted objects and operations, user-level authorization, parameter validation, authorization for sensitive actions, and monitoring.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Design What to verify Trade-off to consider
Direct database connectivity The database identity is limited to the required objects and operations; requests are also checked against the relevant user or session scope. Database grants can constrain the identity, but application code still needs to validate who may request each operation.
API or tool layer Only required functions are exposed, and deterministic application code checks tool name, parameters, resource scope, and user authorization before execution. The layer can express task-specific rules, but it must enforce them consistently rather than relying on the agent to follow tool descriptions.

This comparison is an architectural synthesis of OWASP’s access-control and agent-security guidance, not a claim that one design is inherently safer. See the database security guidance and agent security guidance.

Rank #3
Thetis Pro For Business - FIDO2 Security Key L1 MFA & NFC Passkey Access For School ERP, Employee Online Account, Compatible with Coinbase Google Workspace Apple ID Window Salesforce,Dual USB A +USB C
  • FIDO2 & Passkey Ready: Business-ready and FIDO2 L1 certified. This key is supported by major management suites and is ideal for both individual and enterprise deployment. Works seamlessly with Gmail, Facebook, GitHub, Dropbox, Coinbase, and more.
  • Dedicated Manager App: Use the Thetis Manager App for the initial hardware PIN setup. Setting the PIN on the device first ensures a smooth registration process. Once the PIN is configured, you can begin registering the key across your favorite FIDO2-compatible online services.
  • Universal Connectivity (USB-C, USB-A, & NFC): Designed for PCs, Macs, iPhones, and Android. For mobile use, simply unfold the key, align it with your phone’s NFC antenna, and hold for a few seconds to authenticate.
  • Enhanced MFA (FIDO2 & TOTP/HOTP): Strengthen your security with flexible options. Use the Manager App to access TOTP/HOTP features for accounts that do not yet support FIDO2.
  • Check FIDO2 compatibility before purchase - Known limitations: ID Austria is not supported (requires FIDO2 Level 2). Windows Hello login only works with Windows Enterprise editions that support Entra ID. NFC is supported only through mobile authentication, Not MacOS/windows.

Put authorization and validation in the execution path

For an API or tool-based design, the application should make the allow-or-deny decision before a database operation runs. Tool descriptions help an agent understand available functions; they are not a substitute for enforcement.

  1. Expose only necessary functions. For a read-only lookup task, provide a narrow retrieval function rather than a general-purpose query or database administration tool.
  2. Validate each request in application code. Check that the tool is allowed, the requested operation is permitted, parameters are valid, and the requested records fall within the current user’s or session’s authorized scope.
  3. Use safe query construction. Treat values supplied through a tool call as input, not trusted SQL. Follow OWASP’s SQL injection prevention guidance when building database queries.
  4. Authorize consequential actions explicitly. Require an authorization check for sensitive operations instead of inferring consent from the agent’s request or the surrounding conversation.
  5. Keep database permissions as a backstop. The identity used to execute a tool should not be able to exceed the task’s intended database scope if an application check is missed.

Assume database content can contain prompt injection

Retrieved text is data, not a trusted instruction. A customer record, document, user request, tool description, or connected MCP server may contain text that attempts to steer the agent into taking an unauthorized action. OWASP’s prompt-injection guidance and OpenAI’s explanation of prompt injections describe this risk.

Rank #4
Thetis Nano-C FIDO2 Security Key Hardware Passkey Device with USB Type C, TOTP/HOTP, FIDO2.0 Two Factor Authentication 2FA MFA, Works with Windows/mac/iOS/Android/Linux/Gmail/Facebook/GitHub/Coinbase
  • Ultra-Compact FIDO2 Security Key – Plug-and-stay or carry on a keychain. This USB-C hardware security key offers portable, always-on protection for desktop and mobile use.(Item Size: 0.73 X 0.60 X 0.30 inches)
  • USB-C Hardware Key for All Devices – Works with USB-C ports on PC, Mac, Android, and USB-C iPhones. Enables secure, cross-platform login with FIDO2.0 passkey support.
  • FIDO Certified Security Key – Meets FIDO and FIDO2 standards. Works with Google, Microsoft, GitHub, Dropbox, and more. Please check service compatibility before purchase.
  • Passwordless Login with Passkey – Supports passkey login via WebAuthn and CTAP2. Enjoy password-free sign-ins where supported. Not all websites or services currently support passkeys.
  • Advanced Multi-Factor Authentication – Offers 200 FIDO2 passkey slots and 50 OATH-TOTP slots. Strong, flexible 2FA/MFA support across various apps and authentication platforms.

Do not rely on a prompt telling the agent to ignore malicious instructions as the only defense. Reduce the damage a manipulated agent could cause by limiting its database identity and available tools to the defined task. Review connected MCP servers and their tool definitions; monitor changes to approved tools and investigate unexpected calls. OWASP’s Secure Coding with AI Cheat Sheet covers secure handling of AI-connected tools.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

If the agent must write data, narrow and gate the writes

Grant write access only when the task genuinely requires it. Expose specific write operations rather than broad database capabilities, and define the allowed records and fields for each operation. For sensitive or irreversible actions, require explicit authorization or human review; OWASP recommends human oversight for high-risk actions in its AI Agent Security Cheat Sheet.

Best Value
Kensington VeriMark NFC+ USB‑C Security Key, FIDO2/WebAuthn Hardware Authenticator for Passwordless Login, Works with Windows, macOS & Chrome OS, K64739WW
  • USB-C or tap via NFC for easy authentication on any compatible device. No drivers needed; optional Kensington software available for advanced management features.
  • Works across Windows, macOS, iOS, Android, ChromeOS, and supports Passkeys and Apple ID.
  • Slim, keychain-ready form for easy carry and on-the-go authentication
  • IP68-rated for dependable performance
  • FIDO CTAP 2.1 for enhanced security features (e.g. resident credentials, Passkey support) and backwards compatibility with CTAP 2. FIDO2 L2 certified security for phishing resistant protection against identity theft and unauthorized access.

Test both the intended action and the denial path: an allowed update should affect only its authorized target, while an out-of-scope request should be rejected before execution. Do not treat a model’s statement that it has followed the rules as proof that the action was authorized.

Monitor activity and protect data beyond the query

Monitor database access and agent actions so unusual calls can be investigated. For high-risk actions, OWASP recommends logging structured decision metadata. Decide what interaction details to retain and redact based on data sensitivity and applicable requirements; the cited guidance does not establish one retention period for every system.

Also control what enters prompts, memory, and plain-text logs. Avoid sending secrets or unnecessary sensitive fields to the model, and make sure logs do not become a second, less-protected copy of the data. The permission boundary matters throughout the lifecycle: from the initial request, through retrieved records and model context, to tool execution and audit records.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Security checklist

  • The agent has its own non-administrative database identity.
  • Its grants cover only the required databases, objects, rows, columns, and operations.
  • Read-only access is used unless a documented task requires writes.
  • Application code validates tool calls and user or session authorization before execution.
  • Retrieved content and tool descriptions are treated as untrusted input.
  • Sensitive actions require explicit authorization or human review.
  • Agent activity is monitored, and prompts, memory, and logs avoid unnecessary sensitive data.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.