Prerequisites
- Target system, dependencies and environment configured.
Usage
Purpose
A lockfile records the exact versions and integrity hashes of every dependency (including transitive ones) your project resolved. It's a foundational, low-effort supply-chain control: it makes builds reproducible (everyone installs the same thing) and verifiable (the integrity hash ensures a package wasn't swapped or tampered with between resolution and install). This skill covers using lockfiles for integrity, the simple discipline that underpins dependency-confusion, typosquat, and tampering defences.
When to use it
Every project with dependencies (nearly all). It's basic and often already present but under-used or not enforced — a lockfile that isn't committed, verified, or trusted provides little of its value. It's the substrate the other supply-chain controls build on.
Procedure
- Commit the lockfile. The lockfile (
package-lock.json, poetry.lock, Cargo.lock, pip with hashes, etc.) must be committed to version control so everyone — developers and CI — resolves to the exact same dependency tree. An uncommitted lockfile means builds can resolve differently, defeating reproducibility.
- Install from the lockfile, strictly. Use the install mode that installs exactly what the lockfile specifies and fails if the lockfile is out of sync, rather than silently re-resolving.
npm ci (not npm install), pip install --require-hashes, poetry install — these enforce the locked state:npm ci # installs exactly the lockfile, fails on mismatch
pip install --require-hashes # verifies integrity hashes
npm install can silently update the lockfile; npm ci enforces it.
- Verify integrity hashes. The lockfile's integrity hashes are the tamper-protection: on install, the package manager checks the downloaded package's hash against the lockfile, rejecting a package that doesn't match (swapped, tampered, or a registry substitution). Ensure hash verification is on (some ecosystems require explicit config, like pip's
--require-hashes).
- Review lockfile changes. A change to the lockfile means dependencies changed; review lockfile diffs in pull requests. An unexpected dependency appearing, or a hash changing without a version change, is a red flag (possible tampering or a suspicious update).
- Regenerate deliberately. Update the lockfile intentionally (when adding/updating dependencies), not accidentally; a lockfile that drifts silently loses its guarantee. Automated dependency-update tools (Dependabot) regenerate it cleanly with review.
- Combine with the other controls. Lockfile integrity ensures you install what you resolved; pair with dependency scanning (are the locked versions vulnerable?), typosquat/confusion defences (is the resolved package the right one?), and signing.
Cheatsheet
lockfile = exact versions + INTEGRITY HASHES of every dependency (incl. transitive)
-> reproducible (same install everywhere) + verifiable (hash = not swapped/tampered)
foundational, low-effort. often present but under-used/unenforced.
do
COMMIT the lockfile (uncommitted -> builds resolve differently)
INSTALL STRICTLY from it, fail on mismatch (NOT silent re-resolve)
npm ci (not npm install) | pip install --require-hashes | poetry install
VERIFY integrity hashes (tamper protection — reject package whose hash != lockfile)
(some ecosystems need explicit config: pip --require-hashes)
REVIEW lockfile diffs in PRs (unexpected dep / hash change w/o version change = red flag)
REGENERATE deliberately (adding/updating deps) — silent drift loses the guarantee
COMBINE with dependency scanning + typosquat/confusion defences + signing
Reading the practice
- An uncommitted lockfile = builds can resolve to different dependency trees; reproducibility and the integrity guarantee are lost. Commit it — the foundational step.
- Using
npm install (or loose install) in CI = the lockfile can be silently updated and different packages installed; use npm ci (or the strict equivalent) that installs exactly the lockfile and fails on mismatch. The difference between a lockfile that's enforced and one that's decorative.
- Integrity hash verification off = the tamper protection is disabled; a swapped or tampered package installs unnoticed. Ensure hash checking is on (pip needs
--require-hashes).
- A hash changing without a version change in a lockfile diff = a red flag — the package content changed for the same version, possibly tampering or a compromised republish. Review lockfile diffs.
- A silently-drifting lockfile = the guarantee erodes; regenerate deliberately with review, not accidentally.
- Committed, strictly-installed, hash-verified, reviewed lockfiles = reproducible, tamper-resistant dependency installs — the substrate the other supply-chain controls need.
Pitfalls
- Not committing the lockfile. Without it committed, everyone resolves differently and the integrity guarantee is gone. Commit it.
- Loose install commands.
npm install silently updates the lockfile; use npm ci (and strict equivalents) that enforce the locked state and fail on mismatch. Otherwise the lockfile is decorative.
- Hash verification disabled. The integrity hashes are the tamper protection; without verification (e.g. pip without
--require-hashes), a swapped package installs unnoticed.
- Ignoring lockfile diffs. Dependency and hash changes carry supply-chain risk; a hash change without a version change is suspicious. Review lockfile changes in PRs.
- Silent regeneration. A lockfile that drifts accidentally loses its guarantee; update it deliberately with review.
References
- npm (
npm ci, package-lock), pip (--require-hashes), Poetry, Cargo lockfile documentation
- The dependency-confusion, typosquat-detection, and vulnerable-dependency-triage skills
- The devsecops dependency-scanning skill
- OpenSSF supply-chain security guidance
Inputs
- Relevant source code, logs, network traces, or system specifications.
Outputs
- Analysis findings, security audit report, or generated code artifacts.
1---2name: lockfile-integrity3description: Use when ensuring reproducible, verified dependencies — using lockfiles with integrity hashes so you install exactly the packages you vetted, and nothing gets swapped.4---5678## Prerequisites9- Target system, dependencies and environment configured.1011## Usage12### Purpose1314A lockfile records the exact versions and integrity hashes of every dependency (including transitive ones) your project resolved. It's a foundational, low-effort supply-chain control: it makes builds reproducible (everyone installs the same thing) and verifiable (the integrity hash ensures a package wasn't swapped or tampered with between resolution and install). This skill covers using lockfiles for integrity, the simple discipline that underpins dependency-confusion, typosquat, and tampering defences.1516### When to use it1718Every project with dependencies (nearly all). It's basic and often already present but under-used or not enforced — a lockfile that isn't committed, verified, or trusted provides little of its value. It's the substrate the other supply-chain controls build on.1920### Procedure21221. **Commit the lockfile.** The lockfile (`package-lock.json`, `poetry.lock`, `Cargo.lock`, `pip` with hashes, etc.) must be committed to version control so everyone — developers and CI — resolves to the exact same dependency tree. An uncommitted lockfile means builds can resolve differently, defeating reproducibility.232. **Install from the lockfile, strictly.** Use the install mode that installs *exactly* what the lockfile specifies and *fails* if the lockfile is out of sync, rather than silently re-resolving. `npm ci` (not `npm install`), `pip install --require-hashes`, `poetry install` — these enforce the locked state:24 ```25 npm ci # installs exactly the lockfile, fails on mismatch26 pip install --require-hashes # verifies integrity hashes27 ```28 `npm install` can silently update the lockfile; `npm ci` enforces it.293. **Verify integrity hashes.** The lockfile's integrity hashes are the tamper-protection: on install, the package manager checks the downloaded package's hash against the lockfile, rejecting a package that doesn't match (swapped, tampered, or a registry substitution). Ensure hash verification is on (some ecosystems require explicit config, like pip's `--require-hashes`).304. **Review lockfile changes.** A change to the lockfile means dependencies changed; review lockfile diffs in pull requests. An unexpected dependency appearing, or a hash changing without a version change, is a red flag (possible tampering or a suspicious update).315. **Regenerate deliberately.** Update the lockfile intentionally (when adding/updating dependencies), not accidentally; a lockfile that drifts silently loses its guarantee. Automated dependency-update tools (Dependabot) regenerate it cleanly with review.326. **Combine with the other controls.** Lockfile integrity ensures you install what you resolved; pair with dependency scanning (are the locked versions vulnerable?), typosquat/confusion defences (is the resolved package the right one?), and signing.3334### Cheatsheet3536```37lockfile = exact versions + INTEGRITY HASHES of every dependency (incl. transitive)38 -> reproducible (same install everywhere) + verifiable (hash = not swapped/tampered)39 foundational, low-effort. often present but under-used/unenforced.4041do42 COMMIT the lockfile (uncommitted -> builds resolve differently)43 INSTALL STRICTLY from it, fail on mismatch (NOT silent re-resolve)44 npm ci (not npm install) | pip install --require-hashes | poetry install45 VERIFY integrity hashes (tamper protection — reject package whose hash != lockfile)46 (some ecosystems need explicit config: pip --require-hashes)47 REVIEW lockfile diffs in PRs (unexpected dep / hash change w/o version change = red flag)48 REGENERATE deliberately (adding/updating deps) — silent drift loses the guarantee49 COMBINE with dependency scanning + typosquat/confusion defences + signing50```5152### Reading the practice5354- **An uncommitted lockfile** = builds can resolve to different dependency trees; reproducibility and the integrity guarantee are lost. Commit it — the foundational step.55- **Using `npm install` (or loose install) in CI** = the lockfile can be silently updated and different packages installed; use `npm ci` (or the strict equivalent) that installs exactly the lockfile and fails on mismatch. The difference between a lockfile that's enforced and one that's decorative.56- **Integrity hash verification off** = the tamper protection is disabled; a swapped or tampered package installs unnoticed. Ensure hash checking is on (pip needs `--require-hashes`).57- **A hash changing without a version change in a lockfile diff** = a red flag — the package content changed for the same version, possibly tampering or a compromised republish. Review lockfile diffs.58- **A silently-drifting lockfile** = the guarantee erodes; regenerate deliberately with review, not accidentally.59- **Committed, strictly-installed, hash-verified, reviewed lockfiles** = reproducible, tamper-resistant dependency installs — the substrate the other supply-chain controls need.6061### Pitfalls6263- **Not committing the lockfile.** Without it committed, everyone resolves differently and the integrity guarantee is gone. Commit it.64- **Loose install commands.** `npm install` silently updates the lockfile; use `npm ci` (and strict equivalents) that enforce the locked state and fail on mismatch. Otherwise the lockfile is decorative.65- **Hash verification disabled.** The integrity hashes are the tamper protection; without verification (e.g. pip without `--require-hashes`), a swapped package installs unnoticed.66- **Ignoring lockfile diffs.** Dependency and hash changes carry supply-chain risk; a hash change without a version change is suspicious. Review lockfile changes in PRs.67- **Silent regeneration.** A lockfile that drifts accidentally loses its guarantee; update it deliberately with review.6869### References7071- npm (`npm ci`, package-lock), pip (`--require-hashes`), Poetry, Cargo lockfile documentation72- The dependency-confusion, typosquat-detection, and vulnerable-dependency-triage skills73- The devsecops dependency-scanning skill74- OpenSSF supply-chain security guidance7576## Inputs77- Relevant source code, logs, network traces, or system specifications.7879## Outputs80- Analysis findings, security audit report, or generated code artifacts.