bianhaifeng789-hue/openclaw-config/bare-git-repo-security-scrub

Claude Code and agent skill by bianhaifeng789-hue/openclaw-config

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Install

npx vskill@latest install bianhaifeng789-hue/openclaw-config/bare-git-repo-security-scrub

SKILL.md

The same SKILL.md was published earlier as bianhaifeng789-hue/openclaw-config/bare-git-repo-security-scrub.

Bare Git Repo Security Scrub Pattern

Source

Claude Code: utils/sandbox/sandbox-adapter.ts (bareGitRepoScrubPaths, scrubBareGitRepoFiles)

Pattern

Scrub planted bare-repo files after sandboxed command - prevent git config escape.

Code Example

typescript
// SECURITY: Git's is_git_directory() treats cwd as a bare repo if it has:
// HEAD + objects/ + refs/. An attacker planting these (plus config with
// core.fsmonitor) escapes the sandbox when Claude's unsandboxed git runs.
// Paths that didn't exist at config time - scrub after command
const bareGitRepoScrubPaths: string[] = []
// Build scrub list during convertToSandboxRuntimeConfig
const bareGitRepoFiles = ['HEAD', 'objects', 'refs', 'hooks', 'config']
for (const dir of cwd === originalCwd ? [originalCwd] : [originalCwd, cwd]) {
for (const gitFile of bareGitRepoFiles) {
const p = resolve(dir, gitFile)
try {
statSync(p)
denyWrite.push(p) // Exists - mount /dev/null (ro-bind, no stub)
} catch {
bareGitRepoScrubPaths.push(p) // Doesn't exist - scrub after command
}
}
}
/**
* Delete bare-repo files planted during sandboxed command.
* Called in cleanupAfterCommand() before unsandboxed git runs.
*/
function scrubBareGitRepoFiles(): void {
for (const p of bareGitRepoScrubPaths) {
try {
rmSync(p, { recursive: true })
logForDebugging(`[Sandbox] scrubbed planted bare-repo file: ${p}`)
} catch {
// ENOENT is expected - nothing was planted
}
}
}
// Export in SandboxManager
export const SandboxManager: ISandboxManager = {
cleanupAfterCommand: (): void => {
BaseSandboxManager.cleanupAfterCommand()
scrubBareGitRepoFiles() // Scrub planted files
},
}

Key Concepts

  1. Bare Repo Attack: HEAD + objects/ + refs/ at cwd → git treats as bare repo
  2. fsmonitor Escape: Attacker plants config with core.fsmonitor → sandbox escape
  3. Two-Phase Defense: denyWrite existing files, scrub non-existent after command
  4. Cleanup After Command: Called before unsandboxed git runs
  5. ENOENT Expected: Common case - nothing was planted

Benefits

  • Prevents git config sandbox escape attack
  • Handles both existing and planted files
  • Minimal overhead (ENOENT on most calls)

When to Use

  • Sandboxed environments with git operations
  • Security-critical file protection
  • Cleanup after potentially malicious commands

Related Patterns

  • Git Worktree Main Repo Detection (sandbox-adapter.ts)
  • Sandbox Settings Adapter (sandbox-adapter.ts)
  • Cleanup Registry Pattern (cleanupRegistry.ts)

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/bianhaifeng789-hue/openclaw-config/bare-git-repo-security-scrub/badge)](https://verified-skill.com/skills/bianhaifeng789-hue/openclaw-config/bare-git-repo-security-scrub)

Something wrong with this skill or its page? Tell us.