Every project I audit has a requirements.txt or a lockfile and a feeling of safety. So let me do the threat model out loud.
What you trust when you add a dependency 1. The author of that package today. 2. Every author it depends on, recursively. 3. The registry that serves it, and the account that publishes it. 4. Your own build machine and the network between you and the registry.
What can go wrong - A maintainer account is taken over and a malicious release is published. - A name close to a popular one (typosquatting) gets installed by mistake. - A release is yanked and replaced, so "version 1.4.2" is no longer the same bytes tomorrow. - A project changes hands and the new owner publishes something you did not expect.
What pinning gives you
- A lockfile with exact versions and hashes (pip install --require-hashes, package-lock.json integrity fields, Cargo.lock checksums) means you get the bytes you reviewed last time, not whatever is newest. That kills the "silent replacement" case.
What it does not give you - Protection from a dependency that was already malicious when you pinned it. - Protection when you update. Updating is where the risk comes back, so it deserves a review of the diff, not just a green CI.
Habits that help: fewer, smaller dependencies; a delay before adopting brand-new releases; a private mirror for production builds; and the unfashionable one, reading what changed.
What is your own rule for accepting an update?