Skip to content
redactsure
Book a demo

Explore.

Data Report · RedactSure Research
Chris Sowa · Founder, RedactSure
Published
Last updated

Where Does Gemini CLI Store My Credentials?

Gemini CLI keeps its credential on the machine that runs it, in the tool's own configuration directory or in an environment variable you exported, and the CLI's reference names the exact path for your version. Check that path, then ask what the agent can reach with it and who approves its first use.

A credential reference travels from a browser record through a bounded route to a separate API destination.

A developer installs a command-line agent, exports the key that pays for the model, and runs it against a repository. The tool has to authenticate on every run, so the credential sits where the tool can read it without a person present: a configuration file in the home folder, an environment variable set in a shell profile, or a keychain entry the tool unlocks. Which one applies depends on the installed version, and the tool's own reference is the page that names the path.

That file is the part of the stack the other controls miss. A key left in a home directory authenticates as the developer, in every repository and session that developer can open, and it outlives the task that used it. Google's IAM documentation for agents describes a strongly attested identity issued to an agent and governed through IAM (Google Cloud, Identity, 2026); a file in a home directory is neither issued nor governed that way, and a prompt screen sits in front of the model's input rather than in front of the file.

Which storage class the install uses, what an agent running under that account can reach with what it finds, and what a shorter-lived, narrower credential would change are questions a developer can answer on their own machine. The CLI's reference for the installed version names the path, and a developer should check that path before the tool runs again.

Key findings

  • For a credential file to stay out of a model's context, the value the agent reads would have to be a consistent token, issued for one task and resolved only at the destination a person approved, because a file holding the real key gives the model the real key on the first read (Does a GitHub Fine-Grained Token Replace a Secure Agent Workspace?).
  • It would also require a named person approving the first use of that credential and a record of what the agent read before it acted; file permissions and a CLI's own logs supply neither, and the documented approval default in a coding agent lands on the terminal command rather than on the credential (Does a Coding Agent Need Approval Before Using a Credential for the First Time?).
  • Google's Gemini Enterprise documentation says access control "limits the data that users can view in your search app's results," a boundary for users inside that product, and it does not describe what a command-line tool keeps in a configuration file on a developer's machine (Google Cloud, Access controls, 2026).
  • Google's key guidance states that "Publicly exposing your API keys can lead to unexpected charges on your account or unauthorized access to your data," the exposure a configuration file creates when the machine is shared, backed up or lost (Google Cloud, Keys, 2026).
  • The researchers defending Gemini describe "a suite of adaptive attack techniques to run continuously against past, current, and future versions of Gemini," which treats the model as reachable by whoever controls what it reads (Shi et al., 2025).
  • Google's identity documentation describes "a strongly attested, cryptographic identity for each agent," granted permissions directly through IAM, which is the property a developer's own stored key does not have (Google Cloud, Identity, 2026).

Where does a command-line agent keep the credential it reads?

A governed browser environment covers what an agent reads and does on a rendered page: a cloud console, a settings page, an issue page, a sign-up form. It does not cover the terminal, the IDE, the local filesystem, direct API calls or MCP. A question about where a command-line tool stores its key is a question about the local filesystem and the process environment, so the answer starts there, and a browser control becomes relevant only where the agent opens a page that shows the same key.

Command-line tools converge on three storage classes. The key can sit in a configuration file in the tool's own directory under the user's home folder, plain text unless the tool encrypts it. It can come from an environment variable that a shell profile exports, which keeps it out of the file and leaves it in the process environment, where any child process can read it. It can be held in the operating system's keychain, unlocked by the tool on first use, which protects the value at rest and still hands it to the process that asks. Gemini CLI's configuration reference is the page that names the class and the path for the installed version, and that reference is not described in the pages reviewed here.

Take one credential file on disk: a JSON file in a hidden configuration directory, readable by the user account, holding a key and the project it belongs to. A shared build machine or a synced home folder carries it further than the developer intended. Permissions narrow which accounts can open the path; they do not separate the tool from anything else running under the same account. Some tools document a deny rule for one layer: the sandboxing documentation describes rules for files and environment variables under sandbox.credentials, which block sandboxed commands from reading the path and say nothing about the tool reading its own configuration outside the sandbox (Does Claude Code Read My .env File?).

What can an agent read once the file is on disk?

An agent inherits everything the account can read: a process started by the developer runs with that user's permissions, so an agent that runs a shell command can open the configuration directory, the shell profile and any file the developer can open, with no separate grant and no prompt. The credential file is unremarkable to the agent; it looks like another file in a tree of files.

The reach of the key is the reach of the identity behind it. A key issued to a developer's cloud account authorizes calls as that developer, against the projects the account can use, and the quota is billed to the billing account behind them. Google's IAM documentation for agents describes the alternative it built for cloud agents, "a strongly attested, cryptographic identity for each agent," granted permissions directly through IAM (Google Cloud, Identity, 2026). A file in a home directory is not that: it is the person's credential, and the service's audit trail records the person.

Injection raises the price of the difference. A team that defends Gemini describes "a suite of adaptive attack techniques to run continuously against past, current, and future versions of Gemini" (Shi et al., 2025), a program that assumes a model can be steered by what it reads. A model steered by a README, an issue body or a vendored dependency can use the key it was given, or send it on, and the file's permissions do not enter that decision. Perimeter rules do not close it either: the VPC Service Controls update "adds agent identities to ingress and egress rules" (IT Brief, 2026), a rule about calls between services rather than about a key on a laptop.

Least privilege is the control that fits, and its limit is this page's question. Least privilege governs the actions an agent may take and the credentials it may use; it does not govern what a screen renders or what a configuration file holds (What Is Least Exposure?).

What do the vendors themselves say?

Google documents the controls at the layers where it holds the data, and each page is specific about what its control governs. None of them is about the file a command-line tool writes on a developer's machine, which is why the limits matter as much as the quotes.

Google's guidance on API keys states that "Publicly exposing your API keys can lead to unexpected charges on your account or unauthorized access to your data" (Google Cloud, Keys, 2026), a warning about exposure that names no storage location and no path.

Model Armor can "screen user prompts to and responses from your AI agents" (Google Cloud, Model Armor, 2026), a check on what crosses into and out of the model, which is a different object from a file the tool read before it built the prompt.

The Gemini Enterprise documentation on custom data sources says access control "limits the data that users can view in your search app's results" (Google Cloud, Access controls, 2026), a boundary for users inside a search product rather than a rule for an agent's credential.

Google's administrator guidance states "Use the super admin account only when needed" (Google, Workspace, 2026), a scope rule for the account a key belongs to, and one worth applying when the account behind a CLI key is an administrator.

Dimension Google, per its documentation What a buyer should verify
Agent identity "a strongly attested, cryptographic identity for each agent," permissions granted through IAM Whether the agent runs under that identity or under a developer's key
Key handling "Publicly exposing your API keys can lead to unexpected charges on your account or unauthorized access to your data" Where the CLI writes the key and which accounts can read that path
Prompt screening Model Armor can "screen user prompts to and responses from your AI agents" Whether screening covers tool output and file reads, not prompts alone
Search access access control "limits the data that users can view in your search app's results" Whether the boundary reaches the CLI surface at all
Administrator scope "Use the super admin account only when needed" Which account the key belongs to, and whether that account is an administrator
Network perimeter the update "adds agent identities to ingress and egress rules" Whether east-west rules cover a laptop's outbound call

What does a short-lived credential change?

It changes what the file is worth. A key scoped to one project and one API, with an expiry date, is a smaller loss than a key that reaches every project the developer can open, and the difference is under the developer's control today.

The stronger version keeps the credential out of the tool's process. Separating build from deploy means the agent produces an artifact and opens a change while a step outside its reach holds the credential, the split a cloud coding environment documents when it removes stored credentials before the agent phase (How Do I Let a Coding Agent Deploy Without Giving It Deployment Credentials?). The agent still does the work; the key stops being one of its inputs.

A vault does not settle it by itself. For a vault to keep a credential away from a coding agent, the value the agent fetches would have to arrive as a consistent token the model reads instead of the real value, released only at the approved destination (Does HashiCorp Vault Keep Credentials Away From a Coding Agent?); a token the agent can redeem at will is a shorter-lived version of the same exposure.

What expiry cannot do is decide who may use the key. That decision belongs to a person, on the first use, before the agent's first call, and it needs a record that outlives the run. A key that expires in an hour still authorized every call it made in that hour.

Who approves the first use, and what record is left?

An approval on an action is not an approval on a credential. One coding agent's documentation states that "by default, terminal commands need your approval," an approval that arrives at the command after the key is already in the environment the command will use (Does a Coding Agent Need Approval Before Using a Credential for the First Time?). A page that asks a person to approve a push does not ask who let the agent hold a key that can push to every repository.

Approval screens also degrade. Automation bias, "the tendency to over-rely on automation," has been studied in various academic fields (Goddard et al., 2012), and the effect is strongest when the automation is usually right and the person is asked to confirm rather than to decide. A workflow that approves the fortieth identical prompt is not a control on the first use of a key.

The record is the other half. A log line that says a command ran does not say what the agent read before it ran. The useful record for this question names the credential, the task, the destination of the real value and the person who approved the use.

So the question returns to the screen and the file. A console page that displays the same key is a second exposure, and it is the one a control over rendered pages can address; the file is the one a control over rendered pages cannot.

What does a governed environment change?

It takes the value out of what the model reads. On a rendered page, values chosen by policy are replaced with consistent tokens before any model reads the screen, and the real value resolves only at the approved destination, at the moment of an approved action. The model plans on tokens: an account number renders as ACCT_001, a key as KEY_014, and the run continues.

That is the separation a design like CaMeL argues for, in which "the untrusted data retrieved by the LLM can never impact the program flow" (Debenedetti et al., 2025). The token is what the model's reasoning can move; the value stays in a store the model cannot read, and a person's approval is what releases it to one destination.

The limit is scope. A token substituted at the rendered page does not change a file the tool reads from disk, so a credential in a configuration file needs the credential-side controls as well: a project-scoped key, a short lifetime, an approval on first use and a record of that approval. Where an agent opens a console page that shows the key, the screen control covers that page and the file needs the other controls. The privileged-access comparison reaches the same split from the identity side: tight privilege controls govern the identity an agent acts under, and the view the model receives remains a separate question (RedactSure vs CyberArk).

What the record shows

What a model receives on a screen is set by what the screen draws; what it receives from a file is set by what the file holds. A command-line tool's credential sits on the second path, and the controls the vendor documents, such as agent identity, prompt screening, enterprise access and network rules, act at layers above the file. A developer who wants the key out of the model's context can shorten its life, narrow its scope and tie its first use to a named approval, and none of that requires the tool to change. The test takes one key and one task: record the path and the account the key belongs to, run the task with a test value in place of the real one, and compare what the agent reached with the test value against what it reaches with the real one.

Methodology and limitations

This page rests on three research papers, Google's documentation for agent identity, API key handling, Gemini Enterprise access controls and Model Armor, Google Workspace administrator guidance, one trade press report on VPC Service Controls, and existing RedactSure research pages. Vendor pages were read as of November 3, 2026, and each Sources line carries the date for its page. Public documentation read in full gives a sound view of where each product applies its control.

The products on this page are described from their public documentation and none was tested for this page, so "not described in the pages reviewed" means the pages listed here. Gemini CLI is versioned software and its storage behavior can change between releases, which is why the page states storage classes rather than a path. RedactSure is deploying now with enterprise and government customers. The example describes a record type, not an organization, and nothing here replaces a pilot of one workflow on the organization's own machines. Compliance determinations belong to the organization's counsel, assessors and the organization's own security and compliance officers.

Frequently asked questions

Where does Gemini CLI store my API key?

On the machine that runs it, in one of three places: a configuration file in the tool's own directory, an environment variable set in your shell, or a keychain entry the tool unlocks. Which one applies depends on the installed version and the way you signed in, and the CLI's configuration reference names the path for your install. None of the three sits on Google's side of the API call, so the file is yours to scope, rotate and delete.

Can another program I run read the credential file?

Usually, yes. A process that runs as your user reads the files your user can read, so an agent with a shell, a build script or a package install can open the configuration directory and the file in it. Permissions narrow the set of accounts that can read the path; they do not separate the tool from anything else running under your account. The smaller fix is a key scoped to one project, and the larger one is an identity the tool does not hold.

Does a control over rendered pages cover a terminal tool?

No. A control that replaces values on a rendered page acts on what a browser or a governed environment draws, and it says nothing about a file the tool reads from the local filesystem. The two controls meet only where the agent opens a page that displays the same key, such as a console's API keys page, and that page is inside the screen control's scope while the file is not.

Does Google's agent identity cover a credential a developer's CLI holds?

Not from the pages reviewed. Google's IAM documentation describes an identity issued to an agent and granted permissions through IAM, which is a different object from a key a developer exports into a shell. An identity is issued to the agent by the platform, while the key is minted for the person and pasted into a file. An organization that wants the CLI to run under an agent identity has to configure that path itself, and installing the CLI does not create one.

Who should approve the first use of that key?

A named person, before the agent's first call with it, and not the same person who wrote the prompt if the key can reach production. An approval on a terminal command arrives after the key is in the environment, so it records that a command ran rather than that someone decided the agent should hold the key. Put the decision at the credential, then keep the command approval as a second gate.

What record should the run leave?

One that names the credential, the task it was used for, the destination of the real value and the person who approved it. API logs show the call and the account; they do not show the file the tool opened or what the model read before it acted. A record that answers the second question is the one an assessor will ask for first, because the first question is already answered by billing.

About the author

Chris Sowa is a founder of RedactSure and a former CEO of an AI company; he started it years before ChatGPT existed. He previously led AI at Accenture, served as Global VP of Strategy & Innovation at Schneider Electric, was CCO of Sovos, and spent more than a decade at Oracle, with earlier roles at SAP and IBM.

How RedactSure Keeps a CLI Key Out of the Model's Context

A key a tool reads from disk is in the model's context for the run, and a shorter scope reduces the loss without changing what the model received. Google's guidance warns that exposing an API key can bring unexpected charges or unauthorized access to your data.

The environment that enforces this is built by RedactSure, an AI agent controls, governance and data protection company.

Before: an agent opens a console's API keys page and the model reads the key as the page draws it. Inside the governed environment: the page renders KEY_014 and the real value resolves only at the destination a named person approved.

RedactSure is deploying now with enterprise and government customers. Model Armor screens prompts and responses, which happens after the page has already been read.

Everyone else controls where data can go. RedactSure controls what the AI can see.

See it on your own workflow

The key an agent creates on a console page is the one worth watching. Bring that task and see, with test values, what the model reads and where the real value lands before it is used. Book a demo

Book a demo

Book a demo

Having trouble? Open the booking page or email us.