· Guide · 2 min read
How to avoid malicious packages.
Malicious packages and compromised dependencies can enter through normal development workflows. Practical controls help teams reduce supply-chain risk.
Software projects rely on third-party packages. That saves time, but it also means a normal install command can bring external code into a build, workstation, or production deployment.
Attackers can abuse package ecosystems through lookalike names, compromised publisher accounts, or malicious updates. The practical question is not whether a team can avoid every dependency. It is whether the team can make dependency changes visible, repeatable, and reviewable.
Use a repeatable install process
For npm projects, commit the package-lock.json file. npm documents that the lockfile records the exact dependency tree so teammates, deployments, and CI can reproduce the same install state.[1]
For Python deployments where stronger assurance is needed, pip supports hash-checking mode through --require-hashes. This requires pinned requirements and hashes for the requirements involved in the install.[2]
A lockfile or hash-based workflow does not make a dependency safe by itself. It does make unexpected changes easier to identify and investigate.
Review before installing
Treat a new package as code entering your environment. Before adding one, check:
- Is the package name exactly what you intended?
- Is the publisher, repository, and release history credible?
- Is the package necessary, or can an existing dependency solve the problem?
- Has someone reviewed the change through source control?
- Will the package run during installation, build, or production execution?
Avoid installing packages from a copied command without checking the name and source first. A small spelling change can be the entire attack.
Monitor the dependencies you already have
Use the security features available in your development workflow. npm audit can assess dependencies against known advisories, and npm supports verification of registry signatures and provenance where available.[3] GitHub Dependabot alerts can notify a repository when a known vulnerable dependency is detected.[4]
These tools are useful signals, not a substitute for review. They cannot determine whether a package is appropriate for your architecture, whether a dependency is actually reachable in your application, or whether an upgrade breaks an important workflow.
Build a simple team rule
A practical rule for a small team is enough to start:
- Add dependencies through a pull request or documented review.
- Commit lockfiles or use pinned, hashed requirements for production installs.
- Review high-impact dependency updates before deployment.
- Keep alerts enabled and give someone ownership for triage.
- Remove packages that are no longer needed.
SB Software can help teams assess software supply-chain practices and build a practical improvement plan. Contact us or review our cybersecurity consulting service.