Problem:
Currently, AI coding agents treat .env files as regular workspace files and can automatically read, inspect, or modify them during execution. Because .env files frequently contain sensitive production tokens, secrets, and private credentials, this represents a significant security and privacy risk.
Proposed Solution:
Implement an intrinsic, platform-level guardrail across the agent toolset:
- Block automatic file reading and tool access to .env, .pem, .key, and credential files by default.
- Require an explicit user confirmation prompt whenever an agent attempts to open or inspect files matching sensitive credential patterns.
- Standardize this boundary globally across all models and environments rather than requiring per-project configuration files.
Hi @Gautam_Gareja,
Could you please provide a few details:
- Which version of Antigravity are you using?
- What operating system are you using?
- If possible, could you please share a screen recording the issue you are seeing?
Until there is a global default, the permission rules get you most of the way today ( Permissions | Google Antigravity Docs ):
- Why it happens: “Reading and writing files inside your active project directory is allowed without prompting, while non-workspace files require approval.”
- You can put read_file(.env) in the deny list, or in ask if you want the confirmation prompt. Paths can be absolute or relative to the workspace root, and “Deny read implies deny write”.
- Rules resolve as “Deny > Ask > Allow”, so a deny wins over a broader allow.
- For the CLI, the lists can live in global settings (~/.gemini/antigravity-cli/settings.json), which covers the “not per project” part.
Two limits. The docs only show path targets, no filename glob, so each .pem or .key file has to be listed. And I have not tested whether a read_file deny also stops cat .env from the terminal, since in the default preset commands run without prompting inside the sandbox. I would test that, and add a matching command rule if it gets through.
If you are on Windows, it still uses the older permission system, so this may not apply yet.
Thanks for the guidance. I understand that we can currently use permission rules to restrict access to sensitive files like .env, .pem, and .key. However, these files are accessible by default within the workspace, so users must manually add deny rules for each file or configure global settings to prevent access.
My suggestion is to make this work the other way around. Sensitive files should be blocked by default globally, and users should be able to explicitly allow access when needed. This would provide better security out of the box, reduce manual configuration, and help prevent accidental exposure of credentials across projects. The current permission system is a useful workaround, but having this as a built-in default security feature would make things much safer and more convenient.
You can consider to use infisical solution here. You shouldn’t trust the agents even they promise it because they can access 100% your folder right? However; you should strongly pay attention that, agent something tries to print your secret environment out to the terminal as well.
Hi @Ambati_Rajendra,
Thanks for getting back to me. I just wanted to clarify that this isn’t a version-specific issue; I’m suggesting an improvement to Antigravity’s default security behavior.
I’ve noticed that Antigravity can read and inspect sensitive files like .env, .pem, and .key without blocking access by default.
My suggestion is to enforce this restriction at the global level across Antigravity, so Sensitive files should be blocked by default globally, and users should explicitly grant permission whenever access is required.
Currently, users have to configure permission rules manually to restrict access. Instead, Antigravity should provide this protection by default across all projects, reducing manual effort and the risk of accidentally exposing credentials.
This would also add an extra layer of security, ensuring sensitive credentials remain protected even if users forget to configure permission rules. The existing permission system is a useful workaround, but making this a built-in security feature would make Antigravity safer and more convenient for developers.