First map the package resolution path so the agent only installs from approved registries, pinned versions, and trusted lockfiles. Then restrict the agent’s filesystem and network permissions, because a coding agent that can resolve arbitrary packages can also trigger install scripts and pull untrusted code into its runtime.
What should teams do first when a coding agent installs packages?
The first move is to control where the agent can resolve dependencies from, not to trust the install step itself. A coding agent should only be able to pull packages from approved registries, pinned versions, and trusted lockfiles, because package resolution is a supply-chain decision as much as an engineering convenience.
That matters because once the agent can resolve arbitrary packages, the install phase can become an execution path. Build scripts, postinstall hooks, and dependency confusion all turn a routine package install into a place where untrusted code can enter the agent runtime.
Why package resolution is the real trust boundary
Teams often treat installation as a passive fetch, but for coding agents it is an active trust decision. If the agent can select package names, versions, or registries freely, then the package ecosystem effectively becomes part of the agent’s attack surface.
Approved registries and pinned lockfiles reduce that surface by making dependency choice predictable and reviewable. A trusted lockfile tells you what should be installed; an approved registry list tells you where that software may come from; version pinning narrows the space attackers can abuse through lookalike or newly published packages.
This is also why install-time controls should be paired with repository and workspace controls. A coding agent that can write to the filesystem broadly or reach arbitrary network destinations can often bypass the intended dependency path and reach alternative sources, mirrors, or scripts that were never meant to be part of the build.
For a deeper view of package hallucination and dependency hardening, Slopsquatting and Package Hallucination Guide is directly relevant, and the broader AI Coding Agents Security Guide covers the surrounding sandboxing and supply-chain boundaries.
How install scripts and package choice become execution risk
Package managers do more than download artifacts. Many ecosystems allow lifecycle scripts, native builds, or optional postinstall actions that execute during installation. For a coding agent, that means a package choice can become code execution in the same environment where the agent has access to tools, files, tokens, and project context.
The practical implication is that dependency policy must cover both provenance and behaviour. Teams should assume that an untrusted package can try to inspect the workspace, read environment variables, reach external services, or modify files during install. If the agent can also run commands with broad permissions, the blast radius grows quickly.
The right control objective is to make the install path boring: known registry, known lockfile, known version, limited script execution, and a workspace that does not expose more than the agent needs. That is much safer than trying to inspect every package after the fact.
When you want a concrete incident lens on how package trust failures play out, LiteLLM PyPI package breach shows why package origin matters, while AI Coding Agent Incident Playbook is useful when install-time trust has already been broken and containment becomes the priority.
What to lock down around the agent after package resolution
Once dependency resolution is constrained, the next layer is to reduce what the agent can do with the result. Restrict filesystem permissions to the smallest workspace the task needs, and restrict network access so the agent cannot quietly fetch from unapproved sources or exfiltrate data while installing dependencies.
That combination matters because package resolution and runtime execution are linked. If the agent can resolve arbitrary packages but also has broad filesystem and network access, an attacker only needs one weak dependency path to get code running with useful reach.
Teams should also treat the package list as an approval object, not just a technical artifact. If a coding agent proposes a new dependency, it should be reviewed as a supply-chain change, especially when the package name was suggested by the model rather than already present in the repository’s established dependency set.
Risk and Threat Considerations
Package installs are a common place for supply-chain compromise because they combine name resolution, code execution, and trust in third-party publishing. For coding agents, the risk is amplified when the agent can search broadly, install automatically, and run with workspace or network access that was not intended for untrusted code.
Failure mechanism: The agent resolves a package from the wrong registry, a malicious lookalike, or a dependency with install-time behaviour that executes code before review. That code can then read files, use credentials, or alter the workspace if filesystem and network scope are too broad.
Impact: The result can be poisoned builds, credential exposure, tampered source, or a compromised agent session that turns one dependency install into persistent supply-chain risk across the repo and downstream environments.
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 | Covers controlling agent access paths and approved software sources. |
| Recommendation — Restrict package install permissions and approved sources to minimize unintended code execution. | ||
| NIST SP 800-53 Rev 5 | SA-12 — Supply Chain Protection | Package installs are a software supply-chain trust decision. |
| CM-7 — Least Functionality | Constraining filesystem and network reach reduces install-time abuse. | |
| Recommendation — Use SA-12 to require trusted software sources and review dependency provenance. Apply CM-7 to limit the agent to only the files, tools, and network paths it needs. | ||
| OWASP ASVS | V15 — Secure Coding and Architecture | Install-time trust and dependency handling are part of secure architecture decisions. |
| Recommendation — Verify dependency sourcing and execution paths as part of secure build design. | ||
| SLSA | Supply chain integrity | Build and dependency provenance are central to safe package installation. |
| Recommendation — Adopt provenance and integrity checks for packages entering the build pipeline. | ||
Practitioner Guidance
What to prioritise: Start by making dependency resolution deterministic. Approved registries, pinned versions, and trusted lockfiles should be in place before you decide whether the agent can automate installs at all.
What to verify: Confirm that the agent cannot silently fall back to public registries, alternate mirrors, or unreviewed package sources, and check whether install scripts are allowed to run by default. If they are, treat that as an explicit risk decision rather than a convenience setting.
Common mistake: Teams often harden the model prompts or approval flow but leave the install environment too open. If the agent can reach the network freely and write broadly to disk, package trust controls lose much of their value.
Practitioner takeaway: The safest first step is to define the dependency trust boundary, then constrain the agent’s execution environment to match it, because package resolution without those limits is just an unreviewed code-execution path.
Related resources from NHI Mgmt Group
- What should teams do first when an AI coding agent starts retrying the same fix repeatedly?
- What should teams do first when a coding agent can run commands from workspace content?
- What should teams do first when a coding agent can reach local secrets or config files?
- What should teams do first after a coding agent control failure?
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 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org