GitHub Automates Secret Protection for AI-Generated Code
GitHub is expanding secret protection to detect and block more leaked credentials as AI-generated code grows.
Source: https://github.blog/ai-and-ml/github-copilot/secret-protection-must-scale-with-software/

GitHub Automates Secret Protection for AI-Generated Code
AI is changing the speed at which software is created.
Developers can now use AI coding assistants and agents to generate code, modify repositories, fix bugs and build software much faster than before. But there is another side to that acceleration: security teams also have to protect a much larger amount of code.
GitHub is responding by expanding its automated approach to secret protection.
In a new announcement published October 7, 2026, GitHub said that one in three pull requests on the platform now involves an AI agent. A year earlier, that figure was fewer than one in ten. GitHub says that if the trend continues, most code pushed to GitHub could be written by AI agents within the next two years.
That creates a major security challenge.
AI can write code extremely quickly, but generated code can accidentally contain sensitive information such as API keys, passwords, access tokens and other credentials.
If those secrets reach a public repository, attackers may be able to use them to access systems or services.
GitHub's argument is straightforward: as software creation becomes faster, software protection also needs to become more automated.
The secret problem
A secret is sensitive information that should not be exposed publicly.
Examples include:
API keys
Database passwords
Cloud credentials
Authentication tokens
Service credentials
Access keys
Developers sometimes accidentally place these values inside source code.
For example, a developer might create code that connects to an external API and accidentally include an API key directly in the file.
The problem becomes more difficult when AI agents are producing large amounts of code.
A human developer might carefully inspect a small project.
An AI coding agent can generate or modify many files in a much shorter period.
That means security tools cannot rely entirely on humans noticing every mistake.
GitHub says developers are being outpaced
GitHub's data suggests that the growing number of exposed secrets is connected to the increasing volume of software activity rather than simply developers becoming less careful.
According to GitHub, a new secret appears in publicly visible code about once every two seconds, and that rate has doubled each year for the past three years. GitHub also says that between Q2 2024 and Q2 2026, screened pushes increased 2.84 times while pushes containing credentials increased 2.59 times.
GitHub argues that these numbers challenge the idea that AI is simply making developers careless.
The larger issue is scale.
If developers and AI agents produce more code, there are naturally more opportunities for sensitive information to accidentally appear in that code.
Security systems therefore need to operate at the same speed as software development.
Push protection stops secrets earlier
GitHub already has a system called push protection.
The idea is simple: detect recognizable credentials before they become part of a repository's history.
Instead of waiting for a secret to be discovered after a developer pushes the code, the system can intervene during the push.
The developer or AI agent can then remove or correct the secret before the exposure becomes part of the repository history.
GitHub says that in the past month, push protection blocked a secret at least once every second. The company also says it works with more than 150 technical partners through its secret-scanning partnership program.
This approach is important because prevention is generally easier than cleanup.
Once a secret becomes visible in repository history, simply deleting the line does not necessarily solve the problem.
The credential may already have been copied, indexed or accessed.
The safer approach is to prevent the exposure whenever possible.
GitHub is adding AI-powered detection
The latest development is a new fine-tuned classifier designed to identify more types of secrets.
Traditional secret detection can look for recognizable patterns.
For example, certain credentials have predictable prefixes or formats.
But not every secret looks like a traditional API key.
An internal database password, for example, could look like an ordinary string.
GitHub says its new AI-powered generic secret detection model uses surrounding code context to identify password-like values that may otherwise be difficult to recognize through simple pattern matching.
This is an important change.
Instead of asking only:
“Does this string look like a known secret?”
the system can also consider:
“How is this value being used inside the surrounding code?”
That context can help identify secrets that do not have obvious patterns.
The new model is designed for speed
AI security systems have a major challenge.
Security checks often need to happen during development, which means they cannot be extremely slow.
If every code push required a large AI model to spend several seconds or minutes analyzing every file, developers could become frustrated.
GitHub says its new ModernBERT-based classifier can evaluate batches of candidate secrets in less than two milliseconds.
GitHub says the model is efficient enough to operate in the critical path and could more than double the number of secrets it can prevent.
The feature is currently in private preview, with GitHub saying it will later become available to organisations with GitHub Secret Protection across Enterprise Cloud and GitHub Teams.
Prevention is better than manual cleanup
GitHub highlights an important difference between prevention and remediation.
Before a secret crosses the push boundary, the cost of stopping it can be relatively small.
The developer receives a warning or the push is blocked.
After a secret enters repository history, the situation becomes more complicated.
The credential may need to be revoked.
The developer may need to identify where it was used.
Other systems may need to be checked.
A replacement credential may need to be generated.
Security teams may need to investigate whether the secret was accessed.
GitHub says the average time to manually revoke a secret remains around 40 days, while roughly one in five secrets took more than 90 days to revoke.
That demonstrates why automated protection matters.
A security system that can prevent a secret in milliseconds is fundamentally different from a process that waits for a developer to discover an alert weeks later.
AI-generated code changes the security equation
AI coding tools are changing how software is produced.
A developer can ask an AI agent to create a feature.
The agent can inspect the repository, modify multiple files and potentially run tests.
This can dramatically increase productivity.
But it also means that security needs to be integrated into the same workflow.
The old model was:
Developer writes code → developer reviews code → security checks code
The emerging model is:
Developer + AI agent write code → automated security checks continuously → developer handles important decisions
This does not mean developers can stop reviewing code.
Instead, security automation can take care of repetitive detection while developers focus on higher-level decisions.
GitHub is also bringing detection into Copilot
GitHub says the new classifier will be added to the /security-review command for the Copilot CLI and Copilot App.
This allows Copilot users to address potential secrets before pushing code, even without an organisation's GitHub Secret Protection plan. AI credit usage will be attributed to GitHub Secret Protection in AI usage insights.
This is an interesting development because security is becoming part of the AI coding workflow itself.
Instead of treating security as a completely separate stage, AI-assisted development can include security checks while the code is being created.
That could become increasingly important as coding agents become more autonomous.
Security also needs to work in restricted environments
GitHub says the new model will also ship with GitHub Enterprise Server 3.23 in public preview.
This brings AI-detected alerts to Secret Protection customers in air-gapped environments.
Air-gapped environments are systems designed to operate without normal connections to external networks.
These environments are often used when organisations have particularly sensitive infrastructure or strict security requirements.
Supporting AI-assisted secret detection in these environments shows that GitHub is thinking about security automation beyond ordinary cloud development.
AI writes faster, so security must move faster
This is the bigger lesson from GitHub's announcement.
AI coding is increasing the amount of software developers can produce.
That is valuable.
But security cannot remain a completely manual process while software creation becomes increasingly automated.
If an AI agent can generate hundreds of lines of code in seconds, security tools need to be able to analyze that code at a comparable scale.
This does not mean every security decision should be handed over to AI.
It means repetitive security work can increasingly be automated.
Humans can then focus on decisions that require context, judgment and responsibility.
What this means for Indian developers
This trend is highly relevant to Indian developers and startups.
India has a large developer ecosystem, and AI coding tools are becoming increasingly common among students, freelancers, startups and enterprise engineering teams.
A small startup might use AI to generate an entire feature in a short period.
A student might use an AI coding assistant to build a web application.
An enterprise team might use coding agents across hundreds of repositories.
In all these cases, sensitive information can accidentally appear in source code.
That makes automated secret protection increasingly useful.
Developers should still follow basic security practices:
Never put real passwords in source code.
Never publish API keys in public repositories.
Use environment variables or secure secret-management systems.
Rotate credentials immediately if they are exposed.
Review AI-generated code before deploying it.
Automated protection is an additional safety layer, not a replacement for secure development practices.
What this means for students
For students learning programming, this is an important lesson about AI-assisted development.
Using AI to generate code is easy.
Building secure software is harder.
Students should learn not only how to prompt an AI coding assistant but also how to identify secrets, use environment variables, manage credentials and review generated code.
For example, instead of putting:
API_KEY = "real-secret-key"
inside a project, developers should learn how to safely load secrets through appropriate environment or secret-management mechanisms.
These habits become even more important when AI agents are generating code automatically.
The bigger trend: security is becoming agentic too
The most interesting part of this story is the broader trend.
AI is making software development more automated.
That means security also has to become more automated.
The future development workflow could look like:
AI writes code → security scans code → secrets are detected → risky changes are blocked → developer fixes the issue → code continues
The security layer becomes part of the development pipeline rather than something that happens only after software is created.
This could become increasingly important as AI agents gain the ability to work independently for longer periods.
The final takeaway
AI can dramatically increase how quickly developers create software.
But faster development also means faster security problems if protections do not keep up.
GitHub's latest secret-protection work is an example of the industry responding to that challenge.
The goal is not simply to tell developers to be more careful.
It is to make security systems capable of operating at the same scale as modern software creation.
The key idea is simple:
AI writes more code → more opportunities for secrets to leak → automated security must scale with AI.
For developers, the message is equally simple:
Let AI help you write faster, but make sure security moves just as fast.