Lockfile bypass: builds that ignore the versions you reviewed

Lockfiles pin exact dependency versions, but builds that run install instead of a frozen install, or ignore the lockfile, pull whatever is newest. How to enforce frozen installs across npm, pnpm, Yarn, pip, and Go.

Lesson 24 of 26 · 9 min read · practice only with authorization

Diagram

Same commit, different dependencies

Follow the path. One example at a time.

Step 1 of 4

Locked

package-lock.json pins left-pad 1.3.0.

Illustration: Locked
# Locked
# package-lock.json pins left-pad 1.3.0.

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Install versus ci

    What fails
    npm install can rewrite the lockfile; npm ci never does.
    Who is affected
    Every build artifact.
    What you would notice
    CI scripts using npm install.
    What you change
    Use npm ci or the frozen equivalent.
  2. Unhashed requirements

    What fails
    pip requirements without hashes accept any file for a version.
    Who is affected
    Python builds.
    What you would notice
    requirements.txt with == but no --hash.
    What you change
    Generate hashes with pip-compile --generate-hashes or use uv.
  3. Lockfile not committed

    What fails
    Missing lockfiles mean every build resolves fresh.
    Who is affected
    Reproducibility.
    What you would notice
    .gitignore entries for lockfiles.
    What you change
    Commit lockfiles and review their diffs.

A CI guard

Fail the build if install modified the lockfile.

- run: npm ci
- run: git diff --exit-code -- package-lock.json

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

Which npm command fails instead of changing the lockfile?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

This page stands on its own. The lab and the glossary card are the next reading.

Practice

  1. LabTerminal mission: A lockfile change nobody readsA pull request says “bump axios” but also touches package-lock.json. Diff the lockfiles and find the package whose download URL and integrity hash were quietly swapped.

Glossary

  1. CardLockfile bypassAn install ignores the lockfile and resolves a different tree than review saw.