Code Velocity
AI 安全

AI Agent 安全:GitHub 安全代码游戏磨练智能体技能

·7 分钟阅读·GitHub·原始来源
分享
一张风格化的图片,展示了黑客视角下的 AI 智能体代码,代表着 GitHub 安全代码游戏中的智能体 AI 安全培训。

title: "AI Agent 安全:GitHub 安全代码游戏磨练智能体技能" slug: "hack-the-ai-agent-build-agentic-ai-security-skills-with-the-github-secure-code-game" date: "2026-04-17" lang: "zh" source: "https://github.blog/security/hack-the-ai-agent-build-agentic-ai-security-skills-with-the-github-secure-code-game/" category: "AI 安全" keywords:

  • 智能体 AI 安全
  • AI 安全
  • GitHub 安全代码游戏
  • 网络安全培训
  • 安全编码
  • OWASP 智能体应用十大风险
  • AI 智能体
  • 漏洞评估
  • GitHub Codespaces
  • 安全教育
  • 提示工程安全
  • 开发者安全技能 meta_description: "探索 GitHub 安全代码游戏第四季,培养重要的智能体 AI 安全技能。通过这项免费的互动培训,学习识别和修复 ProdBot 等自主 AI 智能体中的漏洞。" image: "/images/articles/hack-the-ai-agent-build-agentic-ai-security-skills-with-the-github-secure-code-game.png" image_alt: "一张风格化的图片,展示了黑客视角下的 AI 智能体代码,代表着 GitHub 安全代码游戏中的智能体 AI 安全培训。" quality_score: 94 content_score: 93 seo_score: 95 companies:
  • GitHub schema_type: "NewsArticle" reading_time: 7 faq:
  • question: "玩安全代码游戏第四季需要 AI 或编码经验吗?" answer: "不需要,参加 GitHub 安全代码游戏第四季不需要预先具备 AI 或编码经验。整个体验旨在通过命令行界面 (CLI) 中的自然语言交互来轻松访问。玩家只需使用简单的英语或任何首选语言来提示 ProdBot,机器人会做出相应回应。主要要求是好奇心和乐于尝试的精神。这种方法使开发者、安全专业人员,甚至 AI 或编程新手都能专注于培养关键的安全直觉并理解攻击模式,而不是被复杂的语法或高级 AI 概念所困扰。该游戏教您通过直观的命令探索漏洞,从而像攻击者一样思考,使其成为一个引人入胜且高效的学习工具,适用于广泛的受众。"
  • question: "在开始第四季之前,是否必须完成前几季?" answer: "不,完成安全代码游戏的前几季并不是玩第四季的先决条件。每一季都被设计成独立的,允许玩家直接进入最新的挑战,而无需了解之前的内容。然而,值得注意的是,第三季专门关注大型语言模型 (LLM) 安全,涵盖了诸如制作恶意提示和防御恶意提示等主题。这种通用的 AI 安全基础对于理解智能体 AI 漏洞的更广泛背景非常有益,因为智能体系统通常会整合 LLM。虽然不是必需的,但有兴趣全面了解 AI 安全的玩家可能会发现第三季是一个有用的(尽管是可选的)准备经验,通常需要大约 1.5 小时才能完成。"
  • question: "完成第四季大约需要多长时间?" answer: "完成安全代码游戏第四季的估计时间约为两小时。然而,这个持续时间会根据个人游戏风格和探索深度而有显著差异。有些玩家可能更快地通过关卡,而另一些玩家可能会选择深入研究每个挑战,尝试多种方法来利用漏洞并理解底层机制。游戏鼓励彻底探索和“黑客思维”,其中尝试不同的命令并突破 ProdBot 能力的界限是学习过程的一部分。因此,进行更广泛实验的玩家可能会花费更多时间,最终获得对智能体 AI 安全更丰富的理解。"
  • question: "参加 GitHub 安全代码游戏第四季是否免费?" answer: "是的,安全代码游戏第四季完全免费。它是 GitHub 的一项开源倡议,旨在提供易于访问且引人入胜的网络安全培训。该游戏完全在 GitHub Codespaces 中运行,这是一个基于云的开发环境,每月提供长达 60 小时的免费使用时间。这意味着玩家无需在本地安装任何软件,配置复杂的开发环境,或承担与平台本身相关的任何费用,只要他们停留在免费的 Codespaces 层级内。这种设置使得任何拥有 GitHub 账户的人都可以轻松、经济高效地加入并立即开始磨练他们的智能体 AI 安全技能,没有任何财务障碍。"
  • question: "玩第四季时是否有速率限制,它们如何影响游戏体验?" answer: "是的,安全代码游戏第四季利用 GitHub Models 提供 AI 功能,这些功能受特定速率限制的约束。这些限制旨在确保底层 AI 基础设施的负责任使用并防止滥用。如果玩家在游戏过程中遇到速率限制,ProdBot 会告知他们已暂时超出允许的请求数量。在这种情况下,建议的操作是简单地等待速率限制重置,之后游戏可以从中断的地方无缝恢复。GitHub 提供了关于负责任使用 GitHub Models 的文档,包括速率限制的详细信息,以帮助玩家理解这些操作参数并相应地规划他们的游戏。这确保了为所有参与者提供一个公平和可持续的环境。"

## 智能体 AI 安全:通过 GitHub 安全代码游戏提升你的防御能力

人工智能的飞速发展持续重塑着我们的数字世界。最近,像 OpenClaw 这样开源的个人 AI 助手等工具激发了人们的想象力,它们有望清理收件箱、管理日历、浏览网页,甚至编写自己的插件。虽然这种自主 AI 智能体的潜力无疑是变革性的,但它也引出了一个关键问题:当这种力量落入恶意之手时会发生什么?如果一个智能体被诱骗访问未经授权的文件,处理被污染的网页内容,或者在一个多智能体工作流中盲目信任损坏的数据,那会怎样?

这些紧迫的安全问题正是 GitHub 旨在通过其备受赞誉的安全代码游戏第四季来解决的。本最新迭代以其使安全培训引人入胜且易于获取的使命为基础,挑战开发者和安全爱好者“攻击 AI 智能体”,从而培养至关重要的智能体 AI 安全技能。

## 安全代码游戏:一个不断发展的网络安全技能平台

自 2023 年 3 月推出以来,[安全代码游戏](https://securitylab.github.com/secure-code-game/)提供了一种独特的、在编辑器内进行的学习体验,玩家可以在其中利用并修复故意存在漏洞的代码。其核心理念——让安全培训变得有趣——始终如一,并随着威胁环境的发展而不断演进。

第一季向开发者介绍了基础的安全编码实践,提供了一种识别和修补漏洞的实践方法。第二季将这些挑战扩展到多堆栈环境,促进了 JavaScript、Python、Go 和 GitHub Actions 等流行语言的社区贡献。认识到 AI 日益增长的重要性,第三季转向了大型语言模型(LLM)安全,教玩家如何制作和防御恶意提示。超过 **10,000 名开发者**利用这个平台来磨练他们的安全敏锐度,随着技术进步适应新的挑战。

现在,随着 AI 编码助手成为主流,以及自主 AI 智能体从研究原型走向生产,第四季解决了下一个前沿领域:智能体 AI 系统的安全。这些系统能够自主浏览网页、进行 API 调用和进行多智能体协调,带来了一类新的攻击向量,需要专门的理解和防御策略。对于那些希望深入了解 AI 安全基础知识的人,探索诸如[运营智能体 AI:第一部分 - 利益相关者指南](/zh/operationalizing-agentic-ai-part-1-a-stakeholders-guide)之类的资源可以提供有价值的背景信息。

## 为什么智能体 AI 安全是当务之急

专门的智能体 AI 安全培训的时机并非巧合。自主 AI 智能体的采用正在加速,但安全准备却严重滞后。最近的行业报告突显了这一日益扩大的差距:

*   与 100 多名安全研究人员共同开发的 [OWASP 2026 年智能体应用十大风险](https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/),现在将智能体目标劫持、工具滥用、身份滥用和内存投毒列为首要关注的问题。
*   Dark Reading 的一项调查显示,**48% 的网络安全专业人士**预计智能体 AI 将在 2026 年底前成为主要的攻击向量。
*   思科 2026 年 AI 安全状况报告令人担忧地发现,虽然 83% 的组织计划部署智能体 AI 功能,但只有 29% 的组织感到已做好安全部署的准备。

这种巨大的差异为漏洞滋生创造了沃土。弥合这一差距并强化系统最有效的方法是学习像攻击者一样思考——这一原则是整个安全代码游戏体验的基础。了解如何利用这些系统是构建强大防御的第一步。有关保护 AI 系统的更多见解,请参阅围绕[设计智能体以抵抗提示注入](/zh/designing-agents-to-resist-prompt-injection)的讨论。

## 介绍 ProdBot:你刻意易受攻击的 AI 助手

安全代码游戏第四季将玩家置于攻击者的角色,目标是 **ProdBot**,一个故意存在漏洞的、专注于生产力的终端 AI 助手。受 OpenClaw 和 [GitHub Copilot CLI](https://github.com/features/copilot/cli) 等真实世界工具的启发,ProdBot 将自然语言转换为 bash 命令,导航模拟网络,与 MCP(模型上下文协议)服务器交互,执行批准的技能,维护持久内存,并协调复杂的多智能体工作流。

玩家在五个渐进式关卡中的任务看似简单:使用自然语言提示来强制 ProdBot 泄露它永远不应暴露的秘密——特别是 `password.txt` 的内容。成功检索此文件意味着发现并利用了一个安全漏洞。无需预先具备 AI 或编码经验;只需要好奇心和尝试的意愿,因为所有交互都通过 CLI 中的自然语言进行。

## 渐进式漏洞:掌握智能体攻击面

安全代码游戏第四季旨在反映 AI 驱动工具在现实世界中的演变。五个关卡中的每个关卡都为 ProdBot 引入了新功能,同时暴露出新的攻击面供玩家发现和利用。这种渐进式复杂性有助于玩家理解随着 AI 智能体获得更多自主权和访问权限,漏洞是如何积累和变化的。

以下是 ProdBot 的演变和相应的安全挑战:

| 关卡 | ProdBot 的新功能 | 攻击面和挑战 |
| :---- | :----------------------- | :--------------------------- |
| **1** | 在沙盒工作区中执行 Bash 命令。 | 突破沙盒环境。 |
| **2** | 访问模拟互联网。 | 利用由不受信任的网页内容引入的漏洞。 |
| **3** | 连接到外部 MCP 服务器(股票行情、网页浏览、云备份)。 | 识别工具集成和外部服务交互中的弱点。 |
| **4** | 组织批准的技能和持久内存。 | 绕过信任层,利用预建插件,或操纵内存。 |
| **5** | 编排六个专业智能体、三个 MCP 服务器、三个技能和一个模拟的开源项目网络。 | 在复杂的多智能体环境中测试智能体沙盒和数据预验证的声明。 |

这种进展旨在建立对智能体 AI 安全风险的直观理解。第四季中发现的攻击模式并非理论上的;它们代表了安全团队在生产环境中部署自主 AI 系统时目前面临的真实世界威胁。一个主要的例子是 CVE-2026-25253(CVSS 8.8 – 高危),被称为“ClawBleed”,这是一个一键远程代码执行(RCE)漏洞,攻击者可以通过恶意链接窃取认证令牌,从而完全控制 OpenClaw 实例。

最终目标超越了仅仅发现一个特定的漏洞。它旨在培养一种固有的安全直觉——无论是在审查智能体的架构、审计工具集成,还是确定团队中 AI 助手的适当自主级别时,都能识别这些危险模式的能力。它是关于理解如何构建更安全的智能体工作流,这一主题在围绕 [Copilot 应用科学中的智能体驱动开发](/zh/agent-driven-development-in-copilot-applied-science)的讨论中得到了进一步阐述。

## 立即开始,磨练你的 AI 安全直觉

安全代码游戏最吸引人的方面之一是其可访问性。整个体验都在 [GitHub Codespaces](https://github.com/features/codespaces) 中运行,无需任何本地安装或复杂配置。凭借 Codespaces 每月提供的长达 60 小时的免费使用时间,玩家可以在两分钟内免费进入 ProdBot 的终端。每个季度都是独立的,允许玩家直接进入第四季,而无需完成之前的季度,尽管第三季为一般的 AI 安全提供了有益的基础。

你所需要的只是一种黑客思维和乐于尝试的精神。AI 的未来日益智能化,理解其安全影响已不再是可选项。

**准备好攻击 AI 智能体并培养你的智能体 AI 安全技能了吗?[立即开始第四季 >](https://securitylab.github.com/secure-code-game/)**

*特别感谢 GitHub 的高级产品安全工程师 Rahul Zhade 和第三季的创建者 Bartosz Gałek,感谢他们对第四季测试和改进做出的宝贵贡献。*

常见问题

Do I need AI or coding experience to play Season 4 of the Secure Code Game?
No, prior AI or coding experience is not necessary to participate in Season 4 of the GitHub Secure Code Game. The entire experience is designed to be accessible through natural language interactions within a command-line interface (CLI). Players simply use plain English, or any preferred language, to prompt ProdBot, and the bot responds accordingly. The primary requirement is curiosity and a willingness to experiment. This approach allows developers, security professionals, and even those new to AI or programming to focus on developing crucial security instincts and understanding attack patterns, rather than getting bogged down in complex syntax or advanced AI concepts. The game teaches you to think like an attacker by exploring vulnerabilities through intuitive commands, making it an an engaging and effective learning tool for a broad audience.
Is it mandatory to complete previous seasons before diving into Season 4?
No, completing the previous seasons of the Secure Code Game is not a prerequisite for playing Season 4. Each season is designed to be self-contained, allowing players to jump directly into the latest challenges without prior knowledge of earlier content. However, it's worth noting that Season 3 specifically focused on Large Language Model (LLM) security, covering topics like crafting malicious prompts and defending against them. This foundation in general AI security can be quite beneficial for understanding the broader context of agentic AI vulnerabilities, as agentic systems often incorporate LLMs. While not required, players interested in building a comprehensive understanding of AI security might find Season 3 to be a helpful, though optional, preparatory experience, typically taking around 1.5 hours to complete.
What is the approximate duration required to complete Season 4?
The estimated time to complete Season 4 of the Secure Code Game is approximately two hours. However, this duration can vary significantly based on individual playstyle and depth of exploration. Some players might progress through the levels more quickly, while others may choose to delve deeper into each challenge, experimenting with multiple approaches to exploit vulnerabilities and understand the underlying mechanisms. The game encourages thorough exploration and a 'hacker mindset,' where trying different commands and pushing the boundaries of ProdBot's capabilities is part of the learning process. Therefore, players who engage in more extensive experimentation might spend more time, ultimately gaining a richer understanding of agentic AI security.
Is participation in the GitHub Secure Code Game Season 4 free of charge?
Yes, Season 4 of the Secure Code Game is completely free to play. It is an open-source initiative by GitHub, designed to provide accessible and engaging cybersecurity training. The game runs entirely within GitHub Codespaces, a cloud-based development environment that offers up to 60 hours of free usage per month. This means there's no need for players to install any software locally, configure complex development environments, or incur any costs related to the platform itself, as long as they stay within the free Codespaces tier. This setup makes it incredibly easy and cost-effective for anyone with a GitHub account to jump in and start honing their agentic AI security skills immediately, without financial barriers.
Are there any rate limits when playing Season 4, and how do they impact gameplay?
Yes, Season 4 of the Secure Code Game utilizes GitHub Models for its AI capabilities, which are subject to specific rate limits. These limits are in place to ensure responsible use of the underlying AI infrastructure and to prevent abuse. If a player encounters a rate limit during gameplay, ProdBot will inform them that they have temporarily exceeded the allowed number of requests. In such cases, the recommended action is to simply wait for the rate limit to reset, after which gameplay can be seamlessly resumed from where it left off. GitHub provides documentation on the responsible use of GitHub Models, including details on rate limits, to help players understand these operational parameters and plan their gameplay accordingly. This ensures a fair and sustainable environment for all participants.

保持更新

将最新AI新闻发送到您的收件箱。

分享