Agentic coding operations · 更新 2026-06-27

Coding Agent Incident Response Playbook:Stop、Revoke、Revert、Rotate、Notify、Investigate 与 Update Policy

面向使用 Claude Code、OpenAI Codex CLI、hooks、MCP servers 和 repository automation 的团队:当 coding agent 做出坏变更或暴露风险时如何响应。

Agentic coding governance 会降低风险,但不会消灭 incident。Coding agent 可能运行错误命令、修改敏感文件、创建坏 PR、把 prompt 暴露到 logs、触碰 secrets、使用不安全 MCP tools,或生成 reviewer 没真正理解的 patch。

这份 playbook 是 Agentic Coding Bakeoff 与 Governance Checklist 之后的运营层:stop the run、preserve evidence、revoke/rotate credentials、revert/contain changes、notify owners、investigate root cause,并在下一次 rollout 前 update policy。

RepoDaily 判断

把 coding-agent incidents 当作工程 incident 处理,只是 playbook 更小、更明确。先 stop agent,保存 logs 和 diffs,保护 secrets,revert unsafe changes,通知 owner,记录 root cause,并在重新启用 workflow 前更新 command policy、denied paths、hooks、MCP scopes 和 PR review rules。

快速矩阵

Incident 类型立即动作ContainmentPolicy update
Wrong command run停止 agent,保存 transcript/command log检查 filesystem、build outputs 和 touched services增加 denied command 或 approval trigger
Sensitive file modified冻结 branch 并阻止 mergeRevert diff,review git history,检查 generated artifacts增加 denied path、CODEOWNER 或 senior approval
Secret exposure停止 run,保存 evidence 但不要重复传播 secretRevoke/rotate token,并扫描 logs、commits、caches迁移 secret source,收紧 workspace prep,更新 redaction rules
Unsafe MCP/tool use禁用 tool/server 并捕获 scopes usedReview external calls、tokens、browser/file access、data touched缩小 scopes,pin server,增加 owner approval
Bad PR mergedRevert 或 hotfix,停止后续 agent merges运行 tests,monitor errors,通知 affected owners强化 PR checklist 和 merge ownership
Prompt injection followed保存 malicious instruction source 和 transcript检查 steering agent 的 files/comments/issues增加 instruction hierarchy、read-only rules 和 source-trust notes
Benchmark misuse停止部署 benchmark outputReview copyright、assets、user data 和 provenance增加 benchmark scope 和 publishing policy
Reviewer misunderstanding暂停 agent-generated mergesReview diff、tests、assumptions 和 review comments要求 generated-code labels 和 reviewer attestation

Incident Response 准备度评分卡

在 coding agents 超出 pilot 前,先给团队打分。

控制项0 分1 分2 分Owner 问题
Stop mechanism没有明确停止动作只有一个人知道手动 stopOwner 能 stop run 并 disable tools现在谁能停止 agent run?
Evidence captureLogs 丢失或分散保留部分 transcriptPrompt、commands、diff、tests、approvals 已保存哪些 evidence 是必需的?
Secret response没有 rotation path手动 rotation 已知Revoke/rotate/scan 步骤已记录Agent 可能看到哪些 tokens?
Rollback path没有 rollback owner可以 revertRevert/hotfix/yank path 和 owners 已定义坏 merge 怎么撤?
Tool inventoryhooks/MCP/tools 未知部分 inventoryOwners、scopes、tokens、versions 被跟踪哪些 external tools 当时启用?
Policy feedback loopIncident 不反映到 policyAd hoc notesPolicy、denied paths、prompts、reviews 已更新重新启用前改变了什么?

30 分钟 Coding-agent Incident Tabletop

在给 coding agents 新 repository class 写权限前使用。

0–5 分钟:choose scenario

选择一个真实 failure:wrong command、secret exposure、bad PR、unsafe MCP tool 或 prompt injection。

成功标准团队测试具体 incident,而不是泛泛恐惧。

5–10 分钟:stop and evidence path

指定谁 stop run,以及 transcript、commands、diffs、tests、approvals 存在哪里。

成功标准Evidence capture 明确且 redacted。

10–18 分钟:containment

走一遍 revert、revoke/rotate、disable tool、notify owner 和 monitor steps。

成功标准每个 containment action 都有 owner。

18–24 分钟:root-cause review

分类 control failure:command policy、denied path、tool scope、stale docs、reviewer miss 或 prompt injection。

成功标准原因映射到 control,而不是只归咎个人。

24–30 分钟:re-enable decision

写 policy patch,并决定 agent workflow 是 disabled、restricted 还是 re-enabled。

成功标准Workflow 在恢复前已经改变。

Incident Response 流程

  1. 先停止 active run:pause agent、cancel tasks,必要时禁用 hooks/MCP servers,并阻断本次 run 触碰的 merge/deploy path。
  2. 保存 evidence,但不要扩散 secrets:prompt、transcript、command log、changed files、tests、approvals、tool scopes 和 reviewer decisions。
  3. 分类 incident:wrong command、sensitive path、secret exposure、unsafe tool use、bad PR、prompt injection、benchmark misuse 或 reviewer failure。
  4. Contain blast radius:revert branch、revoke/rotate credentials、scan logs/caches、disable tools、notify repository/security owners,并监控 affected services。
  5. 调查 root cause:policy gap、tool scope、stale docs、prompt injection、reviewer miss、missing denied path 或 unsupported repository class。
  6. 重新启用前更新 controls:command allow/deny list、path policy、MCP scopes、hook approval、PR checklist、agent instructions 和下一次 bakeoff/governance review date。

场景表

场景前 15 分钟重新启用前
Agent 意外删除或重写文件Stop run,检查 git status,保存 transcript,从 git 或 backup restore增加 denied commands/paths,并要求 destructive operations approval
Agent 触碰 `.env` 或 credentials停止传播 transcript,revoke/rotate suspected secrets,扫描 logs 和 commits把 secrets 移出 workspace,增加 secret-prep checklist
Agent 通过 browser/MCP tool 使用 private data禁用 tool,捕获 scopes 和 external calls,通知 data owner缩小 scopes,增加 allowlist,要求 owner approval
Agent PR merge 后破坏 productionRevert/hotfix,停止 agent merges,通知 service owner,monitor errors增加 generated-code label、更严格 CI 和 reviewer attestation
Agent 遵循恶意 README/issue 指令保存 source instruction,检查被读取 files,阻止 merge增加 instruction hierarchy 和 source-trust guidance
Website cloning benchmark 使用不安全 assets停止部署,review asset provenance 和 copyright scope增加 benchmark publishing 和 asset policy
Reviewer 批准了自己没理解的代码暂停该 owner 的 agent merge permission,review diff 和 tests要求 reviewer explanation 和 generated-code checklist

Incident 风险清单

Evidence loss

如果 transcripts、commands、diffs 和 tool scopes 丢失,团队只能猜发生了什么。

Secret over-sharing

不要把 exposed tokens 粘进聊天或 incident docs。记录 redacted evidence 并 rotate credentials。

Silent re-enable

不改 policy 就重新启用同一 workflow,会把一次 incident 变成重复模式。

Reviewer laundering

人类点了 merge 不代表 agent 没问题。Reviewer 和 workflow 都需要分析。

Tool-scope sprawl

Hooks、MCP servers、browsers、files 和 cloud APIs 会扩大 blast radius,除非 scopes 被盘点和缩小。

Benchmark-to-production leap

Benchmark output 未经 provenance、asset、copyright 和 owner review,不应部署。

Response 实施模式

Stop card

写一张一页卡片,包含 owner contacts 和 pause agents、disable tools、block merges、stop deploys 的具体动作。

Evidence bundle

在 incident record 里保存 redacted prompt、transcript、commands、changed files、tests、approvals、tool scopes 和 final decision。

Secret response lane

把 secret rotation 和 code rollback 分开处理,避免 token handling 被普通 PR review 拖慢。

Policy patch PR

每次 incident 都应产生一个 policy PR:denied path、command approval、MCP scope、hook review 或 PR checklist change。

Re-enable gate

恢复写权限前,要求 owner sign-off、updated policy 和一次 safe validation run。

Incident taxonomy

按 command、path、secret、tool、prompt injection、PR review、benchmark misuse 或 release/deploy impact 打标签。

常见问题

给安全运营 coding agents 的团队提供简短答案。

Coding-agent incident 的第一步是什么?

停止 active run 并保存 evidence。在 blast radius 未知时,不要继续和 agent 互动。

什么时候要 rotate tokens?

只要 agent 可能读取、记录、commit 或传输了 credential,就应 rotate。敏感 scopes 下,不确定也按暴露处理。

只 revert 坏 PR 可以吗?

Revert 是 containment,不是 root-cause fix。重新启用前还要更新 policy、prompts、denied paths、tool scopes 或 reviewer rules。

Agent-generated incident 谁负责?

Task 或 merge 的 human owner 负责 incident,根据影响由 repo、security 或 platform owners 支持。

相关雷达

Infrastructure & Runtime 雷达

相关 RepoDaily 解读

来源

  1. Claude Code official docs
  2. Claude Code settings docs
  3. Claude Code hooks docs
  4. Claude Code MCP docs
  5. OpenAI Codex CLI docs
  6. OpenAI Codex security docs
  7. Claude Code Best Practice
  8. SkillSpector

Feedback

这页是否帮助你做出决定?

匿名反馈只用于判断内容是否真正有用。

报告过期或缺失的证据