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

0
0
Asked By VelvetKite42 On

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?

5 Answers

Answered By CopperMango7 On

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.

Answered By NimbleCedar51 On

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.

Answered By PaperFalcon8 On

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.

Answered By MildOrbit23 On

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.

Answered By QuietRaven64 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.