An AI coding agent is a tool such as Claude Code, OpenAI Codex or Google Antigravity that reads files, runs shell commands and calls the network on your behalf. AI coding agent security means limiting what it can read, run and send from your machine. A Flutter repo holds things you cannot get back if they leak, like the upload keystore and the App Store Connect key. I have shipped 20+ Flutter apps and use agentic tools on client projects; this is the checklist I would hand any Flutter developer. It covers your machine and CI, not keys inside the shipped app; for that, read why keys in a Flutter binary still leak, and for securing the rest of the shipped app, Flutter security best practices based on OWASP MASVS.
What can an AI coding agent reach in a Flutter project?
Everything your user account can read, unless you configure otherwise. Flutter secrets fall into two groups: signing and server credentials that must never leave your machine or vault, and Firebase client config that is public by design but still belongs out of open-source repos.
| Secret (keep away from agents and git) | Public by design (still keep out of open-source repos) |
|---|---|
Upload keystore (.jks) and android/key.properties: keep both private and out of public source control (Flutter). Lose a self-managed signing key and you cannot publish updates (Android). | google-services.json and GoogleService-Info.plist: the content "is considered public", but Firebase does not generally recommend committing it in open-source projects (Firebase). |
App Store Connect API key (.p8): private, downloadable once, revoke if compromised (Apple). | lib/firebase_options.dart: non-secret identifiers (Firebase). |
iOS Distribution certificate private key (exported from a .p12 to a cert_key file and used by Codemagic CLI tools to sign release builds) (Flutter). | Firebase-restricted API keys, which are not secrets. The exception is a Gemini Developer API key (Firebase). |
Service-account JSON, a credential that never goes in a repo (Google Cloud), and .env files, including those passed to --dart-define-from-file, which accepts .json or .env (per flutter build apk -h on Flutter 3.44.1, checked October 24, 2026). |
Secrets an agent saw also persist locally.
- Claude Code. Any value a tool read or printed lands in plaintext transcripts under
~/.claude/projects/for 30 days by default (docs). - Codex. Login details are cached in a plaintext
~/.codex/auth.jsonor in your OS credential store, chosen bycli_auth_credentials_store(docs). Treatauth.jsonlike a password. Values:file: plaintextauth.jsonkeyring: OS credential storeauto: OS store, falling back toauth.jsonif it is unavailableephemeral: memory only
Does .gitignore stop Claude Code, Codex or Antigravity from reading your secrets?
No. .gitignore decides what git commits; each agent has its own read controls. Flutter's template helps less than people think: flutter create ignores key.properties, *.jks and *.keystore in the android template, but the root template does not ignore .env or the Firebase files.
These are the lines I add to the root .gitignore:
# secrets: never commit
.env
.env.*
*.p8
*.p12
# open-source repos only: Firebase advises not committing config files
# android/app/google-services.json
# ios/Runner/GoogleService-Info.plist
.env.* also ignores a .env.example, so name a committed template something else. On the agent side:
- Claude Code. It documents no automatic
.envexclusion. Block it withReaddeny rules inpermissions.deny. A.claudeignorefile has no effect (settings reference), and auto mode's classifier allows reading.envby default (permission modes). - Codex. Environment variables named with KEY, SECRET or TOKEN reach commands by default, because
ignore_default_excludesdefaults to true (config reference)..envappears only as a deny glob on the recommended configuration page. - Antigravity. The terminal sandbox blocks
~/.sshand.env(sandbox), IDE strict mode respects.gitignore(settings), and since App v2.18.1 (September 28, 2026) edits to.git,.envand.vscodeprompt (changelog). I found no doc naming keystores orkey.propertiesas sensitive.
How do Claude Code, Codex and Antigravity compare on permissions, sandboxing and data?
Claude Code and Antigravity both evaluate deny before ask and allow (Claude Code, Antigravity), but the three tools' defaults differ in ways that matter for a repo with signing keys. Codex and the Antigravity App start sandboxed; the Claude Code sandbox and the Antigravity CLI sandbox start off. Checked October 24, 2026; all three change often, so re-check a row before relying on it.
| Aspect | Claude Code | OpenAI Codex | Google Antigravity |
|---|---|---|---|
| Default mode | Auto (classifier-reviewed) for interactive terminal and VS Code; Manual starts read-only (docs) | "Auto" (workspace-write plus on-request) in version-controlled folders, else read-only (docs) | App Default preset: sandboxed commands run without prompting. CLI toolPermission: request-review (docs) |
| OS sandbox | Shell commands only: Seatbelt (macOS), bubblewrap (Linux, WSL2). Off by default; none on native Windows (docs) | Seatbelt (macOS), bubblewrap (Linux, WSL2), native sandbox on Windows. On by default (docs, Windows) | Namespaces, Seatbelt, AppContainer. On in the App, off in the CLI (docs) |
| Network default | Proxy with an empty domain allowlist (docs) | Off unless network_access = true (docs) | None in the sandbox; read_url domains allowed (docs) |
| Secrets by default | Add Read denies; sandbox still reads ~/.ssh unless denyRead is set (docs) | KEY/SECRET/TOKEN env vars passed to commands (filter off by default); .git, .codex, .agents, .aws read-only (docs) | Sandbox blocks ~/.ssh and .env (docs) |
| No-guardrails mode | --dangerously-skip-permissions, refused as root (docs) | --yolo, "not recommended" (docs) | Turbo; CLI always-proceed (docs) |
| Training: individual plans | Free, Pro, Max: only if the privacy setting is on; 5-year retention, 30 days if off (docs) | May be used for training; opt out in ChatGPT Data Controls (Help Center) | Interactions improve Google ML, human review possible; opt out in Settings (terms) |
| Training: business and API | Team, Enterprise, API: not trained unless you opt in; 30-day standard (docs) | Business, Enterprise, Edu, API: not trained by default (docs, API) | Enterprise: "never used to train Google foundation models" (docs) |
How should you configure each agent before it opens a client Flutter repo?
Deny reads of .env, key.properties and keystores, turn the OS sandbox on with network off, and keep approval on for shell commands. Each key below comes from the linked vendor docs; the Flutter paths are my own choices.
Claude Code
Team rules go in .claude/settings.json and personal ones in .claude/settings.local.json (settings):
{
"permissions": {
"deny": [
"Read(./.env)",
"Read(./.env.*)",
"Read(./secrets/**)",
"Read(./android/key.properties)",
"Read(**/*.jks)",
"Read(**/*.keystore)",
"Bash(curl *)"
],
"ask": ["Bash(git push *)"]
},
"sandbox": {
"enabled": true,
"failIfUnavailable": true,
"allowUnsandboxedCommands": false,
"filesystem": {
"denyRead": ["~/.ssh", "~/.aws/credentials"]
}
}
}
The keystore patterns rely on documented gitignore-style matching, so confirm them with /permissions. The docs name the gaps: Read denies do not cover grep -r or scripts that open files themselves, which is why the sandbox is on, and Bash(curl *) will not catch /usr/bin/curl or sh -c (settings reference). Project and local settings files cannot put a session into auto or bypassPermissions through defaultMode; Claude Code ignores those values there (for bypassPermissions, since v2.1.257), so a cloned repo cannot loosen them (settings, reference).
Codex
The Auto preset keeps network off and .git, .codex, .agents and .aws read-only (approvals). In ~/.codex/config.toml:
sandbox_mode = "workspace-write"
approval_policy = "on-request"
web_search = "cached"
cli_auth_credentials_store = "keyring"
[sandbox_workspace_write]
network_access = false
[shell_environment_policy]
ignore_default_excludes = false
ignore_default_excludes = false turns on KEY/SECRET/TOKEN filtering, and keyring moves tokens out of plaintext auth.json (auth). For file denies like "**/.env*" = "deny", copy the permission-profile example from the recommended configuration; permission profiles are Beta and "may change" (permissions). approvals_reviewer = "auto_review" is "not a deterministic security guarantee" (auto-review).
Antigravity
Antigravity splits settings by surface and account type.
- App, individual accounts. Four presets: Request Review, Default, Auto (Preview, v2.23.0+, not on business or enterprise accounts) and Turbo. Use Default or Request Review, never Turbo on a repo with signing material (agent settings).
- App, business and enterprise. The older Require Review, Proceed in Sandbox and Always Proceed settings. Google recommends Require review or Proceed in sandbox (admin settings), and I agree.
The CLI sandbox is off by default, so set these in ~/.gemini/antigravity-cli/settings.json:
| Setting | Value |
|---|---|
toolPermission | "request-review" |
enableTerminalSandbox | true |
allowNonWorkspaceAccess | false |
Add rules through the interactive /permissions manager at project, shared or global scope. Rules use action(target) format; Google's examples allow command(git) and command(npm test) and deny command(sudo) (docs). My own additions: allow command(flutter test), deny command(curl). Keep the browser allowlist at localhost (allowlist).
When is bypass, YOLO or Turbo mode ever acceptable?
Only inside a disposable container or VM holding no host secrets. On a laptop next to your keystore and SSH keys, my answer is never.
- Claude Code: bypass mode "offers no protection against prompt injection"; use it only in containers or VMs, ideally without internet (permission modes). A dev container does not stop exfiltration of
~/.claudecredentials, so never mount~/.sshinto it (devcontainer). - Codex:
danger-full-accessbelongs in an isolated CI runner or container (non-interactive mode). - Antigravity: Turbo means "Run all commands without restrictions" (agent settings).
How does prompt injection reach a Flutter developer's agent?
Prompt injection is text an agent obeys as instructions. The dangerous kind is indirect: input from external sources such as websites or files. OWASP's mitigations are least privilege, human approval for privileged operations and segregating untrusted content (LLM01), plus narrow tools over open-ended shell access (LLM06).
Prompt injection reaches coding agents in a Flutter workflow through four entry points:
- Web pages the agent fetches. A pub.dev README fits OWASP's "files and websites" class, though I know of no documented incident.
- GitHub issues. OpenAI's docs describe an issue hiding an instruction to POST the last commit to an external server (internet access).
- Repo rule files. Antigravity loads
AGENTS.md,GEMINI.mdand.agents/rules/*.mdfrom the workspace, and the rules page has no security warning about rule files from untrusted repos; its only cautions cover subfolder scanning and missing frontmatter (rules). - MCP servers that fetch outside content (Claude Code MCP).
Anthropic advises against piping untrusted content directly to Claude (security), and its auto classifier blocks actions driven by hostile content but "does not guarantee safety" (permission modes).
Antigravity has the most public research, from independent researchers:
- PromptArmor, November 20, 2025: Gemini used
catto get past the default gitignore-access block, then exfiltrated.envcredentials through the browser subagent; webhook.site was then on the default Browser URL Allowlist (PromptArmor). Current docs start it with onlylocalhost. - Johann Rehberger, November 25, 2025: five issues, including
.envexfiltration (Embrace The Red). - Mindgard, November 25, 2025, updated May 7, 2026: a repo rule copies an MCP config into the global config; Mindgard says no fix was confirmed (Mindgard).
- Pillar Security, April 20, 2026: code execution through
find_by_name, marked fixed by Google on February 28, 2026 (Pillar).
Do Claude Code, Codex and Antigravity train on your code?
It depends on the plan, not the tool. Anthropic and OpenAI say business and API plans are not trained on by default, and Google says Antigravity enterprise data is never used to train its foundation models. Consumer Claude accounts are trained on only if you allow it, Antigravity's individual terms allow it unless you change the data-use preference in settings, and OpenAI's Help Center says individual ChatGPT and Codex content may be used for training unless you turn it off in Data Controls.
- Claude Code. Does Claude Code train on my code? On Free, Pro and Max, only when the setting at claude.ai/settings/data-privacy-controls is on.
/feedbacktranscripts are kept for 5 years (data usage). - Codex. With ChatGPT sign-in, workspace settings apply; with an API key, your API organization's settings apply (auth). For individual plans, opt out in ChatGPT Data Controls (Help Center). API abuse logs are kept up to 30 days (API data).
- Antigravity. Individual terms let Google use Interactions to improve its products and machine learning, and employees and contractors may review them (terms). With Enable Telemetry on (Settings, Account in the app, or
/configin the CLI), Antigravity collects interactions to improve Antigravity; turn it off to opt out. CLI telemetry is always off for business accounts (settings).
A sandbox does not change what is sent to the model (sandbox environments). My rule: if a client contract says no training, the agent runs on a business or API plan.
How do you keep the Flutter supply chain safe when an agent edits pubspec.yaml?
Commit the lockfile and read the resolver's output, because Dart has no separate audit command. Why every pubspec.yaml change needs review is in my Antigravity workflow guide; these are the mechanics.
- Read
dart pub get. It flags packages with GitHub Advisory Database advisories;ignored_advisoriesapplies to the root package only (advisories). There is nodart pub audit(commands). - Commit
pubspec.lockfor apps (docs). It stores SHA256 content hashes that pub validates (glossary), so its diff shows what the agent changed. - Do not trust the badge too far. A verified publisher confirms domain identity only (docs); see OWASP LLM03.
- Approve MCP servers one by one. Anthropic does not security-audit any MCP server (security), Antigravity runs unconfigured MCP tools in Ask mode (MCP), and Codex offers per-tool
approval_mode = "prompt"(docs).
What review process should gate agent changes in CI?
Run agents read-only in CI, scope secrets to single steps, and keep human approval before merge. My daily habits are in the five-step review routine; this is the CI layer.
claude -pshows no trust dialog and runs the repo's hooks and.mcp.jsonservers, so add--bare(headless).codex execis read-only by default and--full-autois no longer supported; scopeCODEX_API_KEYto one step (docs). openai/codex-action defaults todrop-sudo, withcontents: readandpersist-credentials: falsein its sample.- Codex review rules "don't replace tests, branch protections, or required approvals" (GitHub).
# pre-merge review: agent-written Flutter PR
[ ] No .env, key.properties, *.jks, *.p8, *.p12 or service-account JSON in the diff
[ ] pubspec.yaml / pubspec.lock changes explained; dart pub get shows no advisories
[ ] No new MCP server, hook, AGENTS.md or .agents/ rule without review
[ ] android/ and ios/ changes (permissions, signing, Info.plist) read line by line
[ ] No API key or secret in Dart code or assets
[ ] flutter analyze clean, flutter test green
[ ] Human approval on a protected branch
Your backend still relies on App Check and Security Rules that never ship as allow read, write: if true (Firebase). I keep LLM keys behind a backend proxy, as in TourVista, Nest AI and Fluently AI.
The copy-paste AI coding agent security checklist
- Secrets. Add the
.gitignorelines. Apply the deny rules and settings above. Never paste a service-account JSON or.p8into a prompt. Runclaude purgeor lowercleanupPeriodDaysafter an agent read a secret (docs). - Permissions and sandbox. Sandbox on in all three, network off by default. No bypass, YOLO or Turbo outside a container or VM, and no
~/.sshmounted into one. - Prompt injection. Do not pipe untrusted issues or pages straight in. Keep browser and web allowlists minimal. Read
AGENTS.md,GEMINI.md,.agents/,.claude/and.mcp.jsonin a cloned repo before an agent opens it, and audit your Antigravity MCP config for unexpected entries, as the Cloud Security Alliance recommends. - Data and training. Check the Claude privacy setting, ChatGPT Data Controls and Antigravity Enable Telemetry. Use business or API plans where a contract forbids training. Skip
/feedbackon client sessions. - Supply chain and review. Commit
pubspec.lock, readdart pub getadvisories, approve MCP servers individually, and keep branch protection plus a human review of every diff.
Frequently Asked Questions
Can Claude Code, Codex or Antigravity read my .env file?
Claude Code and Codex can unless you block it. Claude Code documents no automatic exclusion, so add Read deny rules plus the sandbox, since deny rules miss grep -r and scripts (permissions). For Codex, use a deny glob from its recommended configuration. Antigravity's terminal sandbox blocks .env, but Turbo turns the sandbox off.
Is google-services.json a secret I need to hide from AI agents?
No. Firebase says its config file content is considered public, and Firebase-restricted API keys are not secrets; Security Rules and App Check protect your data (Firebase). The real secrets sit next to it: service-account JSON, keystores and any Gemini Developer API key.
Does Claude Code train on my code?
On Free, Pro and Max plans, only when the model-improvement setting is on, with 5-year retention, or 30 days if it is off. Under commercial terms (Team, Enterprise, API) Anthropic does not train on Claude Code prompts or code unless the customer opts in (data usage).
Does Google Antigravity use my code to improve its models?
On individual accounts, the Antigravity terms say Interactions improve Google and Alphabet machine learning and may be reviewed by employees and contractors. Turn off Enable Telemetry (Settings, Account in the app, or /config in the CLI) to opt out; CLI telemetry is always off for business accounts. For enterprise access, Google says code, prompts and transcripts are never used to train its foundation models (terms, enterprise).
Is it safe to use --dangerously-skip-permissions or Turbo mode?
Not on your own machine. Anthropic says bypass mode offers no protection against prompt injection and belongs in containers or VMs, ideally without internet. Antigravity's Turbo runs all commands without restrictions. For unattended runs, use a disposable container with no SSH keys, cloud credentials or signing material mounted (permission modes).
Is Codex sandboxed, and does it have internet access by default?
Yes. The Auto preset is workspace-write plus on-request approval in version-controlled folders, and network access stays off unless network_access = true is set. The sandbox is Seatbelt on macOS, bubblewrap on Linux and WSL2, and MXC on compatible Windows machines (approvals and security, sandboxing).
What should I do if an AI agent already read a real secret?
Treat it as compromised. Rotate or revoke it; Apple says to revoke a compromised App Store Connect API key immediately. Then clear local copies: Claude Code keeps tool output in plaintext transcripts under ~/.claude/projects for 30 days by default, which claude purge removes. Add a deny rule so it cannot happen again (Apple, Claude Code).
Want an AI-assisted Flutter workflow with these guardrails, or an LLM feature built safely (see integrating ChatGPT and Gemini in Flutter and my full AI workflow)? See my Flutter AI development service or get in touch.