# husky@9.1.7 security report (npm)

- Verdict: **Needs review** (risk level: medium)
- Scanned: 2026-10-06T14:16:57.000Z
- Files reviewed: 2
- Findings: 4 medium, 3 low severity findings
- Report: https://security.togoder.click/npm/husky
- Source: Togoder Security (https://security.togoder.click), AI source-code review

## Summary

Togoder Security scanned the npm package husky@9.1.7 on Oct 6, 2026. An AI review of 2 source files produced 4 medium, 3 low severity findings. The overall verdict is medium: the findings flag risky but common patterns (dynamic code, unsafe defaults, broad file or network access) rather than confirmed malware.

## Findings

### [medium] File system manipulation outside package scope

Finding ID: `NPS-3B07F333436F`

File: `bin.js:12`

The 'init' command reads and rewrites the project's package.json, adding a 'prepare' script set to 'husky', and creates a .husky/pre-commit hook file. While this is consistent with husky's legitimate behavior, it modifies configuration and creates executable hook scripts in the user's project without explicit consent beyond running the command.

### [medium] Arbitrary hook script creation

Finding ID: `NPS-32049BAF875D`

File: `bin.js:16`

Writes a .husky/pre-commit file whose content is derived from the npm_config_user_agent environment variable and appends 'test\n'. This creates a git hook that runs on every commit. The content is not attacker-controlled here (derived from a well-known env var), but writing executable git hooks is a sensitive operation.

### [medium] Install-time side effects

Finding ID: `NPS-A1620A6D2026`

File: `index.js`

Top-level/exported function performs filesystem writes (mkdirSync, writeFileSync, copyFileSync, rmSync) and runs a git command when invoked. If wired to a lifecycle script (e.g. prepare/postinstall), it executes at install time and can modify the consumer's git configuration.

### [medium] File system manipulation outside package scope

Finding ID: `NPS-205DADBD9C0F`

File: `index.js:16`

Writes git hook scripts and .gitignore files under the .husky directory and modifies git configuration (core.hooksPath). This modifies the host repository's git configuration and hook path, which affects behavior outside the package directory.

### [low] Environment variable access

Finding ID: `NPS-16A64ECF6A87`

File: `bin.js:16`

Reads process.env.npm_config_user_agent to determine the package manager name. This is standard for CLI tools and not credential harvesting, but it is environment inspection.

### [low] Deprecated command handling / process exit

Finding ID: `NPS-63F32BF2A681`

File: `bin.js:21`

Commands 'add', 'set', 'uninstall', and 'install' are deprecated and cause the process to exit with error codes. Not malicious but changes behavior for callers.

### [low] Process execution

Finding ID: `NPS-83F0A659666B`

File: `index.js:18`

Uses child_process.spawnSync to invoke 'git config core.hooksPath', a shell-adjacent process execution. This is expected behavior for a git hooks manager (husky), but still constitutes spawning a process.

## Files reviewed

- `bin.js` (medium): The script implements husky's legitimate init/install workflow but writes git hooks and modifies package.json, which are sensitive operations typical of lifecycle tooling rather than clear malicious behavior.
- `index.js` (medium): Code matches the legitimate 'husky' git hooks installer pattern: it configures core.hooksPath and writes hook scripts, with no evidence of exfiltration, credential harvesting, obfuscation, or backdoor behavior, though it does spawn git and modify repository configuration.

AI analysis is guidance, not a guarantee. Methodology: https://security.togoder.click/methodology
