Back to skill

Security audit

git-repo

Security checks for vulnerabilities and agentic risk

Overview

This Git helper is broadly aligned with its purpose, but it needs review because it can automatically delete existing worktrees and uses risky credential and configuration workflows.

Install only if you are comfortable giving this skill broad control over Git repositories and related local configuration. Before using the staging or pruning helpers, back up or commit important worktrees and prefer dry-run/manual cleanup. Avoid clone commands that put tokens directly in URLs; use a credential helper or gh-authenticated flow instead. Review any global ~/.gitconfig or SourceGit preference.json changes before applying them.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/local-to-staging-pr.sh:120
Finding

Forced deletion of unrelated dirty worktrees without confirmation

Content
View full analysis

Vulnerability Details

File Location: scripts/local-to-staging-pr.sh, lines 120–134
Vulnerability Type: Unchecked destructive cleanup of unrelated Git worktrees
Risk Level: Medium

Technical Analysis

Before creating a staging worktree, the script enumerates all registered worktrees beneath the repository's .claude/worktrees/ directory. If a worktree's branch is an ancestor of origin/main, it forcibly removes that worktree and forcibly deletes its branch:

bash
while IFS= read -r wt_path; do
  [[ -z "$wt_path" || "$wt_path" != "$REPO"/.claude/worktrees/* ]] && continue
  wt_branch=$(git -C "$wt_path" branch --show-current 2>/dev/null || true)
  [[ -z "$wt_branch" ]] && continue
  if git merge-base --is-ancestor "$wt_branch" origin/main 2>/dev/null; then
    echo "Reclaiming already-merged worktree: $wt_path ($wt_branch)" >&2
    git worktree remove "$wt_path" --force 2>/dev/null || true
    git branch -D "$wt_branch" 2>/dev/null || true
  fi
done < <(git worktree list --porcelain | awk '/^worktree /{print $2}')

The ancestry test establishes only that the branch's committed history is reachable from origin/main. It does not establish that the worktree is clean or inactive. The code does not run git status --porcelain, inspect Git operation indicators such as MERGE_HEAD, CHERRY_PICK_HEAD, or rebase state, or request confirmation before using git worktree remove --force.

Consequently, the authorization to prepare one staging PR is expanded into destructive cleanup of separate workspaces. Those workspaces may contain uncommitted tracked changes, untracked files, or an in-progress Git operation belonging to another session or user workflow.

The documentation at worktree.md:217 describes the automatic reclamation as safe, but the executable path does not enforce the cleanliness and operation-state gates documented elsewhere in the Skill.

Attack Path

  1. Another session, edit ...[truncated 1360 chars]
Remediation
View remediation

Remediation Suggestions

Remove opportunistic deletion of unrelated worktrees from the staging-PR helper, or place it behind a dedicated explicit cleanup flag and per-worktree confirmation.

Before any worktree removal, enforce all of the following:

  1. Resolve the worktree's absolute Git directory and reject removal if operation indicators such as CHERRY_PICK_HEAD, MERGE_HEAD, REBASE_HEAD, BISECT_LOG, rebase-merge, or rebase-apply exist.
  2. Run git -C "$wt_path" status --porcelain and skip the worktree unless the output is empty.
  3. Verify that the candidate is not the primary worktree and that its path is within the intended canonical worktree directory.
  4. Present the exact worktree path and branch to the user and require explicit confirmation before deletion.
  5. Use non-forced git worktree remove "$wt_path" so Git's own safety checks remain effective.
  6. Delete the branch only after successful worktree removal, and prefer git branch -d over git branch -D.
  7. Log skipped dirty or mid-operation worktrees rather than suppressing errors with 2>/dev/null || true.

A safer design is to leave cleanup entirely to the existing dry-run-first worktree-pruning workflow and keep this helper focused solely on creating the requested staging worktree.

Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • System Prompt LeakageDirect Leakage, Indirect Extraction, Tool-Based Exfiltration
  • Tool MisuseTool Parameter Abuse, Chaining Abuse, Unsafe Defaults
Findings (64)

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · CHANGELOG.md (reported line 164)May include surrounding context.

md
### Features

* **consolidate:** address PR 134 reviews and reflect orange/yellow severity display rules ([e6118d0](https://github.com/es6kr/skills/commit/e6118d0fb0217a4c4ad388b82e574203a8f9258e))
* **next-feat:** accumulate features for hook-kit context gate ([df4f73a](https://github.com/es6kr/skills/commit/df4f73ae4d27d4919105da70c6c94a14a32e8056))
* skills topic bundle — brief/email, code-workflow/plan-research-search, git-repo topics, skill-kit/invoke-discipline ([7fd877d](https://github.com/es6kr/skills/commit/7fd877da1b703fcdcdcaf1a3ce912f885abfa3f0))

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents a general-purpose Git/SourceGit integration skill focused on clone/account issues, hooks troubleshooting, worktree inventory/reuse, repo doctoring, safe relocation, and related maintenance tasks. The provided code instead implements a narrow automation script for promoting a local commit into a staging branch workflow using cherry-pick, temporary worktrees, and optional push/PR creation. While there is some loose overlap with 'worktree' topics, the primary behavior here is not represented in the declared purpose, and important capabilities like push and PR creation are entirely undeclared. This is a material description-behavior mismatch.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

This code does relate to Git worktrees, so it is not wholly unrelated. However, the declared description presents a broad toolkit with many named subcommands and use cases, none of which explicitly describe pruning merged worktrees. The closest declared items are general worktree inventory/reuse/create, move/rename/register, and patrol/batch inspect, but the actual code goes further by determining merge status and physically removing worktrees and optionally branches. That destructive cleanup behavior is a material capability and appears undeclared. Also, SourceGit integration and most of the listed functions are absent from this chunk, making the actual behavior substantially narrower and different in primary purpose than the declaration.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 42)May include surrounding context.

md
| rename-worktree | rename worktree directory and metadata (cross-platform, Windows safe) | [rename-worktree.md](./rename-worktree.md) |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 48)May include surrounding context.

md
| worktree | unified worktree acquisition: inventory, reuse inactive, or create new at `.claude/worktrees/` | [worktree.md](./worktree.md) |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 135)May include surrounding context.

md
| worktree | unified worktree acquisition: inventory, reuse inactive, or create new at `.claude/worktrees/` | [worktree.md](./worktree.md) |

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 104)May include surrounding context.

md
**Batch cleanup**: `scripts/prune_merged_worktrees.py` automates this same `gh pr list --head` check (with a git-native `merge-base --is-ancestor` fallback when

Missing User Warnings

High
Category
Not specified by scanner
Confidence
95% confidence
Finding

The workflow instructs automatic modification of repository state and application configuration, including appending to .gitignore and editing SourceGit preference.json, while explicitly stating it proceeds without user confirmation. In an agentic context, silent file and config changes can alter version-control behavior, hide files from tracking, or persist unexpected state across future sessions without the user's informed consent.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The skill embeds an access token directly into a clone URL, which risks credential leakage through shell history, process listings, logs, error messages, and Git config artifacts. Even though it later resets the origin URL, the secret may already have been exposed during command execution or captured by surrounding tooling.

Content

No source excerpt is available for this finding.

Anti-Refusal Statement

High
Category
Anti-Refusal
Confidence
80% confidence
Finding

Skill instructs the agent to omit warnings, disclaimers, or ethical commentary. Stripping safety caveats hides risk from the user and is a common jailbreak preamble.

Content

Scanner excerpt · githooks.md (reported line 14)May include surrounding context.

md
|---|-------|-------|---------|
| 1 | `core.hooksPath` points elsewhere | `git config --get core.hooksPath` | git reads ONLY that directory — both `.githooks/` and `.git/hooks/` are bypassed |
| 2 | `.githooks/` is not a git convention | — | git never auto-discovers `.githooks/`. It is a naming convention that requires an explicit `core.hooksPath=.githooks` per repo (git 2.9+) |
| 3 | Hook file lacks the execute bit | `ls -l .githooks/<hook>` | git skips non-executable hooks **silently** — no warning, no error |

Diagnostic sequence:

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
97% confidence
Finding

The documented use of rm -rf against a path containing placeholders is dangerous because incorrect substitution, empty variables, path traversal, or misunderstanding of the current directory can delete unintended files recursively. Even with a comment about approval, the command shape itself is high risk in agent-assisted execution contexts.

Content

Scanner excerpt · move-worktree.md (reported line 31)May include surrounding context.

mv .worktrees/ .worktrees/.tmp git worktree add .worktrees/

Clean up the old directory

rm -rf .worktrees/.tmp # AskUserQuestion required (safe-delete)

text

### Scenario B: Move from `.claude/worktrees/` (or any non-default location) to the configured worktree path

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

This commented deletion command has the same risk profile as other recursive removals: if later executed with malformed or attacker-influenced parameters, it can recursively remove unintended directories. In skill documents, even commented examples can be copied verbatim by agents or users, making them operationally risky.

Content

Scanner excerpt · move-worktree.md (reported line 54)May include surrounding context.

md
#        and remove the staged directory (AskUserQuestion via safe-delete):
mv .claude/worktrees/<name> .worktrees/<name>.staged
git worktree add .worktrees/<name> <branch>
# rm -rf .worktrees/<name>.staged   # safe-delete approval required

#    OR (b) Treat as orphaned and follow Scenario A (rename the source first,
#    then `git worktree add` to the clean target path).

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
88% confidence
Finding

Removing the .git pointer file inside a worktree is a destructive metadata operation that can orphan the directory from Git management if done at the wrong time or on the wrong path. Although less broad than rm -rf, it still enables repository-state corruption and data-management errors when parameterized carelessly.

Content

Scanner excerpt · move-worktree.md (reported line 98)May include surrounding context.

  1. Prune the old worktree from the main repository:
    bash
    rm .worktrees/<name>/.git
    rmdir .worktrees/<name>
    git -C /path/to/main-repo worktree prune
    

Description-Behavior Mismatch

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The file explicitly promises the topic is read-only and will not alter staged content or rebase state, but later instructs restoring hunks to the index and performing branch-reset operations. This mismatch can cause an agent or user to trust the procedure as non-destructive when it actually performs state-changing Git operations, increasing the chance of unintended repository modification during a sensitive rebase or recovery workflow.

Content

No source excerpt is available for this finding.

Intent-Code Divergence

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

The document says the topic is audit-only and never runs rebase control flow, yet later recommends git rebase --continue as part of resolving a redundant pick. In a paused rebase, continuing advances history and may finalize mistaken conflict resolutions, so this contradiction undermines safety guarantees and could lead an automation agent to execute an irreversible workflow step under false assumptions.

Content

No source excerpt is available for this finding.

Lp1

High
Category
MCP Least Privilege
Confidence
75% confidence
Finding

The skill uses 'shell' capability that is not listed in its permissions. This may indicate deceptive intent or missing permission declarations.

Content

No source excerpt is available for this finding.

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/repo-to-ghq.sh (reported line 125)May include surrounding context.

sh
# Other worktrees exist - copy bare repo to preserve them
    echo "Bare repo has $other_wt_count other worktree(s), copying..."
    cp -R "$bare_repo" .git
    rm -rf .git/worktrees
  else
    # No other worktrees - move bare repo (clean up worktrees dir)
    rm -rf "$bare_repo/worktrees" 2>/dev/null

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
95% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · scripts/repo-to-ghq.sh (reported line 128)May include surrounding context.

sh
rm -rf .git/worktrees
  else
    # No other worktrees - move bare repo (clean up worktrees dir)
    rm -rf "$bare_repo/worktrees" 2>/dev/null
    mv "$bare_repo" .git
  fi

Direct Prompt Extraction

High
Category
System Prompt Leakage
Confidence
85% confidence
Finding

Skill contains instructions that could directly expose system prompts, internal rules, or hidden instructions to users or external parties.

Content

Scanner excerpt · sourcegit.md (reported line 180)May include surrounding context.

Add to RepositoryNodes with proper grouping

text

## Output Guidelines

- Confirm what was added/modified
- Show the group hierarchy if applicable

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
65% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · conflict-dry-run.md (reported line 59)May include surrounding context.

md
| # | Don't | Do |
|---|-------|-----|
| 1 | Assume you misremembered the prior state and quietly proceed | Check `git reflog --date=iso -20` for that worktree — distinguish "my own recent operation" from "external activity" |
| 2 | Force the worktree back to the state you expected (`git reset --hard`, `git checkout -f`) | External concurrent activity is not an error to correct — report it and re-verify against the *current* state before continuing |
| 3 | Treat one worktree's clean state as proof the mirror worktree is equally clean | Each worktree shares the object store but not the working tree or HEAD — check each independently, every time |
| 4 | Give up and re-apply the fix from memory without checking whether it already landed | The external activity may have already applied (or superseded) your fix — diff the target file/lines before re-editing |

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
65% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · rebase-audit.md (reported line 188)May include surrounding context.

md
| # | Don't | Do |
|---|-------|-----|
| 1 | Assume you misremembered the prior state and quietly proceed | Check `git reflog --date=iso -20` for that worktree — distinguish "my own recent operation" from "external activity" |
| 2 | Force the worktree back to the state you expected (`git reset --hard`, `git checkout -f`) | External concurrent activity is not an error to correct — report it and re-verify against the *current* state before continuing |
| 3 | Treat one worktree's clean state as proof the mirror worktree is equally clean | Each worktree shares the object store but not the working tree or HEAD — check each independently, every time |
| 4 | Give up and re-apply the fix from memory without checking whether it already landed | The external activity may have already applied (or superseded) your fix — diff the target file/lines before re-editing |

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
65% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · to-ghq.md (reported line 149)May include surrounding context.

md
| # | Don't | Do |
|---|-------|-----|
| 1 | Assume you misremembered the prior state and quietly proceed | Check `git reflog --date=iso -20` for that worktree — distinguish "my own recent operation" from "external activity" |
| 2 | Force the worktree back to the state you expected (`git reset --hard`, `git checkout -f`) | External concurrent activity is not an error to correct — report it and re-verify against the *current* state before continuing |
| 3 | Treat one worktree's clean state as proof the mirror worktree is equally clean | Each worktree shares the object store but not the working tree or HEAD — check each independently, every time |
| 4 | Give up and re-apply the fix from memory without checking whether it already landed | The external activity may have already applied (or superseded) your fix — diff the target file/lines before re-editing |

Tool Parameter Abuse

High
Category
Tool Misuse
Confidence
65% confidence
Finding

Tool parameters are crafted to achieve unintended or unsafe behavior. Parameter abuse can bypass intended safety checks (e.g. shell=True, --force, dangerous glob patterns).

Content

Scanner excerpt · worktree-drift-sync.md (reported line 28)May include surrounding context.

md
| # | Don't | Do |
|---|-------|-----|
| 1 | Assume you misremembered the prior state and quietly proceed | Check `git reflog --date=iso -20` for that worktree — distinguish "my own recent operation" from "external activity" |
| 2 | Force the worktree back to the state you expected (`git reset --hard`, `git checkout -f`) | External concurrent activity is not an error to correct — report it and re-verify against the *current* state before continuing |
| 3 | Treat one worktree's clean state as proof the mirror worktree is equally clean | Each worktree shares the object store but not the working tree or HEAD — check each independently, every time |
| 4 | Give up and re-apply the fix from memory without checking whether it already landed | The external activity may have already applied (or superseded) your fix — diff the target file/lines before re-editing |

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding

The README instructs users to run npx skills add es6kr/skills --skill git-repo without pinning a specific package/version. Because npx resolves and executes code from the registry at install time, a future compromised, typosquatted, or maliciously updated package could execute arbitrary code on the user's machine. In a skill-installation context, this is more dangerous because the command is presented as the primary onboarding path and is likely to be copy-pasted verbatim.

Content

No source excerpt is available for this finding.

Rp1

Medium
Category
MCP Rug Pull
Confidence
91% confidence
Finding

The peer-skill installation command also uses npx skills add es6kr/skills --skill commit-tidy without a pinned version, creating the same supply-chain exposure. Users following documentation may execute whatever package version is current at the time, which can enable arbitrary code execution if the upstream package or dependency chain is compromised. The context increases risk because this is framed as a required dependency, raising the chance users will run it automatically.

Content

No source excerpt is available for this finding.

Static analysis

No suspicious patterns detected.