About Socket Certified Patches
What a certified patch is, how it is tested and how it reaches your project
A Socket Certified Patch backports a security fix into the exact version of a dependency you already use. The version in your manifest and lockfile stays the same, so nothing else in the dependency tree moves. You apply patches with the socket-patch CLI.
When to patch and when to upgrade
Upgrading is the right fix when it is cheap. Patch when it is not:
- The fix is only in a new major version with breaking changes.
- Another package pins the vulnerable release and you can't move it.
- The package is no longer maintained and will never ship a fix.
- You need the CVE gone today and the upgrade needs a release cycle.
A patch is not a reason to stop upgrading. It removes the CVE now and lets you upgrade on your own schedule. socket fix handles the CVEs that do have a clean upgrade.
Never break your code
A patch that fixes a CVE and breaks your build is not a fix. Every patch is reviewed by an engineer, and it is tested against the original package before it is published:
- Regression testing. A test suite is built for the package from the maintainer's own tests for the fix, plus new ones. It has to pass on the original package and on the patched one, so the patch changes nothing your code relies on.
- Differential testing. The original and the patched package are run side by side and compared. They have to behave the same everywhere except the vulnerability.
- Compatibility testing. The tests run on the runtime the package release supports, and each patch is reviewed for breaking changes. A patch must not change a package's public behavior.
- Integration and end-to-end testing. The package is exercised the way an application uses it, not only function by function.
- Proof-of-concept validation. A working exploit for the CVE has to succeed against the original package and fail against the patch.
- Benchmarks. Run time and memory use are measured before and after, so a fix doesn't slow the package down.
A patch changes only the vulnerable code, and it stays faithful to the maintainer's fix.
The metrics behind each patch
Socket publishes the measurements it takes for a patch on the patch's page on socket.dev, under Verification. Each one compares the package before and after the patch.
| Metric | What it shows |
|---|---|
| Exploits | How many proof-of-concept exploits reproduced against the original package, and how many the patch blocks |
| Tests | How many tests pass on the original package and on the patched one |
| Run time, typical use | How long a script that uses the package the way a typical application would takes to run |
| Run time, patched code path | How long a workload that repeatedly runs the code the patch changed takes to run |
| Peak memory | The highest memory use of the process while running those workloads |
| Patch size | Lines, files and functions changed |
- How benchmarks are run. The original and the patched package are each timed 9 to 15 times in a sandbox, alternating between them, and the median times are compared. Memory is measured over 3 runs of each. The figures are approximate: results vary between runs and environments.
- Test coverage. A suite that passes proves little if it never runs the patched code. Socket measures coverage of the fix by running the suite against weakened variants of the patch, each with part of the fix removed. A variant the tests don't catch is a gap, and the suite is extended until it is closed.
- The same page lists the CVEs the patch fixes and shows its diff, so you can read exactly what changes before you apply it.
How a patch reaches your project
socket-patch changes what your package manager installs. It does not run during your build.
- Hosted mode points the lockfile entry at the patched package on
patch.socket.dev. Two fields change: the link and the integrity hash. - Vendored mode commits the patched package into your repository under
.socket/vendor/and points the lockfile at that copy. Installs then need nothing from Socket.
In both modes your own package manager does the install, with no install hook and no Socket tool on your build machines. The integrity hash pins the exact bytes, so an install fails if the package is not the one you committed to. Patch what you can't upgrade walks through both.
Patches are yours to keep
- A hosted link doesn't expire and doesn't depend on your subscription. A lockfile you committed keeps installing if you cancel.
- You may vendor any patch and keep it. Vendored packages are ordinary files in your repository, and nothing Socket does later changes them.
Socket stops serving a link in two cases, so that installs fail instead of using a bad package: when a patch is withdrawn as unsafe or broken, and, for Cargo, RubyGems, NuGet, Maven and Go, when a patch is replaced or retired. Rerunning socket-patch scan moves the project to the replacement. How permalinks work has the detail.
Free and paid
| Tier | Patches included | What you need |
|---|---|---|
| Free | Patches for critical CVEs | Nothing. No account and no token |
| Paid | Patches for all CVEs, at every severity | An API token for an organization with Socket Patches |
What happens over time
- New patches. Patches are published as new CVEs are disclosed. Rerun
socket-patch scanon a schedule to pick them up. - Better patches. One patch applies per package version. When a patch that fixes more arrives, a later scan moves you to it.
- Upgrades. A patch belongs to one exact version. When you upgrade the package, the new version installs from the registry as usual, and the next scan tells you whether it needs a patch of its own.
- Several CVEs in one package. A scan applies the highest ranked patch and names the advisories that stay open. Upgrade the package to clear those.
Where patches show up in Socket
- Alerts. A CVE with a patch carries a Patch available badge, and a CVE you have patched carries a Patched badge once Socket scans the default branch. The Patch Status filter and policy condition have three values: No patch, Patch available and Patch applied. A patched CVE is listed under Patch applied.
- Exports. The CycloneDX, SPDX and OpenVEX exports of a scan record each applied patch. See Export SBOM and VEX.
- Your own scanner.
socket-patch vexwrites an OpenVEX document from your project that tells any VEX-aware scanner which CVEs are covered.
What Socket sees
To find patches, the CLI sends the names and versions of your dependencies to the patch service. It never sends source code. It also reports each command's outcome as usage telemetry, which --no-telemetry turns off. With --mode vendored and committed packages, installs contact Socket for nothing.
Next
- Patch what you can't upgrade: the step-by-step guide
socket-patchCLI: every command- Socket Patch FAQ
Updated about 2 hours ago