By · Last updated 2026-03-29

返回博客人工智能安全

GitHub 3900万次泄露:AI编程工具的安全风险

67%的开发者曾意外在代码中暴露密钥(GitGuardian 2025)。2024年GitHub泄露的密钥达3900万个,同比增长25%。

March 29, 20268 分钟阅读
GitHub secret leaksdeveloper AI securitycredential exposureMCP Server protectionGitGuardian 2025

一年内3900万个凭证泄露

GitHub Octoverse 2024年报告发现,2024年GitHub上泄露了3900万个密钥,较2023年同比增长25%。这些密钥包括API密钥、数据库连接字符串、身份验证令牌和云服务凭证。

原因众所周知:开发者在代码提交时将密钥夹带其中——来自调试会话,或者直接硬编码而非存储在环境变量中。3900万次泄露表明,这不是偶发现象,而是普遍惯例。

AI工具开辟了第二条泄露渠道

GitGuardian 2025年研究发现,67%的开发者曾意外在代码中暴露密钥。导致GitHub泄露的同样习惯,也正在制造AI工具泄露。

开发者将代码粘贴到Claude、ChatGPT或其他AI助手寻求帮助,而这些代码往往包含有效的凭证。AI模型接收到这些密钥,可能将其存储在对话历史中,并将其发送至服务提供商的服务器,开发者随即失去对这些凭证的控制——且不会收到任何警告。

三个典型场景:

调试数据库问题。 开发者粘贴一段报错堆栈,堆栈信息中包含数据库连接字符串。AI读取了其中的密码。

审查数据处理流水线。 开发者分享一个数据管道脚本,其中包含AWS访问密钥和私钥。AI同时接收了这两项凭证。

API集成代码审查。 开发者请求对集成代码进行反馈,代码中包含有效的合作伙伴API密钥。该密钥随即离开了开发者所在的内部网络。

在每个场景中,目的都是合理的技术求助;凭证泄露只是为了给AI提供足够上下文而产生的副作用。这与GitHub泄露的模式完全相同——不是恶意为之,只是习以为常。

CI/CD流水线面临同样的风险

2024年CI/CD流水线密钥泄露增加了34%。构建脚本、部署配置和基础设施即代码文件如今都需要经过AI审查。这些文件往往包含云服务凭证和服务账户令牌。

随着AI工具覆盖开发周期的更多环节——代码审查、文档生成、调试、性能优化——暴露面也随之扩大。

MCP架构如何拦截泄露

对于使用Claude Desktop或Cursor IDE的团队,模型上下文协议(MCP)服务器架构在开发者与AI模型之间置入了一层凭证过滤器。

MCP服务器处理会话中流转的所有文本——粘贴的代码、报错堆栈、配置文件、调试上下文——所有内容在到达模型之前,均经过一个匿名化步骤。

引擎识别凭证格式:API密钥格式、数据库连接字符串、OAuth令牌、私钥标头以及安全团队自定义的格式。每个匹配项在传输前均被替换为令牌。

实际效果如下:

开发者粘贴包含数据库连接字符串的报错堆栈,MCP服务器将该字符串替换为 [DB_CONNECTION_1],AI看到的是包含令牌的报错堆栈,并基于匿名化版本提供调试建议。实际凭证始终未离开内部网络。

这从根本上阻断了导致GitHub密钥泄露的同一漏洞渠道。渠道虽然不同——AI工具而非git提交——但修复逻辑相同:在传输前拦截。

关于anonym.legal如何在AI工具和文档工作流中处理这一问题,请参阅安全概述;关于审计控制,请访问合规中心

事后检测为时已晚

部分团队使用提交后扫描来发现泄露的密钥。GitGuardian和truffleHog在处理GitHub渠道方面效果良好,但无法覆盖AI工具会话。

当密钥已到达AI服务提供商的服务器,暴露已经发生。扫描只能在事后发现问题;MCP层匿名化则阻止密钥到达模型。

3900万次GitHub泄露记录了一个渠道,AI工具暴露是同一问题在另一个监控更少、审计追踪更少的渠道中的复现。传输前预防,才能同时覆盖两个渠道。

参考资料

准备好保护您的数据了吗?

开始使用 285 种实体类型在 48 种语言中匿名化 PII。

About this page

We update this page when our platform or the law changes.

Read our founder note for how we work.

Each change shows up in the timestamp at the top.

Related reading

We follow these rules

  • GDPR (EU 2016/679).
  • ISO/IEC 27001:2022.
  • NIS2 (EU 2022/2555).
  • HIPAA safe harbor under 45 CFR § 164.514(b)(2).

Our promise

We do not sell your data.

We do not train models on your text.

We store your files in Germany.

You can delete your account at any time.

You own your work.

Where we run

Our servers live in Falkenstein, Germany.

We use Hetzner. They hold ISO 27001 certification.

All data stays in the EU.

Backups run every day.

Need help?

Email support@anonym.legal.

We reply within one business day.

How we test

We run a full check suite on every release.

Each surface gets its own sweep script and report.

Human reviewers spot-check the output each week.

We track recall and precision on a labelled set.

Bad runs block the deploy.

What we never do

  • We never sell your information to third parties.
  • We never train models on what you upload.
  • We never keep your work after you delete it.
  • We never share keys with any outside firm.
  • We never run ads inside the product.

Plans in plain words

We sell credits, not seats.

One credit covers one short job.

Long jobs use a few credits each.

You can top up at any time.

Unused credits roll over each month.

Read the plans page for current rates.

Who built this

A small team of engineers and lawyers built this.

We ship from Europe and work in the open.

Our founder note spells out why we started.

Where to start

How the parts fit

A browser add-on cleans text inside Chrome.

A Word plug-in handles drafts in Office.

A small desktop tool works on whole folders.

An agent protocol link feeds large models safely.

All four share one core engine and one rule set.

Words from our team

We started this work after a lunch about cookies.

One friend kept getting odd ads on her phone.

We asked why a court file leaked through a draft.

We sketched the first build on a napkin that week.

By month three we had a tiny demo for a friend.

She used it on her first case the next day.

Common questions we hear

Can the tool read scanned PDFs? Yes, with OCR.

Does it work on long files? Yes, in small chunks.

Can I roll my own rule set? Yes, save it as a preset.

Does it run offline? The desktop build runs offline.

Do you keep my files? No, the cloud build wipes after each run.

Will it learn from my work? No, we never train on inputs.

A short tour of the workflow

Upload a file or paste a snippet of prose.

Pick the entities you want gone from the draft.

Choose a method: replace, mask, hash, encrypt, or redact.

Press run and watch the side panel show each hit.

Skim the result and tweak any rule that misfired.

Save the cleaned file or send it to a teammate.