Independent AI intelligence Two editions daily · ET
Fervor AI

Analysis · November 17, 2026 · concept

GitHub secret scanningGitHub Copilotagent-securityai-skillscodexprivacy

GitHub Secret Scanning Now Runs Inside Your Coding Agent, Before the Pull Request

Turn on one setting and your agent checks its own work for leaked keys before you ever see the diff. Here is how, and what it still misses.

Leaked API keys used to be a human mistake with a human pace. Someone pasted a token into a config file, committed it on a Friday, and a scanner caught it hours later.

Coding agents changed the pace. An agent can write forty files in ten minutes, and some of those files are exactly where keys like to hide: a .env.example filled with real values, a test fixture with a working database URL, an MCP config with a token in it. By the time a pull request opens, the key has already been written, staged and maybe pushed.

On November 17, GitHub moved the check to where the leak starts. Copilot's security review can now run GitHub secret scanning on a set of changes inside the agent session, before anything is merged. The agent writes, the agent checks, then you review.

That is the idea worth keeping even if you never touch Copilot: the cheapest place to catch a secret is the diff the agent is about to hand you. After the push, every fix costs more.

There is a catch, and it is a practical one. The feature is off by default, it only reads the changes in front of it, and each scan costs AI credits. So it helps only if you turn it on and understand its edges.

Why agents make this worse

Numbers first, because they are the reason this matters.

GitGuardian's State of Secrets Sprawl 2026 counted 28.65 million new hardcoded secrets in public GitHub commits during 2025, a 34% rise over the year before. Secrets for AI services alone grew 81%.

The line that stops people: commits made with Claude Code's help showed a 3.2% secret-leak rate, against a 1.5% baseline across all public commits. GitGuardian itself warns that this "should not be read as a simple tool failure," and that is fair. Agents write more code, touch more config, and often run in projects where people are moving fast. But the direction is clear. More generated code means more places for a key to land.

Two more numbers explain why a late catch is expensive. When GitGuardian rechecked secrets it had confirmed as valid in 2022, more than 64% still worked in January 2026. People leak keys, then never rotate them. And MCP config files, the small JSON files that tell an agent which tools to connect to, exposed 24,008 unique secrets on public GitHub, 2,117 of them valid.

A key that sits in history for years is a key someone else can find.

What GitHub shipped

GitHub already had two layers of secret scanning:

  • Secret scanning alerts check your repository, including history, and flag what they find.
  • Push protection blocks a push that contains a known secret. GitHub's docs say it is on by default for your personal pushes to public repositories, but repository-level push protection has to be switched on by an admin.

The November 17 change adds a third layer that runs earlier, inside the session where the code is written. Copilot has a built-in reviewer called the security review specialist (think of it as a second agent whose only job is to read a change for security problems). It already looked for exposed secrets with an LLM. Once you opt in, it also runs:

  • Provider patterns for more than 500 secret types, the same detectors GitHub built with 150+ partners such as cloud and payment providers.
  • A fine-tuned detection model, first announced on October 7, that reads the code around a string to spot credentials with no fixed format, such as a password inside a database connection string.

It works in four places: Copilot CLI, the Copilot desktop app, your own agents built on the Copilot SDK, and Copilot code review on pull requests. GitHub says no extra plan is needed if you can already use Copilot security review or code review, but scans spend AI credits under a separate Secret Protection SKU (a billing line item, so the usage shows up on its own).

The part that changes how you work

The interesting shift is not the detectors. GitHub had those. It is who runs them, and when.

Before, the flow looked like this: the agent writes code, you review it, you push, and push protection or an alert catches the key. You are the one carrying the mistake through each step.

Now the agent can be told to check itself before it returns. In Copilot CLI or the app, the agent can hand its changes to the security-review specialist as a subtask. With the SDK, your own agent can call it with session.rpc.tasks.startAgent and agentType: "security-review" before returning its work, so your custom agent gets secret detection without you maintaining detectors.

This is the same pattern good teams use for tests. The agent should not say "done" until the check passes. Secrets just joined the list of things it checks.

Where it sits next to your other checks

It helps to picture three nets at three heights.

The lowest net is the session check, the new one. It runs while the agent is still working, on the exact files it changed, and the agent can fix what it finds before you see anything. It is the cheapest catch because nothing has been pushed yet.

The middle net is push protection. It runs when someone tries to push, and it blocks the push instead of warning. It does not care whether a person or an agent wrote the code, which is exactly why it should stay on even after you trust the session check.

The top net is secret scanning alerts on the repository. It is the only one of the three that looks backward through history. It is also the slowest, because by the time it fires, the key is already on GitHub's servers.

Each net misses something the others catch. The session check misses anything nobody asked it to review. Push protection misses repos where nobody switched it on. Alerts arrive after the fact. Run all three and the gaps mostly close.

Put this into practice

Here is the lowest-friction path, in the order I would do it.

1. Turn it on where your agent runs. Each tool has its own switch:

  • Copilot CLI: inside an interactive session, run /settings aiSecretDetection on. Then run /security-review on your changes, or ask the agent to delegate to security-review.
  • Copilot app: Settings, then Experimental, then turn on AI secret detection.
  • Copilot SDK: set the SECURITY_REVIEW_FINE_TUNED_MODEL feature flag to true when you create the session.
  • Copilot code review: in the repository's Settings, open Copilot, then Code review, and turn on Secret scanning under Security.

All of this comes straight from GitHub's November 17 changelog. Expect a short findings list if something turns up, and nothing dramatic if the diff is clean.

2. Make the check part of "done." Add one line to whatever instructions file your agent reads (for Copilot, your custom instructions; for other agents, their equivalent): run a security review before reporting a task complete, and fix any secret it flags by moving it to an environment variable. The setting gives the agent the tool. The instruction makes it a habit.

3. Switch on repository push protection. The session check only works when someone runs it. Push protection is the net underneath. If you administer the repo, turn it on in the repository's code security settings so a missed key still bounces at push time.

4. Scan your history once. The new check reads changes, not history, so an old key stays invisible to it. Run a full repository scan with GitHub secret scanning alerts if you have it, or with any history scanner you trust, and treat what it finds as a rotation list.

5. Rotate first, delete second. If a real key turns up, revoke it at the provider before you scrub the commit. A deleted line in Git does not un-leak a key someone already copied.

6. Look hard at MCP configs. Given how many valid tokens GitGuardian found in them, give these files a second look before they reach a commit. Keep tokens in environment variables and reference them from the config.

Honest limitations

It is off by default. Until you opt in, security review uses only its LLM-based detection. Plenty of teams will assume they are covered when they are not.

It reads the diff, not the past. GitHub says plainly that the review "doesn't search repository history." Every key leaked before today stays where it is.

It costs credits. Each scan consumes AI credits under the Secret Protection SKU. On a busy repo with many agent sessions, that is a line item someone will notice.

It is a preview. Public preview means behavior and names can change. Pin nothing important to the exact flag names yet.

It lives in Copilot. If your agent is Claude Code, Codex or OpenCode, this switch does not exist for you. The pattern still transfers: run a secret scanner as the last step of every agent task (a pre-commit hook works), and keep push protection on as the backstop.

Detection is not prevention. A scanner finds a key after it is written. The real fix is an agent that never needs to see the key at all, because it reads secrets from the environment at run time.

The shift to keep

For years, secret scanning was a gate at the end of the pipeline. Coding agents move faster than that gate was designed for, and they write in exactly the files where keys hide.

Moving the check into the session is the right instinct, from GitHub or anyone else. The agent produced the diff, so the agent should prove the diff is clean before you read it.

So pick one repo this week and set up all three nets: turn on the session check for the agent you use and add "run a security review before you say done" to its instructions, switch on push protection, and run one history scan. Then see what it finds. If the answer is nothing, you have lost twenty minutes. If the answer is a live key from 2024, you have found it before someone else did.

Sources: GitHub Changelog, "Secret scanning on demand for developers and agents" (Nov 17, 2026); GitHub Changelog, "Purpose-built model for leaked secret detection" (Oct 7, 2026); GitHub Docs, push protection; GitGuardian, The State of Secrets Sprawl 2026 (Mar 17, 2026).