PULSE
AI 认知观点 VIEWPOINT重要度 62

AI 写代码提速,密钥保护必须跟上

GitHub · 2026-10-07 · 原题《Secret protection must scale with software》 · 原文约 7 分钟 · 阅读原文 ↗
AI 提速 vs 密钥防护 核心矛盾:产出速度 > 审查能力 速度侧(AI 代理) 每 3 个 PR 有 1 个涉 AI 一年前不到十分之一 推送量增长 2.84 倍 含凭证推送增长 2.59 倍 覆盖拦截比例 6.63% → 3.93% 开发者自觉持续下降 人工撤销平均 40 天 五分之一超 90 天 防护侧(平台拦截) 推送保护仅拦约 30% 70% 已进入仓库历史 四体问题 精度 · 延迟 · 吞吐 · 成本 ModernBERT 分类器 上下文评估 · 不到 2 毫秒 可预防密钥有望翻倍 更精确 · 成本更低 结论:从开发者自觉 → 平台推送前自动拦截
AI 代理让代码产出速度远超人工审查能力,密钥泄露的防护必须从依赖开发者自觉转向平台在推送前自动拦截,否则漏洞规模将不可持续。

论证要点

  1. GitHub 上每三个 PR 就有一个涉及 AI 代理,一年前还不到十分之一;若趋势延续,两年内大部分代码可能由代理编写,且很多不会被人类完整阅读。
  2. 九季度数据显示,推送量增长 2.84 倍、含凭证推送增长 2.59 倍,但每次推送的泄露比例没有统计上可检测的上升趋势,开发者覆盖推送拦截的比例反而从 6.63% 线性降至 3.93%。
  3. 手动撤销密钥平均耗时约 40 天,约五分之一超过 90 天;开发速度在加快,而暴露的凭证可能数周甚至数月仍可用,人工修复无法同步扩展。
  4. 推送保护目前只能拦截约 30% 的新检测密钥,剩余 70% 在凭证已进入仓库历史后才被发现;预防随算力扩展,修复仍随人力扩展。
  5. 密钥保护面临“四体问题”:精度、延迟、吞吐量和成本相互耦合;误报会打断开发者并降低下一次拦截的可信度,太慢或太贵的检查无法在关键路径上运行。
  6. GitHub 与微软应用科学团队构建了 ModernBERT 分类器,在上下文中评估候选密钥,不到两毫秒处理一批,比现有基于 LLM 的流水线更精确且成本更低,有望将可预防的密钥数量翻倍以上。

对实践的启示

做 AI 应用或依赖 AI 写代码的团队,不能只靠提醒开发者小心;应把密钥检测和拦截嵌入推送前流程,并关注平台级自动撤销能力。对使用 GitHub 的组织,新分类器将进入推送保护、后推送扫描、企业服务器和 Copilot CLI,部分功能消耗 AI 积分。

作者承认的反方与局限

作者承认,公开讨论容易把密钥泄露归咎于 AI 让开发者变得粗心,但九季度数据并未显示每次推送的泄露比例有统计上可检测的上升趋势,开发者覆盖推送拦截的比例也在下降,说明开发者比以往更理解风险。

原文摘引

Developers aren’t becoming more careless; they’re being outpaced.
Prevention scales with compute, but remediation still scales with people.
Telling developers to be more careful cannot solve this imbalance.
▸ 展开原文全文(34 段,抓取自 GitHub)

Erin Havens

Erin Havens is a Product Manager at GitHub, focused on security products. 100+ ships across products like Secret Protection and Dependabot (and counting).

Developers aren’t becoming more careless; they’re being outpaced. The tools that let developers create more software should also take on more of the work of protecting it.

|

7 minutes

Today, one in three pull requests on GitHub involves an AI agent. A year ago, that number was fewer than one in 10. If that pace holds, within the next two years, most of the code pushed to GitHub could be written by an agent. Much of it may never be fully read by a human.

If developers and agents move faster, we have a responsibility to ensure protection keeps up with the accelerated rate of code creation. That means preventing more leaks before they happen and making the response to exposures that remain less dependent on manual human effort.

This is a pivotal point for leaked secrets. Developers aren’t becoming more careless; they’re being outpaced. The tools that let developers create more software should also take on more of the work of protecting it.

In this essay, I share the nine quarters of data behind that claim. I also introduce the fine-tuned classifier we built with Microsoft Applied Sciences to extend push protection to unstructured secrets. The model assesses a whole set of candidate secrets in less than two milliseconds and could more than double the number of secrets that we can prevent.

A new secret appears in publicly visible code about once every two seconds, doubling yearly for the past three years. Public discourse is quick to jump to the idea that AI made developers careless.

Between Q2 2024 and Q2 2026, screened pushes grew 2.84 times while pushes carrying credentials grew 2.59 times. Across nine complete quarters of data, we found no statistically detectable trend regarding per-push prevalence. At the same time, we found data suggesting that, more than ever, developers understand the risk of accidental exposures and are less willing to accept that risk. Over the same period, the share of push-path blocks overridden by developers fell linearly from 6.63% to 3.93%. These figures challenge the common claim that agents are causing developers to become more careless.

More pushes, no clear rise in push prevalence

2026 Q2 · 574M pushes · 0.47% with secrets

At a fixed rate, doubling activity doubles expected exposures. If each exposure requires the same human response, the workload doubles too. The mean time to manually revoke a secret hovers around 40 days; roughly one in five took more than 90 days. We’re accelerating the creation of software while exposed credentials can remain usable for weeks or months, because human remediation can’t scale at the same pace as development.

Telling developers to be more careful cannot, on its own, solve that problem. As the amount of code grows, we must prevent more exposures and reduce human effort required by those that remain, if software development is to remain sustainable.

I’ve spent the past few years working on secret scanning at GitHub and the past year as product lead for the area. Our greatest impact has come from connecting the dots between detection to systems that can act.

GitHub’s catalog covers more than 150 technical partners through our secret scanning partnership program. Through our partner program, we work with participating secret issuers to build out detectors and report public exposures so they can respond. In Q2 2026, public scanning successfully reported an average of 26 credential matches a second, including repeat observations. Once notified, a large number of these partners immediately revoke the token: OpenAI API keys, Google Cloud account credentials, Slack webhooks, Hugging Face user tokens, SendGrid keys, etc. The owner may still need to replace the token, but revocation can happen without waiting for a developer to find and process a GitHub alert.

Push protection intervenes earlier. It stops recognizable credentials before it enters repository history, giving the developer or agent a chance to correct the change before there’s an exposure to investigate. We work with our technical partners to increase precision rates of their detectors as much as possible, until we’re confident enough to push-protect these secrets for the developer community by default.

Thanks to the efforts of our partners, in the past month, a secret was blocked by push protection at least once every second. When it comes to issuer-bound credentials, GitHub blocks more secrets than those which slip. I’m proud of how ordinary we’ve made that feel for developers.

When including additional secret types, push protection stops about 30% of newly detected secrets before they enter repository history. We find the remaining 70% after the credential is, unfortunately, already lost. And:

- Prevention scales with compute, but remediation still scales with people.

- Refusing a push costs compute; cleaning up a secret already lost to visible history costs a developer’s time and attention.

- As the amount of code grows, we must prevent more exposures and reduce the human effort required by those that remain, or else the volume of vulnerabilities introduced will become untenable.

Telling developers to be more careful cannot solve this imbalance. Recognizing more of these secrets, earlier in development flows, is work the platform must take on.

Before a secret crosses the push boundary, the cost of stopping it is small, and the decision is binary: block or allow. After it crosses, the same string can authenticate to a real system, and the cost is unbounded.

In many cases, our only detection clue may be the surrounding code and world context. A provider-issued token may have a recognizable prefix. An internal database password may be completely unstructured, with no identifying pattern at all. We were already using context to find these secrets post-push; the problem was balancing that context-aware judgement with other factors.

We refer to this as the “four-body problem” for secret protection: precision, latency, throughput, and cost are coupled constraints. Prevention must be worth a developer’s time. A finding suitable for later review may not justify blocking a push. A false positive interrupts a developer and makes the next block harder to trust. A check that is too slow, expensive, or difficult to scale limits how often it can run.

Our new ModernBERT classifier assess candidate secrets in context, without generating code or prose. It’s not only more precise than existing LLM-based pipelines, but it’s incredibly fast, evaluating candidate batches in under two milliseconds. It’s also extremely cost efficient, enough to run at scale in the critical path.

The inclusion of our model in push protection makes it possible for us to more than double the number of secrets that we’re able to prevent. The feature is currently in private preview. Later this month, the feature will be available to organizations with GitHub Secret Protection across Enterprise Cloud and GitHub Teams. It will consume AI credits.

We’re also bringing the model to developer surfaces beyond the push.

- Starting today, any organization with AI secret detection will be automatically updated to the new model. Alerts opened from these post-push scans remain included with an organization’s purchase of secret scanning at no additional cost.

- The model will also ship with GitHub Enterprise Server 3.23 in public preview, bringing AI-detected alerts to Secret Protection customers even in air-gapped environments.

- We’re adding the classifier to the /security-review command for the Copilot CLI and Copilot App, so Copilot users can address secrets before a push even without needing an organization’s GitHub Secret Protection plan. AI credit usage will be attributed to GitHub Secret Protection in your AI usage insights.

The future we want is one where developers can entrust m