ZenChAIne
記事一覧に戻る
Preventing Accidental GitHub Data Leaks in AI-Assisted Development

Preventing Accidental GitHub Data Leaks in AI-Assisted Development

ZenChAIne·
GitHubSecurityAI-Assisted DevelopmentClaude CodeCodex

Introduction

In its October 7, 2022 notice, Toyota reported that a contractor had mistakenly uploaded part of the T-Connect source code to a publicly accessible GitHub account, including a data-server access key. The code was public from December 2017 through September 15, 2022, with possible exposure of 296,019 email-address and customer-management-number records.

Money Forward also held files containing personal information in GitHub repositories. Its May 1, 2026 first report described unauthorized access using leaked credentials and the copying of repositories; its June 23 fourth report limited the potentially exposed personal information to material in those repositories and reported no production-environment leakage.

Development repositories can accumulate credentials and real data alongside code. When delegating development operations to AI, decide what belongs there first, then enforce that decision before data is sent.

Key points

  • Developers can delegate commits and pushes to agents, while threat reports also document AI use in collecting and analyzing exposed information.
  • Define what may enter Git and AI services for each project, use synthetic or masked data, and record the policy in AGENTS.md.
  • Combine agent hooks, Git hooks, and GitHub push protection; revoke exposed credentials rather than relying on deletion.

What changes on the development and attacker sides?

Delegating commits and pushes expands the review question from whether generated code is correct to what information the agent is about to send. A workflow in which a developer reads generated code and saves it manually offers different checkpoints from one in which an agent edits files and transmits the result.

Apiiro's November 5, 2026 investigation documented Claude Code saving a secret-bearing command in plaintext in .claude/settings.local.json after the user selected “Yes, and don't ask again.” Accidentally committing that local file and pushing it to a public repository exposes the saved secret.

The reported 2,539 detections cover current files, history, shared settings, and other sources. They were classified from format and context; the researchers did not use the credentials, test their validity, or contact the hosts.

Attackers also use AI for collection and analysis. Anthropic's September 2026 threat report records observed operations that searched public code and containers for credentials and validated the findings.

Treat reading exposed code and connecting related information as tasks that an adversary may support with AI. As the information handled by development agents expands, checks before transmission should also move beyond a developer's memory and manual attention.

How should a project define its information boundary?

Decide what may be stored or transmitted from the organization's policy and the project's contracts. Keep real credentials and personal information out of ordinary source repositories, and separately establish what may be sent to an AI reviewer.

Use dummy or synthetic test data, and mask customer names, contract details, identifiers, and other sensitive fields when describing a real support case. Removing a name may leave enough information to identify a person or project, so prefer recreating only the conditions needed to reproduce the problem with fictional inputs.

One project may authorize private source code in an approved cloud AI service, while another requires an internally hosted language model or a human reviewer. For example, storing personal information in Google Sheets already involves a decision to entrust that information to Google. If Gemini is prohibited, the organization should be able to explain the different treatment under its information-management policy.

Even services from the same provider may differ in purpose, retention period, applicable agreement, and settings, so approval for Sheets does not automatically authorize sending the same information to Gemini. Decide for each project from the actual terms of use and data handling, rather than relying solely on a service name or its classification as AI.

An internally hosted model still needs controls over inputs, logs, and backups. The next article will examine contracts, training use, retention, and transfers to other models; the immediate task is to determine the information permitted in each project.

Record the decision in AGENTS.md

Write the agreed policy into AGENTS.md, which Codex reads as project instructions. The following is an illustrative policy to adapt to the actual data and approved destinations of a project.

text
Information handling for this project
- Git may contain code, publishable documents, and approved synthetic data.
- Do not add real credentials, personal information, or customer source records.
- Use dummy test data. Minimize and mask descriptions derived from real records.
- Cloud AI may receive only code and synthetic data approved for this project.
- Refer internal-only information to an authorized internal model or a human.
- Hold transmission and ask the responsible person when classification is unclear.
- Run the specified checks before committing and pushing; do not skip failures.

If the team also uses Claude Code, reference the same policy from CLAUDE.md so agents work from a consistent decision. AGENTS.md communicates that decision; configure access permissions, allowed destinations, and execution gates separately.

Where should the boundary be enforced?

Apply checks when the agent uses tools, when Git records or sends changes, and when GitHub accepts a push. Use deterministic detection for recognizable credentials and human or AI review for customer documents whose sensitivity requires understanding their contents.

The project's information boundary is recorded in AGENTS.md and implemented through agent hooks, Git hooks, and GitHub receiving-side controls. Post-push CI cannot prevent the initial transfer.
The project's information boundary is recorded in AGENTS.md and implemented through agent hooks, Git hooks, and GitHub receiving-side controls. Post-push CI cannot prevent the initial transfer.

Before the agent executes a tool

An AI harness is the runtime that gives a model tools and manages their permissions and execution. Codex and Claude Code document PreToolUse hooks for checking supported operations before execution, with synchronous command hooks able to reject an operation.

Restrict access to secret-storage locations and run deterministic checks on the exact changes intended for transmission. Searching a command string for git push misses alternative scripts and API writes, so also limit write credentials and outbound destinations.

Use a scanner such as Gitleaks for secrets, including API keys and private keys, and give a separate review agent the applicable policy and proposed changes to inspect for real customer data or internal documents. Make the reviewer read-only, avoid reproducing sensitive contents in logs, and implement the hold on failure, timeout, or uncertainty in the calling program.

Review again after the content changes and require a responsible human to approve exceptions. Claude Code labels its agent-based hooks experimental, so use command-based enforcement and treat the model's content review as an additional check.

Before Git records or sends changes

Git hooks also cover Git operations performed outside the agent, including a terminal or GUI. Use pre-commit to inspect staged content and pre-push to inspect the commits being sent.

Scanning only the final state misses a key added in one commit and removed in a later commit that is still being pushed. Combine forbidden-path checks and secret detection, including settings that an agent updates.

Distinguish Claude Code's shared .claude/settings.json from local .claude/settings.local.json. Exclude local settings through the project's ignore policy and scan shared settings, including permission rules, for sensitive contents. The documented global-ignore safeguard when Claude Code creates the local file should not be the team's only protection.

Adding an ignore rule does not untrack an already tracked file. Revoke exposed credentials, untrack the local file, and assess the history and other copies as well.

When GitHub receives the push

Local hooks can be bypassed through configuration changes or options such as --no-verify, so enable GitHub push protection to reject supported secrets at receipt. Verify eligibility, repository visibility, enabled patterns, activation, and bypass permissions when deploying it.

Where forbidden locations are known, push rulesets can restrict paths and other file properties. Custom pre-receive scripts are a GitHub Enterprise Server capability; on GitHub.com, combine the features available to the repository.

Use GitHub Actions after a push to stop a subsequent merge or deployment. The data has reached GitHub by then, so checks intended to prevent its initial transmission belong before the push and at receipt.

What should happen after a leak?

Revoke and replace potentially exposed credentials first. Deleting a file or rewriting Git history cannot make a copied credential unusable.

For personal information or customer documents, investigate destinations, exposure periods, and impact, then involve the reporting and customer-response owners under the organization's incident procedure. Coordinate history cleanup and treatment of other copies with the developers whose work may be affected.

FAQ

Does writing AGENTS.md stop an agent from sending data?

It shares the policy that the agent should follow. Add permissions and execution gates to cover missed instructions and mistaken judgments.

Can the reviewer receive all customer information?

Choose the reviewer according to the project's contract and information policy. Reduce inputs through synthetic data or masking where possible, and use an authorized internal model or a human when external transfer is prohibited.

Does passing the checks establish that no confidential material remains?

Review customer documents and real data in addition to paths and recognizable credentials. Update the policy and checks when adding a new information type or transmission route.

Summary

Before delegating commits and pushes, define what may enter Git and AI services for the project and record it in AGENTS.md. Translate that policy into permissions and checks before transmission, including a way to stop and resolve uncertain cases.

Our Agent Skills article discusses managing agent instructions. The third article in this series will cover counterfeit development tools and modified plugins. ZenChAIne's development and technical support can help review information handling and AI development workflows.

References

Official documentation checked on November 9, 2026. Recheck product behavior when deploying the controls.