Install Hook Analysis
Install hooks run code the moment you install a package — before you ever import it.
Malicious packages abuse preinstall scripts and setup.py to execute
payloads during installation, when your guard is down.
The Install Hook Attack Surface
Package managers allow packages to execute arbitrary code during installation. In npm, this happens through preinstall, postinstall, and install scripts defined in package.json. In Python, setup.py runs during pip install and can execute any Python code.
This is the most dangerous moment in the package lifecycle. The code runs with the installing user's full permissions, has network access, can read the filesystem, and executes before the developer has any chance to review the package source.
What Hextrap Scans For
The Phase 2 content analyzer inspects install-time scripts for patterns that indicate malicious intent:
npm Scripts
child_processimports — spawning shell commands from Node.jsexec()/execSync()calls with encoded or obfuscated arguments- Network requests via
http,https, ornode-fetchin install scripts - File system operations writing outside the package directory
Python setup.py
subprocess.Popen()oros.system()callssocketimports and network connectionsurlliborrequestsusage for downloading payloadsexec()/eval()with encoded arguments- Reading sensitive files (
~/.ssh,~/.aws,/etc/passwd)
Why This Matters
Install hooks are the primary delivery mechanism for supply chain attacks. Over 90% of malicious packages discovered on npm and PyPI use install hooks to execute their payloads. By analyzing these scripts before allowing installation, Hextrap blocks the most common attack vector.
Legitimate packages do use install hooks — for native compilation, binary downloads, or post-install setup. The analyzer distinguishes between these benign uses and suspicious patterns like encoded commands, credential access, and external network calls to unknown hosts.
Block Malicious Install Scripts
Analyze every install hook before code reaches your machine