All posts

Non-human identity: what it means for your prompt-injection risk (on Postgres)

A CI pipeline that automatically spins up a PostgreSQL client to run migration scripts suddenly starts returning unexpected rows, exposing a prompt-injection risk. The job’s service account is still valid, but a newly introduced AI-assisted code-generation step has begun injecting crafted prompts into the SQL it builds. The result is data leakage that no human ever typed. That scenario illustrates a broader problem: non-human identities, service accounts, CI jobs, off-boarded contractors’ token

Free White Paper

Non-Human Identity Management + Prompt Injection Prevention: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

A CI pipeline that automatically spins up a PostgreSQL client to run migration scripts suddenly starts returning unexpected rows, exposing a prompt-injection risk. The job’s service account is still valid, but a newly introduced AI-assisted code-generation step has begun injecting crafted prompts into the SQL it builds. The result is data leakage that no human ever typed.

That scenario illustrates a broader problem: non-human identities, service accounts, CI jobs, off-boarded contractors’ tokens, are now the primary callers of database APIs. They are attractive because they have long-lived credentials and often enjoy broad privileges. When an AI model is asked to write a query, the model can be tricked into appending a malicious clause, a classic prompt-injection risk. The database sees a perfectly formed statement from a trusted identity and executes it without question.

Why non-human identities increase prompt-injection risk

Human operators normally review the text they type before it reaches the database. A service account, however, rarely has a person looking over each command. Automation scripts treat the output of an LLM as data, not as an untrusted prompt. If the model is fed ambiguous instructions, it may embed hidden SELECTs, UPDATEs, or DELETEs that exfiltrate or corrupt data. Because the request originates from a credential that the platform already trusts, traditional network firewalls or IAM policies do not flag it.

What happens when the request goes straight to PostgreSQL

In many teams the service account is configured directly on the client library. The request travels over TLS straight to the PostgreSQL server. The server authenticates the identity, checks role-based permissions, and runs the query. No intermediate component sees the payload, so there is no place to apply real-time validation, inline masking, or per-command approval. Auditing is limited to PostgreSQL’s own logs, which often omit the full query text for performance or compliance reasons. The result is a blind spot: the organization cannot prove which AI-generated statement caused the data exposure, nor can it block dangerous patterns before they hit the database.

Continue reading? Get the full guide.

Non-Human Identity Management + Prompt Injection Prevention: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

Mitigating prompt-injection risk with a data-path gateway

The missing piece is a layer that sits between the non-human identity and the PostgreSQL endpoint. That layer can inspect every SQL statement, enforce policies, mask sensitive columns in responses, and record the full session for later replay. It also provides a hook for just-in-time approvals when a query crosses a risk threshold. By moving the enforcement point to the gateway, the organization regains visibility and control without changing the existing service-account credentials.

Introducing hoop.dev as the enforcement point

hoop.dev implements exactly this data-path gateway for PostgreSQL. It proxies the connection, validates each incoming query against configurable guardrails, and can automatically redact fields like credit-card numbers before they leave the database. hoop.dev records every session, so an auditor can replay the exact command that triggered a breach. Because the gateway runs inside the customer’s network, the original service-account never sees the database credential; hoop.dev holds it securely. The enforcement outcomes, query-level audit, inline masking, just-in-time approval, and session recording, exist only because hoop.dev sits in the data path.

Setting up hoop.dev starts with the standard getting-started guide, where you deploy the gateway and register a PostgreSQL connection. Identity is still handled by your existing OIDC provider, but hoop.dev becomes the relying party that decides whether a particular non-human token may execute a statement. For detailed policy configuration, see the learn section.

By placing hoop.dev in front of PostgreSQL, you transform a blind automation pipeline into a controlled, observable channel. Prompt-injection attempts are caught before they hit the database, sensitive data is masked on the fly, and every interaction is archived for forensic analysis.

FAQ

  • Does hoop.dev require changes to my existing CI scripts? No. The gateway accepts standard PostgreSQL client connections, so your scripts can point to the hoop.dev host instead of the raw database endpoint.
  • Can I still use role-based access control inside PostgreSQL? Yes. hoop.dev forwards the authenticated identity, and PostgreSQL continues to enforce its own role permissions. hoop.dev adds an extra layer of guardrails on top of those permissions.
  • What happens to logs if I need to prove a breach? hoop.dev records the full SQL payload and response, including any masked fields. Those logs are stored outside the database process, enabling replay without relying on PostgreSQL’s internal logging.

Ready to protect your non-human identities from prompt-injection risk? View the source code on GitHub and follow the getting-started guide to deploy hoop.dev in front of your PostgreSQL clusters.

Open source

Save the open-source gateway for agent data access

Hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.

Star and save the repo →More posts