Review processes break because teams often check package.json for lifecycle hooks and assume a clean manifest means a safe install. binding.gyp can trigger code during native builds, so the real execution path lives in the build toolchain. That means scanners, approvals, and CI policy have to inspect build metadata as well as scripts.
Why This Matters for Security Teams
The failure here is not just malicious code, it is misplaced trust in where npm execution starts. Teams often review NIST SP 800-53 Rev 5 Security and Privacy Controls style controls at the manifest layer, then assume a quiet package.json means a safe install. Native build paths can still execute code through binding.gyp, which means policy, approval, and detection logic must cover the build toolchain, not only lifecycle scripts. That matters because supply chain attacks routinely hide in the least-inspected path.
NHI Management Group research shows why this is not theoretical: 96% of organisations store secrets outside secrets managers in vulnerable locations including code, config files, and CI/CD tools, and 79% have experienced secrets leaks. When build-time execution can touch environment variables, local credentials, or pipeline tokens, a package install becomes an identity event as much as a software event. Recent incidents such as the Shai Hulud npm malware campaign and the Mastra npm Supply Chain Attack - Sapphire Sleet show how quickly package trust can collapse when execution happens outside the paths defenders actually monitor. In practice, many security teams encounter the compromise only after credentials have already been read from the build environment.
How It Works in Practice
binding.gyp is a native module build definition, so npm may invoke the build system even when package.json contains no suspicious scripts. That changes the control point. Instead of asking only “What scripts run?”, defenders need to ask “What build steps run, under what privileges, with what secrets available, and from which working directory?”
For practitioners, the workable model is to treat package installation as a controlled execution workflow. Review should cover package.json, binding.gyp, transitive native dependencies, and any tool invoked by node-gyp or the platform compiler. Build-time policy should be enforced in CI with allowlists for expected native modules, short-lived credentials, and environment scoping so the build job sees only the minimum secrets required. For higher-risk environments, run builds in isolated workers with no long-lived tokens, and verify that artifact signing, dependency pinning, and provenance checks happen before any release promotion.
This is where Ultimate Guide to NHI guidance becomes operational: build systems are non-human identities too, and they must be governed like privileged workloads. Pair that with runtime assurance concepts from the NIST control catalog by requiring least privilege, controlled execution, and auditability at the point where code actually runs. These controls tend to break down when native package builds are delegated to developer laptops or self-hosted runners with broad filesystem access because the execution context becomes both opaque and overprivileged.
Common Variations and Edge Cases
Tighter build inspection often increases pipeline friction, requiring organisations to balance developer velocity against the risk of hidden native execution. That tradeoff is manageable, but guidance is still evolving for several edge cases.
One common exception is legitimate native tooling that must compile on demand. In those environments, a blanket ban on binding.gyp is usually unrealistic, so current guidance suggests policy should distinguish known-good native dependencies from unreviewed ones. Another edge case is monorepos or internal package registries where trust is assumed because the source is “inside” the company. That assumption fails when a compromised internal package can still execute build logic with access to shared credentials.
This is also where post-install assumptions become dangerous. A package can look clean in package.json and still execute code through native compilation, prebuild fetches, or platform-specific hooks. The strongest practical response is to combine dependency review with build provenance checks, secrets minimisation, and strict CI runner isolation. The Nx Package Attack is a reminder that once a package can reach developer or pipeline credentials, the blast radius is no longer limited to one install event. There is no universal standard for this yet, but mature teams are moving toward build-time identity controls rather than relying on manifest review alone.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Non-Human Identity Top 10, OWASP Agentic AI Top 10 and CSA MAESTRO address the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP Non-Human Identity Top 10 | NHI-04 | Build-time execution can expose NHI secrets and privileged credentials. |
| OWASP Agentic AI Top 10 | A-03 | Autonomous build actions behave like non-human execution paths needing runtime control. |
| CSA MAESTRO | GOV-04 | Native build steps need governance, approval, and provenance in CI/CD. |
| NIST AI RMF | This is a trust and accountability problem in automated software execution. | |
| NIST CSF 2.0 | PR.AC-4 | Build systems need least privilege and controlled access to secrets and resources. |
Inspect build paths for secret exposure and restrict native package installs to least-privilege runners.
Related resources from NHI Mgmt Group
- What breaks when npm package installs are allowed to execute code before inspection?
- What breaks when malicious npm packages are allowed to run on developer endpoints?
- How should teams reduce risk from malicious npm package installs?
- What breaks when malicious npm packages execute during CI/CD installs?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org