An on-install script is code that runs automatically during software installation. It is used to perform setup tasks such as creating files, registering services, or configuring defaults, and may execute with the installer’s privileges, so it can affect system state, trust boundaries, and access permissions.
What an on-install script does
An on-install script is not just “extra installer logic”; it is executable code that becomes part of the installation event itself. That means the script can shape the initial software footprint, create files or services, and establish defaults before the user or administrator has finished trusting the product.
Because it runs during installation, the script sits at a sensitive point in the software supply chain. A benign use case can be legitimate setup automation, but the same mechanism can also be abused to alter system state, seed persistence, or introduce unexpected access paths if the package source or build pipeline is compromised.
Why install-time execution is security-sensitive
Install-time code is dangerous because it often executes at a moment of elevated trust. Installers may have permissions that the application itself does not yet need, which means an on-install script can inherit broad access to the host, files, configuration, or network resources.
This makes the boundary between “setup” and “action” easy to blur. If package review focuses only on application behavior after deployment, a malicious or overly broad install script can slip through unnoticed and perform security-relevant changes before runtime controls are in place.
For dependency-heavy ecosystems, install-time execution is also a common delivery path for supply-chain abuse. NHI Management Group’s Self Propagating Supply Chain Worms guide shows how package install scripts can become part of a propagation loop when registry credentials, trusted publishing paths, or CI identities are abused.
Common failure modes and attack paths
The main failure modes are over-trust, hidden side effects, and uncontrolled privilege. A package may appear harmless in source form while its install script creates services, rewrites configuration, downloads payloads, or reaches out to external infrastructure during installation.
Attackers also value install scripts because they run early, before users have a chance to notice suspicious behavior or before compensating controls are fully active. That makes them useful for persistence, environment-specific payload delivery, and supply-chain compromise that only triggers in real installations.
In ecosystems such as npm and PyPI, install scripts are especially sensitive because they can run automatically across many environments. NHI Management Group’s npm Install-Time Security Guide explains the practical controls that reduce this exposure, while the Malicious Package and Dependency Confusion Guide covers the broader package abuse patterns that often surround install-time execution.
How teams should evaluate and govern on-install scripts
On-install scripts should be treated as a trust decision, not a packaging detail. For new dependencies, teams need to know whether scripts exist, what they do, and whether the package genuinely requires install-time execution to function.
That review is strongest when it is tied to dependency intake and package approval rather than ad hoc judgement. NHI Management Group’s Dependency Intake Review Checklist is useful here because it places install scripts alongside authenticity, provenance, and maintainer checks as part of dependency acceptance.
Where install-time execution is unavoidable, the governance question becomes whether it is constrained, observable, and consistent with the organisation’s packaging policy. If the package ecosystem or build path supports script suppression, script allowlisting, or restricted install modes, those controls should be preferred for high-trust or high-impact environments.
What to do after a suspicious install script has run
If an on-install script is suspected of being malicious, the response should assume that host state may already have changed. The priority is to determine what the script touched, what it may have created, and whether it accessed credentials, tokens, or other sensitive material during installation.
That usually means reviewing installed files, added services, altered startup entries, outbound network activity, and any dependent systems that may have been exposed through the install path. NHI Management Group’s Malicious Open Source Package Response Playbook and Malicious Package Worm Response Playbook both reflect the operational reality that package compromise often requires token rotation, lockfile review, and environment rebuilds.
If the script executed with elevated privileges, post-incident review should also consider whether trust boundaries were crossed in a way that left behind persistence or secondary access. In practice, that is what makes on-install scripts more than a convenience feature: they are an execution channel that can materially change the security posture of the system that installed them.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
CIS Controls v8, NIST SP 800-53 Rev 5, OWASP ASVS and SLSA set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| CIS Controls v8 | CIS-5 — Account Management | Install scripts can create or alter accounts and services during setup. |
| Recommendation — Restrict install-time account creation and review any new service or user added by a package. | ||
| NIST SP 800-53 Rev 5 | CM-7 — Least Functionality | On-install scripts should be limited to only the setup behavior actually required. |
| SI-7 — Software, Firmware, and Information Integrity | Install scripts are part of trusted software execution and can alter integrity at install time. | |
| Recommendation — Disable unnecessary install-time execution paths and permit only required setup functions. Verify package integrity and inspect install-time behavior before allowing execution. | ||
| OWASP ASVS | V15 — Secure Coding and Architecture | Install-time code is an architectural trust boundary that can introduce unwanted behavior. |
| Recommendation — Design packages so install-time actions are minimized, explicit, and reviewable. | ||
| SLSA | Build provenance and artifact integrity | Install scripts are part of the artifact trust chain and can undermine provenance confidence. |
| Recommendation — Require strong provenance and artifact integrity checks before packages are permitted to execute install scripts. | ||
Related resources from NHI Mgmt Group
- What breaks when teams rely only on install-time script blocking to stop npm malware?
- What are the signs that a malicious package is hiding install-time execution beyond a normal preinstall script?
- What happens when a compromised dependency or install script reaches a CI/CD build?
- Why does a malicious install script create more risk than a normal package vulnerability?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org