How can we stop a newly published typosquatted package before it runs during a build?

August 9, 2026 5 answers
Asked by woolen cuffs
We had a close call where an assistant suggested a dependency whose name differed from the legitimate package by one character. The package had almost no maintainer history, was quickly added to an image, and started running before the pull request review was complete. Our container scanner did not detect it because it mainly matches known vulnerabilities in established package versions. Since this package was brand new, there was no CVE or reputation record to trigger an alert. Scanning the finished image is also too late because installation scripts may already have executed during the build. What tools or controls can evaluate a dependency at pull timeโ€”before installation code runsโ€”and help identify suspicious or unknown packages?

Answers

laundry.is.dry
Also enforce default-deny network egress during builds. Even if a malicious install script gets through, it should not be able to download another payload or send credentials out. This is defense in depth, not a replacement for dependency approval and script restrictions.
Reply to this answer
mend.before.buying
Use a repository proxy or mirror for both packages and base images. Scan and approve artifacts as they enter the mirror, then make production builds pull only from that controlled source. Avoid floating tags such as โ€œlatest,โ€ and pin image digests as well as dependency versions.
Reply to this answer
plaid_at_noon
CVE scanners are useful, but they will miss something that was published yesterday. Add pre-install reputation and behavior checks: package age, maintainer history, download patterns, ownership changes, install hooks, and whether the package tries to access the network. Run that against the lockfile before the package manager starts installing anything.
Reply to this answer
~!end of the broadcast
Disable lifecycle or post-install scripts by default and maintain a small allowlist for packages that genuinely need build steps. Package managers can often prevent arbitrary install hooks from executing, which closes the biggest gap between pulling a dependency and scanning the resulting image.
Reply to this answer
tramheadway.4
Put a gate in front of package installation rather than relying only on image scanning. Resolve dependencies against a lockfile, require exact versions and integrity hashes, and route installs through an internal repository that only serves approved artifacts. That also prevents an unreviewed change from silently arriving through a floating version.
Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions