All posts

Putting access controls around ChatGPT: data masking for AI coding agents (on on-prem)

Unmasked output from on‑prem AI coding agents can leak production credentials in plain text, and data masking is the only reliable way to prevent that leakage. Many organizations run a locally hosted LLM to assist developers with code generation, configuration snippets, or log analysis. The workflow usually looks like this: a developer types a prompt, the agent runs the model, and the response is streamed back to the terminal or IDE. Because the model has been fine‑tuned on internal repositorie

Free White Paper

AI Model Access Control + Data Masking (Static): The Complete Guide

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

Free. No spam. Unsubscribe anytime.

Unmasked output from on‑prem AI coding agents can leak production credentials in plain text, and data masking is the only reliable way to prevent that leakage.

Many organizations run a locally hosted LLM to assist developers with code generation, configuration snippets, or log analysis. The workflow usually looks like this: a developer types a prompt, the agent runs the model, and the response is streamed back to the terminal or IDE. Because the model has been fine‑tuned on internal repositories, it can surface snippets that contain API keys, database passwords, or internal hostnames without any indication that the data is sensitive. Teams often assume that keeping the model on‑prem isolates the risk, but the real exposure happens at the point where the model’s answer is delivered to a human or a downstream automation pipeline.

In practice, teams rely on ad‑hoc conventions, "never paste secrets into prompts" or "scrub logs manually", instead of enforcing a technical control. The result is a fragile safety net: a developer may unintentionally copy a secret from the LLM’s reply into a script, or an automated CI job may ingest the output and store it in an artifact repository. Because the LLM sits directly behind the user’s client, there is no audit trail, no real‑time inspection of the response, and no way to block or redact sensitive fields before they leave the system.

This gap is especially problematic when the same on‑prem agent is used by multiple services, bots, or AI‑assisted code reviewers. Each consumer inherits the same lack of protection, and the organization loses visibility into who saw what and when. The core problem is that the data path, from the LLM to the requester, contains no enforcement point where policies such as data masking can be applied.

Why data masking is a non‑negotiable control for AI coding agents

Data masking means replacing or redacting sensitive values in a response while preserving the overall structure of the output. For code generation, this typically involves hiding strings that match known secret patterns (for example, AWS keys that start with AKIA) or sanitizing configuration blocks that contain passwords. Masking protects three critical assets:

  • Confidentiality: Secrets never appear in clear text outside the controlled environment.
  • Compliance: Regulations that require protection of credential material are satisfied when the organization can demonstrate that secrets are never exposed in logs or user terminals.
  • Operational safety: Accidental credential leakage is a common cause of lateral movement and privilege escalation. Masking reduces that attack surface.

Without a dedicated enforcement point, attempts to mask data at the application level are easily bypassed. A developer could disable the masking routine, or a script could call the LLM directly via an internal API, sidestepping any client‑side checks.

Common mistakes when trying to mask AI output

1. Relying on post‑processing: Scrubbing the response after it has already been displayed gives the user a chance to copy the secret before it is removed.

2. Embedding masking logic in the model prompt: Asking the model to "hide passwords" does not guarantee that it will obey; the model may still emit the value in a different format.

3. Using static regexes only: Secrets evolve and can appear in unexpected contexts. A static pattern misses many cases, leading to false confidence.

Continue reading? Get the full guide.

AI Model Access Control + Data Masking (Static): Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

Architectural approach: place the guardrail in the data path

The only reliable way to guarantee data masking is to intercept the traffic between the requester and the LLM at a point that cannot be bypassed by the client or by a direct API call. This means inserting a Layer 7 gateway that terminates the protocol, inspects the payload, applies masking rules, records the session, and then forwards the sanitized response to the original caller.

In this model, identity is still resolved upstream, via OIDC or SAML, so the gateway knows which user or service is making the request. The gateway does not store credentials for the LLM; it forwards the request using its own service identity, keeping the model’s secret token out of the user’s hands. The crucial piece is that every request and response must travel through the gateway; otherwise, the masking policy is ineffective.

How hoop.dev implements the solution for on‑prem ChatGPT agents

hoop.dev is a Layer 7 gateway that sits exactly where the enforcement needs to happen. When a developer or automation system connects to the locally hosted ChatGPT instance, the connection is routed through hoop.dev’s agent. The gateway reads the inbound request, forwards it to the model, receives the raw answer, and then applies data masking policies before delivering the result.

Because hoop.dev operates at the protocol level, it can:

  • Mask sensitive fields in real time: The gateway scans the response for patterns that match credential signatures and replaces them with a placeholder such as ***MASKED***. This happens before any user sees the data.
  • Record the full session: Every prompt and masked response is logged in an audit trail, giving teams visibility into who asked what and when.
  • Enforce just‑in‑time approvals: If a request contains a high‑risk operation, such as asking the model to generate a deployment manifest that includes secret references, hoop.dev can pause the response and require a human approver.
  • Scope access per identity: The gateway checks the requester’s group membership and only permits masking rules that are appropriate for that role, preventing over‑broad exposure.

All of these outcomes exist only because hoop.dev sits in the data path. The upstream identity system determines who may start a session, but without hoop.dev the request would travel straight to the LLM, bypassing every guardrail.

Getting started with hoop.dev for ChatGPT masking

To protect your on‑prem AI coding agents, deploy the hoop.dev gateway using the standard Docker Compose quick‑start. The deployment includes an OIDC‑enabled authentication front‑end, a configurable masking policy engine, and the network‑resident agent that talks to your ChatGPT service. Once the gateway is running, register the ChatGPT endpoint as a connection in hoop.dev; the gateway will store the service credential and expose a local port that your developers use instead of the raw model endpoint.

After registration, define masking rules that match the secret formats used in your organization. The feature documentation explains how to write pattern‑based rules and how to test them against sample responses. When the gateway is active, every request will be inspected, masked, and logged automatically.

For a step‑by‑step walkthrough, follow the getting‑started guide. It shows how to spin up the gateway, connect your ChatGPT instance, and configure a basic masking policy. The repository on GitHub contains the full source code and example configurations.

Explore the source code on GitHub to see how the masking engine is implemented and to contribute improvements.

FAQ

Does hoop.dev store the LLM’s authentication token?

No. The gateway holds the service credential internally and never exposes it to the requester. Identity is verified upstream via OIDC, and the token remains private to the gateway.

Can I see the unmasked response for debugging?

hoop.dev records the original response in the audit log, but access to that log is governed by the same role‑based policies that control who can request a session. Only authorized auditors can retrieve the raw data.

Is masking applied to streaming responses?

Yes. The gateway processes each chunk as it arrives, ensuring that even partially streamed data never leaks a secret before it is sanitized.

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