Every Third PR Is Agent-Written: Protecting Secrets

One in three GitHub PRs is written by an agent. Learn how secret detection, sandboxing, and an LLM gateway prevent leaks before commit.

  • An agent in every third pull request
  • What changes in the risk calculus
  • A detector that reads context
  • The sandbox limits damage in advance

An agent in every third pull request

  1. According to GitHub, an AI agent is involved in one out of every three pull requests today, compared with fewer than one in ten a year ago.

  2. If the pace continues (this is an extrapolation, not a GitHub forecast), agents will write most of the code on GitHub within two years, and humans will not read all of it.

  3. For secrets, this means protection must trigger before commit without requiring human involvement at every step.

  4. The reason is A GitHub analysis of scaling secret protection and a series of announcements around it.

What changes in the risk calculus

  1. Previously, a secret leak was a rare event occurring at human speed.

  2. A developer would leave a key in the configuration, a scanner would catch it after the push, and someone would manually revoke and reissue it.

  3. The approach worked while a limited amount of code was being written and someone reviewed every line. An agent breaks both assumptions.

  4. It produces more changes per hour, and no one reads some of them line by line.

  5. The likelihood of finding a password or token in thousands of commits grows with scale, while manually reviewing every finding can no longer keep up. GitHub splits the task in two: prevent more leaks before they occur and reduce the manual work needed to respond to those that remain.

A detector that reads context

  1. Traditional secret scanning searches for patterns: a cloud provider key has a recognizable prefix and length. A database password in the `db_pass` variable has no such pattern, so these findings went undetected. GitHub announced a specially trained model for detecting leaked secrets.

  2. It reads the surrounding code and uses the context to identify likely credentials, including passwords without a recognizable format.

  3. The model is planned for three areas: secret scanning alerts, push protection (blocking a push containing a secret), and security review within Copilot.

  4. We expect the greatest impact from the third area.

  5. A check within the agent's workflow runs before the secret reaches the repository, so the key does not need to be rotated.

  6. Fixing it at this point costs the least.

Assess where AI can deliver impact in your process

The sandbox limits damage in advance

  1. The detector triggers after a secret has entered the code, while the sandbox reduces the chance of that happening. Local sandboxing in GitHub Copilot is now generally available for Copilot CLI, the Copilot app, and VS Code sessions with Agent Host.

  2. Commands and tools launched by Copilot receive limited access to the file system, network, and credentials.

  3. The policy is set by the developer or organization.

  4. Under the hood, Microsoft eXecution Container (MXC) translates a unified sandbox policy into isolation mechanisms for the specific operating system.

  5. For the company, this means one rule applies across different workstations.

  6. If an agent cannot access `~/.aws` or connect to the outside network, there is nothing for it to steal or publish.

  7. We consider this principle the mandatory minimum for any agentic environment.

Low-cost models and local execution

According to GitHub's early testing, it matched Claude Sonnet 5 on many coding tasks while using significantly fewer tokens and steps.

The data is preliminary, so it should be tested on your own tasks before switching. In Copilot CLI version 1.0.94-0, the `/model` command can find local models in the running Ollama instance.

The model is not added automatically: the developer sees the provider and endpoint and confirms the choice.

There will be many sub-agents, they will become cheaper, and some will run through local endpoints.

Each such channel belongs in the threat model, with two questions: where does the code go, and which keys enter the context?

How we build the security perimeter

  1. For AI-native development for clients, we use a three-layer model. 1. The secret never reaches the agent.

  2. Tokens with minimal permissions, a short lifetime, and access through a dedicated proxy. A key that is absent from the model context cannot appear in the commit either. 2. The execution environment is restricted.

  3. A sandbox for files, the network, and credentials, as in MXC.

  4. For server-side agents, container isolation and egress filtering provide the same result. 3. Traffic to the models passes through a single point. In LLM & Security Gateway, requests to external and local models pass through a single gateway that masks secrets and personal data and maintains an audit trail.

  5. Agents accessing corporate systems through MCP servers receive separate permissions for each tool.

  6. A repository-level detector serves as the fourth layer and protects against residual errors.

  7. Relying on it alone is risky: every detection model produces false positives and misses. GitHub has so far described plans, so check the documentation for timelines for specific features.

Conclusion

When a third of changes pass through an agent, keys enter the code faster than people can revoke them. Protection is architectural: minimum agent privileges, environment isolation, a single traffic-control point, and a detector as the last line. A manager buying agent-based development for speed should ask the contractor where its sandbox is and who can see model requests. Without those answers, the first leak will require keys to be revoked across the entire infrastructure.

Discuss the article: Every Third PR Is Written by an Agent: How…

Enter your email or phone number so we can get back to you.

Send via: