Quick answer: Environment variables are a delivery mechanism, not an isolation boundary between code running with access to the same environment. An agent can expose a secret when its tools or runtime can read and disclose it; the model does not automatically see every environment variable. Limit the runtime's credentials and permissions, and treat runtime retrieval as another sensitive delivery path—not a guarantee that keys stay hidden.
Separate the model from its tools
A model receiving a task does not inherently have access to your computer's environment. A shell tool, code-execution tool or application function may have that access. The host decides which tools exist, what environment they receive and which results reach the model.
If untrusted code runs with access to process.env, telling the agent not to read STRIPE_SECRET_KEY is not a security boundary. Restrict the execution environment rather than relying on task instructions.
The same applies to file access. A client may exclude particular files from indexing, but a separate shell tool could still read them. Check the actual paths and permissions available through each tool; do not assume every coding client reads every .env automatically.
A .env file and an environment are different surfaces
| Surface | What to check |
|---|---|
A plaintext .env file | Which users, tools, backups and sync services can read it; whether it entered Git history |
| A process environment | Which code executes in that process and can inspect its environment |
| A child process | Which values the parent passes or inherits into it |
| A hosting configuration panel | Which identities and API permissions can view or change values |
| Tool output and diagnostics | Whether environment dumps, errors or traces disclose values |
Database connection strings and mail-provider keys are secrets too. They do not become harmless merely because the application, rather than an agent, needs them.
Environment injection can be a reasonable delivery choice for a trusted workload. The problem is giving an independently trusted agent access to unrelated production secrets—or assuming a different delivery mechanism makes an untrusted runtime safe.
Reduce inherited access
For each agent or tool process:
- List its legitimate task and required services.
- Inspect how its environment is constructed without dumping secret values into logs.
- Pass only necessary configuration and credentials.
- Restrict filesystem access and execution privileges where the runtime supports it.
- Check child processes, diagnostics, crash reporting and log collection.
- Use provider-restricted credentials appropriate to the task.
Removing a value from the environment does not help if the same runtime can read it from a file or use an unrestricted platform token to obtain it elsewhere.
CI needs a deliberate trust boundary
Keep agent-assisted review or documentation work separate from jobs that receive deployment credentials unless sharing is genuinely required and justified.
Use narrowly scoped job or step environments, restricted workflow permissions and environment protections where supported. Review event triggers and untrusted pull-request content before permitting privileged execution.
A separate job is helpful, but not a universal guarantee of isolation. Self-hosted runners, shared workspaces, artifacts, caches and persistent machines may bridge jobs. Do not pass secrets through outputs or upload files containing them to a less-trusted job.
For platform-specific setup, follow the CI provider's current documentation and test with fictional credentials before trusting the boundary.
Platform access is not the same as plaintext secret access
Review what a hosting or source-control token can actually do. Listing secret names, reading secret values, editing a workflow and running a privileged job are different capabilities.
For example, GitHub's Actions secrets REST API returns secret information without revealing stored secret values. A token that can modify or trigger privileged execution can create a different exposure path. Do not describe those privileges as simply decrypting secrets through the API.
For other platforms, verify the relevant endpoints, credential types and restrictions rather than assuming they behave like GitHub.
What runtime retrieval changes
Authenticated retrieval can avoid preloading every service key into every process. Named identities and retrieval policies can also make onboarding, access review and future-delivery revocation easier.
Gazebo checks the caller's retrieval policy and returns the authorised stored provider credential to the runtime and its host. It does not automatically issue a narrower or shorter-lived provider key. The returned value may still enter memory, model context or logs depending on the client.
Protect the agent's bootstrap authentication too. Moving provider keys out of .env does not eliminate the need to secure the token or connection used to retrieve them.
See the SDK, CLI and MCP guides for supported integration paths.
If exposure may already have happened
Distinguish possible accessibility from confirmed disclosure, but do not postpone necessary containment while investigating.
Block further retrieval, stop or isolate the affected runtime where possible, and restrict, revoke or replace potentially exposed provider credentials as appropriate. Read-only access may expose sensitive information; do not assign it an automatic low-priority replacement deadline.
Preserve available evidence, identify other consumers of shared keys and use provider/runtime records to investigate actual activity. Gazebo's records describe retrieval, not subsequent API calls. Fix the environment before delivering replacement credentials.
Use the incident-response playbook and rotation versus revocation guide for those separate actions.