Back to skill

Security audit

Git Hooks Manager

Security checks for vulnerabilities and agentic risk

Overview

This Git hooks manager has a coherent purpose, but its hook import/install paths can write or delete files outside the Git hooks directory.

Review this carefully before installing. Use it only on repositories you trust, avoid importing hook configuration from untrusted sources, back up existing .git/hooks files, and prefer a fixed version that rejects non-standard hook names and enforces path containment before writing or deleting files.

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

Error
Location
scripts/hooks_manager.py:89
Finding

Path Traversal and Absolute-Path Injection Enable Arbitrary File Write and Deletion

Content
View full analysis
bool: """Install a hook by name.""" if hook_name not in HOOK_NAMES: print(f"Warning: {hook_name} is not a standard Git hook name") hook_path = self.hooks_dir / hook_name if script: content = script elif template and template in TEMPLATES: content = TEMPLATES[template] else: # Default no-op hook content = "#!/bin/sh\n# Hook installed by git-hooks-manager\n" with open(hook_path, "w") as f: f.write(content) # Make executable on Unix if os.name != "nt": os.chmod(hook_path, 0o755) print(f"Installed {hook_name} hook at {hook_path}") return True def uninstall(self, hook_name: str) -> bool: """Remove a hook.""" hook_path = self.hooks_dir / hook_name if hook_path.exists(): hook_path.unlink() ``` `scripts/hooks_manager.py:163-169`: ```python def import_config(self, path: str) -> None: """Import hook configuration from JSON.""" with open(path) as f: config = json.load(f) for hook_name, script in config.get("hooks", {}).items(): self.install(hook_name, script=script) print(f"Imported hooks config from {path}") ``` ### Technical Analysis The `hook_name` value is used directly as a filesystem path component. Although the implementation checks whether it appears in `HOOK_NAMES`, an invalid value only generates a warning and is still processed. `pathlib.Path` does not constrain the resulting path to `self.hooks_dir`: - A value containing `../` can traverse outside the Git hooks direc ...[truncated 2676 chars]
Remediation
View remediation
Vulnerability Patterns
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (10)

os.system() or os exec-family call

High
Category
Dangerous Code Execution
Confidence
85% confidence
Finding

os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.

Content

Scanner excerpt · examples/basic_usage.py (reported line 18)May include surrounding context.

python
"""Install a pre-commit hook with lint-and-test template."""
    with tempfile.TemporaryDirectory() as tmpdir:
        # Init a git repo
        os.system(f"cd {tmpdir} && git init -q")
        
        manager = HookManager(tmpdir)
        manager.install("pre-commit", template="lint-and-test")

os.system() or os exec-family call

High
Category
Dangerous Code Execution
Confidence
85% confidence
Finding

os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.

Content

Scanner excerpt · examples/basic_usage.py (reported line 61)May include surrounding context.

python
"""Install a pre-commit hook with lint-and-test template."""
    with tempfile.TemporaryDirectory() as tmpdir:
        # Init a git repo
        os.system(f"cd {tmpdir} && git init -q")
        
        manager = HookManager(tmpdir)
        manager.install("pre-commit", template="lint-and-test")

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · scripts/hooks_manager.py (reported line 159)May include surrounding context.

python
def run_command(self, cmd: str, args: Optional[List[str]] = None) -> subprocess.CompletedProcess:
        """Run a shell command and return result."""
        full_cmd = [cmd] + (args or [])
        return subprocess.run(full_cmd, capture_output=True, text=True, cwd=self.repo_path)
    
    def export_config(self, path: str) -> None:
        """Export hook configuration to JSON."""

subprocess module call

Medium
Category
Dangerous Code Execution
Confidence
70% confidence
Finding

subprocess module calls execute external commands. Without careful input validation, this enables command injection.

Content

Scanner excerpt · tests/test_hooks_manager.py (reported line 21)May include surrounding context.

python
def setUp(self):
        self.temp_dir = tempfile.mkdtemp()
        # Initialize git repo
        subprocess.run(["git", "init"], cwd=self.temp_dir, capture_output=True)
        self.manager = HookManager(self.temp_dir)
    
    def tearDown(self):

Missing User Warnings

Low
Category
Not specified by scanner
Confidence
83% confidence
Finding

This is a markdown file, so SQP-2 applies to omissions in user-facing safety warnings. The command list advertises install, uninstall, export, and import operations that affect repository hook configuration, but the README provides no warning that these actions modify Git hook files or may replace existing local hooks/configuration.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is specified with a lower bound only, which allows builds to resolve to different future versions and undermines reproducibility. This increases supply-chain risk because a vulnerable or malicious upstream release could be installed without any change to this repository.

Content

Scanner excerpt · requirements.txt (reported line 1)May include surrounding context.

text
click>=8.0.0
colorama>=0.4.6
pytest>=7.0.0

Unverifiable Dependency: click has 1 known advisory(ies) (CVE-2026-7246 (Pallets Click, versions 8.3.2 and below, contain a command injection vulnerabili)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
89% confidence
Finding

The manifest does not pin click, and the package has at least one known advisory affecting some versions. Because any version at or above 8.0.0 may be selected, it is impossible to verify from this file alone whether installations will avoid affected releases, creating real uncertainty around command-injection exposure.

Content

No source excerpt is available for this finding.

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

The dependency is unpinned, so installations are not deterministic and may pull in unexpected future releases. That creates avoidable supply-chain exposure and makes it harder to verify whether a deployment is using a safe version.

Content

Scanner excerpt · requirements.txt (reported line 2)May include surrounding context.

text
click>=8.0.0
colorama>=0.4.6
pytest>=7.0.0

Unpinned Dependencies

Low
Category
Supply Chain
Confidence
95% confidence
Finding

Using only a minimum version for pytest permits installation of any newer release, including versions later found vulnerable or incompatible. Even though pytest is commonly a dev/test dependency, unpinned packages still weaken build integrity and traceability.

Content

Scanner excerpt · requirements.txt (reported line 3)May include surrounding context.

text
click>=8.0.0
colorama>=0.4.6
pytest>=7.0.0

Unverifiable Dependency: pytest has 2 known advisory(ies) (CVE-2025-71176 (pytest has vulnerable tmpdir handling); CVE-2025-71176 (pytest has vulnerable tmpdir handling)), but the manifest does not pin a version, so it is unknown whether the installed release is affected

Low
Category
Supply Chain
Confidence
86% confidence
Finding

Pytest has known advisories for some versions, but this requirements file does not fix an exact version, so the safety of the installed release cannot be established. The risk is somewhat reduced because pytest is typically used in testing rather than production runtime, but compromised or vulnerable test tooling can still affect CI systems and developer environments.

Content

No source excerpt is available for this finding.