Are you confident that your AI‑driven queries to BigQuery can’t be hijacked by a malicious prompt? prompt-injection risk is a real threat when large language models generate SQL on behalf of a service account.
Most teams that let models build queries rely on a single service account that lives in a secret manager or a CI pipeline. The model receives a user’s natural‑language request, builds a query string, and sends it straight to BigQuery using the stored credential. If an attacker can influence the prompt – for example by inserting a hidden instruction or by feeding crafted user input – the model may produce a query that exfiltrates data, drops tables, or modifies billing settings. Because the request travels directly from the model to the data warehouse, there is no visibility into what was actually run, and no chance to stop a dangerous statement before it reaches the database.
This situation illustrates the first beat of the problem: a real, unsanitized state where a non‑human identity (the service account) is the only gatekeeper. The credential is static, shared across many jobs, and never rotates automatically. Engineers trust the model’s output, but the underlying connection provides no audit trail, no inline data protection, and no way to require a human to approve high‑impact statements. The result is a high‑impact prompt‑injection risk that can go unnoticed until damage is done.
Understanding prompt‑injection risk with non‑human identities
Introducing a non‑human identity does solve one piece of the puzzle. By moving from a human‑owned key to a service account, you can enforce least‑privilege scopes, limit the data that the model can touch, and rotate the secret on a schedule. That is the second beat: the precondition that the post is about. The service account now defines who the request is – a machine identity – and what it may do. However, the request still reaches BigQuery directly. The gateway that could inspect the SQL, mask sensitive literals, or pause the execution for an analyst is missing. In other words, the fix stops the credential from being exposed to developers, but it leaves the data path completely open, with no real guardrails.
Because the enforcement point is absent, the following gaps remain:
- There is no session‑level record of which prompt produced which query.
- Dangerous commands such as drop table or delete from execute without a checkpoint.
- Result sets that contain personally identifiable information are streamed back to the model unfiltered.
- Any accidental or malicious change to billing or dataset permissions goes unchecked.
All of these gaps are precisely what a data‑path gateway is built to address. The gateway must sit between the service account and BigQuery, inspect each wire‑level request, and apply policy before the query touches the warehouse.
Why a gateway in the data path is essential
Enter hoop.dev. hoop.dev is a Layer 7 gateway that proxies connections to infrastructure such as BigQuery. It runs an agent inside the network, receives the request from the AI‑driven process, and then forwards it to the target only after applying the configured controls. Because hoop.dev sits in the data path, it is the only place where enforcement can happen.
When a prompt‑generated query arrives, hoop.dev can:
