GitHub security in the Claude Code era: 10 verified kits by team and organization type
With the spread of Claude Code, repositories have changed from something only humans read to something AI also reads, and the threats targeting them changed too, writes azarashi, a frontend engineer at sonicmoov. Threats are grouped into three directions: "inside" — instructions hidden in files such as CLAUDE.md so that humans do not see them but AI reads them, for example HTML comments that Markdown preview hides or zero-width characters[1] that are invisible in a diff; "outside" — reconnaissance by an attacking AI that reads the build artifacts of public sites and the commits and issues of public repositories; and "tools" — Claude Code plugins and the dependency packages Claude installs, which should be managed with a lockfile like npm packages. Countermeasures are grouped by who needs them (everyone, team, external input, organization), assume a private repository, and ship as ready-made kits that can be pasted in or installed by Claude Code itself; the author verified them in October 2026 on Claude Code 2.1.293 and gitleaks 8.30.1 in a personal test repository, notes that a public site exposes build artifacts as a reconnaissance surface even when the repository is private, and leaves account takeover and dependency or application vulnerabilities out of scope.
Against hidden instructions, kit K1 keeps Claude Code from reading secret files such as .env through two layered mechanisms: deny rules that block direct reads, and a hook that inspects the Bash command string before execution and catches workarounds like python3 -c "open('.env').read()". Verification showed that deny rules alone do not stop a script that opens .env itself — in Auto mode the command even ran without any confirmation — so the author recommends combining the hook with sandboxing, careful reading of permission prompts and, above all, not keeping real secrets in the working directory. Kits K2 and K10 protect AI configuration files (CLAUDE.md, .claude/, .mcp.json, .github/workflows/) as quasi-code, using CODEOWNERS[2] and Rulesets[3] with four settings: require a pull request before merging, at least one required approval, review from Code Owners, and dismissal of stale approvals when new commits are pushed. Testing confirmed that with Required approvals left at 0 a code owner's own pull request could be merged without anyone's review, while setting it to 1 blocked this, and that without the stale-approval rule a hidden instruction could be pushed in after approval.
Kits K3 and K4 detect invisible text in CI, flagging zero-width, bidirectional-control and similar invisible or confusable characters as errors and HTML comments as warnings, with line-by-line annotations on the PR diff, and also check for backslashes that editor saves can add and that silently break patterns in CODEOWNERS, .claude/settings.json and .gitignore; if the check is made a required status check, such pull requests cannot be merged. For external input, the author stresses that what matters is not whether CI is used but whether Claude reads content written by outsiders, listing paths such as claude-code-action started from Issue and PR comments, where anyone who can comment becomes an input path, local review of external PRs, where that branch's CLAUDE.md and .claude/settings.json including hooks load directly, GitHub and Slack connectors, and cloud or scheduled sessions that process external input while nobody watches. Two claude-code-action vulnerabilities were published in 2026 — a permission check flaw combined with prompt injection[4], fixed in v1.0.94, and arbitrary code execution through a malicious .mcp.json included in a pull request — and the recommended repository-side mitigations include restricting runs by the commenter's author_association, keeping the permissions: block to the minimum, pinning the Action by commit SHA, allowlisting Actions in repository or organization settings, and limiting tools with --tools.
Sources
-
JPZenn JA
検証済み10キットで始める、Claude Code時代のGitHubセキュリティ対策【チーム・組織別】





