Skip to content

fix(claude): scope allowlisted commands and drop the auto-format hook - #11

Merged
Jerry-CodeHub merged 1 commit into
masterfrom
fix/claude-config
Sep 23, 2026
Merged

Jerry-CodeHub merged 1 commit into
masterfrom
fix/claude-config

Conversation

@Jerry-CodeHub

Copy link
Copy Markdown
Owner

背景

审计 2026-09-22 H-2(09-20 已提出、一直未修):入库的 .claude/settings.json 对所有在此仓库使用 Claude Code 的人生效,三项叠加构成零交互供应链执行面:

  1. Bash(pnpm *) 全量放行——pnpm 是任意脚本执行器(run <任意 script> / exec / dlx)
  2. PostToolUse 钩子在每次 Write/Edit 后无条件执行 pnpm format——即 package.json 的 script,可被恶意 PR 毫不起眼地篡改,维护者打开仓库即触发任意代码执行
  3. env.CESIUM_ION_TOKEN 直通注入 + Bash 放行使 deny Read(.env*) 可经 pnpm exec node -e 零提示绕过

改动

  • allow 收敛为枚举白名单(install/check/test/lint/typecheck/format/build/preview/size 等低危命令);pnpm run/exec/dlx 与一切未列出命令回归正常的逐次审批
  • 删除 PostToolUse 自动 format 钩子:pre-commit 的 lint-staged 已有等价兜底,全仓 format 是个人工作流,不应入库强加给贡献者
  • deny 扩为 Read(**/.env*)(覆盖子目录)并显式加 Bash(cat .env*)
  • 保留 env.CESIUM_ION_TOKEN(本地构建需要),allowlist 收敛后它不再有免提示外发通道

验证

  • JSON 语法校验通过;配置在新会话生效

@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 2a8f5cad-fdbd-427f-9183-f689f05b21ba

📥 Commits

Reviewing files that changed from the base of the PR and between 8e537c4 and 7f687cf.

📒 Files selected for processing (1)
  • .claude/settings.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying umi-react-admin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7f687cf
Status: ✅  Deploy successful!
Preview URL: https://bf03c721.umi-react-admin.pages.dev
Branch Preview URL: https://fix-claude-config.umi-react-admin.pages.dev

View logs

@Jerry-CodeHub
Jerry-CodeHub merged commit 4c99111 into master Sep 23, 2026
5 checks passed
@Jerry-CodeHub
Jerry-CodeHub deleted the fix/claude-config branch September 23, 2026 00:09
- replace the Bash(pnpm *) wildcard (any script/exec/dlx execution) and
  npm run * with an enumerated list of low-risk commands; pnpm run/exec/
  dlx and everything else now go through the normal approval prompt
- remove the PostToolUse hook that ran 'pnpm format' after every
  Write/Edit: it executed a package.json script with zero interaction,
  so a tampered script in a merged PR meant arbitrary code execution on
  every contributor's machine (lint-staged already covers formatting)
- widen the env-file deny to **/.env* so nested env files are covered,
  and deny 'cat .env*' explicitly
- keep the CESIUM_ION_TOKEN env passthrough: local builds need it and
  the allowlist above no longer offers a prompt-free exfil path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant