# Malicious package build hook execution

Install/build/targets hooks in packages that run bundled binaries or fetch remote code

_Area: Software supply chain and CI/CD. Seen in 4 disclosed reports; latest 2026-12-05. Updated 2026-12-01._

## How it works
A package's manifest can declare hooks that the build or install tool runs automatically: npm `preinstall`/`postinstall`, MSBuild `build/<id>.targets`, Gradle/Xcode build phases, git hooks. The assumption that breaks is that installing or building a dependency is passive. It is not: the toolchain executes whatever the hook names, with the developer's privileges, before any code review of the package's actual source. Attackers put the payload in the hook, in a bundled binary the hook launches, or in a remote fetch the hook performs, so the visible package code looks benign [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)[E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md)[E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md).

## Where it shows up
- Manifest hook fields: `preinstall`/`postinstall`/`install`, `build/<package_id>.targets`, Gradle tasks, Xcode build phases, `.git/hooks` [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)[E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md)[E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md)
- Launchers (`*.cjs`) that download a platform-specific executable (e.g. Bun) and run it [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)
- Bootstraps that POST to a host and execute returned `exec`/`args`/`cmd` fields [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)
- Repackaged legitimate OSS with a small added bootstrap that overrides an API base URL via env var [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)
- `example/`, `test/` and sample build files shipped in the registry tarball but never compiled as a dependency [E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md)
- Committed `.nupkg` files and `RestoreAdditionalProjectSources` in take-home repos [E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md)
- Obfuscated shell (`printf|tr`), fragment-based string decryption, side-loading pairs in `%LOCALAPPDATA%` [E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md)[E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md)

## How to review
The invariant: no package may execute code at install/build time that is not fully visible and hash-matched to a reviewed source. Check every hook target resolves to reviewed source, not a binary or remote fetch. Diff bundled binaries and bootstraps against upstream hashes; flag any env-var override of an API endpoint. Scan `example/`/`test/` build files even though they are not dependencies. Confirm `build/<id>.targets` matches the package id (NuGet imports case-insensitively, so a mismatched name still runs) [E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md).

## How finders spotted it
- A supply-chain monitor bot flagged suspicious behavior in one package; researchers linked it to a prior campaign, found a sibling package, and analyzed sites, packages and malware together [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)
- A researcher scanned registry tarballs and found obfuscated shell in `example/` build files, then matched `printf|tr` patterns and C2 domains to a known worm [E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md)
- Researchers tracked fake job-assessment repos, noticed committed `.nupkg` files and `RestoreAdditionalProjectSources`, decompiled the targets DLL and controls, and decrypted fragment strings to recover URLs [E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md)

## Variants seen
- Remote-command launcher downloading a runtime and executing server-selected fields [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)
- Repackaged OSS agent with a bootstrap redirecting LLM traffic [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)
- Worm-injected build hooks in `example/` shipped in the tarball [E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md)
- MSBuild targets stager plus runtime WinUI constructor trigger [E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md)

## Impact and severity
Credential and wallet theft, LLM traffic interception, macOS/Windows infostealers, worm propagation to every project on a machine and to anyone who clones and builds [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)[E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md)[E3](https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md). Severity rises with auto-run on install/build, propagation, and chaining with privilege escalation (sudo, UAC bypass) [E1](https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md)[E2](https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md).

## Seen in real software
Open-source packages and projects, and products, where this pattern was found. If the target runs one, compare the version it runs with the fix.
- **NuGet** (version not stated): 13 Malicious NuGet Packages Target .NET Developers With Fake Job Assessments. Report: https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md
- **universal_file_viewer** (example/ build files (Gradle, Xcode pbxproj, git hooks)) 0.1.5: Compromised Flutter package on pub.dev contains XCSSET malware. Report: https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md

## Evidence
- E1: https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-apex-accelerator-malicious-npm-packages.md
- E2: https://bugbountylibrary.com/r/blog%3Aaikido-dev-blog-compromised-flutter-package-on-pub-dev-contains-xcsset-malware.md
- E3: https://bugbountylibrary.com/r/blog%3Asocket-dev-blog-malicious-nuget-packages-fake-job-assessments.md
