Patch what you can't upgrade
Remove a CVE from a dependency without changing its version, using Socket Certified Patches in hosted or vendored mode.
Some CVEs can't be fixed by upgrading. The fix is in a breaking major version, a parent package pins the vulnerable release, or the package is no longer maintained. A Socket Certified Patch backports the security fix into the exact version 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, in one of two modes:
| Hosted mode (default) | Vendored mode | |
|---|---|---|
| What it does | Points your lockfile at the patched package on patch.socket.dev | Commits the patched package into your repository under .socket/vendor/ |
| What you commit | The lockfile, and for some package managers one registry setting | .socket/vendor/ and the lockfile |
| What installs need | Network access to patch.socket.dev | Nothing from Socket |
| Choose it when | You want the smallest change and ordinary installs | Your builds are air-gapped, or you want every patched package in your repository |
In both modes your own package manager installs the patched package. There is no install hook, no Socket tool on your build machines, and nothing to reapply after an install.
Patches are yours to keep. A hosted patch link doesn't expire and doesn't depend on your subscription, and you are free to vendor patched packages into your repository and keep using them if you cancel Socket. See How permalinks work.
| 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 |
Before you start:
- Install the CLI. On macOS or Linux, run
curl -fsSL https://install.socket.dev/patch | sh. On Windows, or to install through npm, runnpm install -g @socketsecurity/socket-patch.socket-patch --versionshould print 5.0.0 or later. - A project with a lockfile from the support matrix. You don't need to install dependencies first:
socket-patchreads the lockfile. - For paid patches,
export SOCKET_API_TOKEN=.... Any organization-wide API token works, and no particular scope is needed. A token limited to certain repositories is refused. The organization is worked out from the token; pass--org your-orgto set it yourself. Asocket loginfrom the Socket CLI is picked up too. - Network access to
patches-api.socket.dev(no token) orapi.socket.dev(with a token) when you runsocket-patch, and topatch.socket.devwhen you install in hosted mode or whensocket-patchvendors a package.
socket patchin the Socket CLI is an older versionThe
socket patchcommand that ships with the Socket CLI runs an earlier release of this tool. It has no hosted or vendored mode. Use the standalonesocket-patchbinary for everything on this page. Agent mode andsocket patchcovers the older workflow.
1. Find CVEs that have a patch
In the dashboard, open Alerts and set the Patch Status filter to Patch available. Select the alerts you want and choose Patch to get the commands for each repository.
Across every repository, the API lists the reachable CVEs that have a patch available. The token needs the historical:alerts-list scope. Each response covers part of the list, so keep asking until endCursor comes back empty:
cursor=""
while :; do
page=$(curl -sG -H "Authorization: Bearer $SOCKET_API_TOKEN" \
"https://api.socket.dev/v0/orgs/your-org/historical/alerts" \
--data-urlencode "range=latest" \
--data-urlencode "filters.cvePatchStatus=patch_available" \
--data-urlencode "filters.alertReachabilityType=reachable" \
--data-urlencode "startAfterCursor=$cursor")
jq -r '.items[]? | "\(.repoSlug) \([.artifact.namespace, .artifact.name] | map(select(. != null and . != "")) | join("/"))@\(.artifact.version) \(.alert.props.cveId)"' <<<"$page"
cursor=$(jq -r '.endCursor // empty' <<<"$page")
[ -n "$cursor" ] || break
done | sort -uDrop the filters.alertReachabilityType=reachable line to see every patchable CVE, not just reachable ones. A response can have no rows while a later one has some, so don't stop at an empty page: stop when endCursor is empty.
For one project, preview the patches for what the lockfile pins:
cd /path/to/your-app
socket-patch scan --dry-runThe preview lists each package with a patch, the CVEs the patch fixes, and the files a real run would change. It changes nothing. For a script, add --json:
socket-patch scan --dry-run --json \
| jq -r '.packages[] | "\(.purl) fixes: \(.fixedIds | join(", "))"'
Alerts report patches for some ecosystems onlyThe Patch Status filter and the API query cover npm, PyPI, Go, Maven, NuGet and RubyGems alerts, and only CVEs that have an upstream fixed version. For Cargo and Composer projects, and for a CVE with no upstream fix, use
socket-patch scan --dry-run, which covers every ecosystem in the support matrix.
2. Patch in hosted mode
Hosted mode is the default. Run a scan from the project root, then install as usual:
socket-patch scan # points the lockfile at the patched packages; never prompts
npm ci # or your project's normal install command
socket-patch list # shows each patched package and its mode
scanapplies patches unless you pass--dry-runA bare
socket-patch scanedits your dependency files without asking, and so doessocket-patch scan --json. Use--dry-runwhenever you only want to look.
A patched dependency keeps its name and version. In package-lock.json only two fields change: resolved becomes the link to the patched package, and integrity becomes the hash of the patched package. This is minimist 1.2.2 with the free patch for CVE-2021-44906:
"node_modules/minimist": {
"version": "1.2.2",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.2.tgz",
- "integrity": "sha512-<hash of the upstream package>",
+ "resolved": "https://patch.socket.dev/patch/npm/minimist/1.2.2/<link token>/<patch uuid>/minimist-1.2.2.tgz",
+ "integrity": "sha512-<hash of the patched package>",
"license": "MIT"
}Other package managers get the same change in their own format. In a requirements.txt, the pinned line becomes a direct reference with a hash:
-urllib3==1.26.18
+urllib3 @ https://patch.socket.dev/patch/pypi/urllib3/1.26.18/<link token>/<patch uuid>/urllib3-1.26.18-py2.py3-none-any.whl#sha256=<hash of the patched package>Commit every file the scan reports. For npm that is package-lock.json and an .npmrc with allow-remote=all, which npm 12 and later need before they install a package from a host other than the registry. The support matrix lists what each package manager writes.
To patch one advisory or one package instead of everything the scan finds:
socket-patch get CVE-2021-44906 # by CVE or GHSA ID
socket-patch get pkg:npm/[email protected] # by package URL, for one exact version
socket-patch get minimist # by package name, for every version in the project
socket-patch get your-patch-uuid # by patch UUIDget patches only the versions your project uses. A CVE that affects 27 releases of a package still adds one patch when you have one of them.
3. Or vendor the patches into your repository
Vendored mode stores the patched packages in your repository instead of linking to them:
socket-patch scan --mode vendored # find patches and vendor them in one run
socket-patch vendor # or convert a project that already uses hosted modeHere is what the CLI does:
- It downloads the prebuilt patched package from Socket and checks the archive and the hashes of the patched files.
- It stores the package under
.socket/vendor/<ecosystem>/<patch uuid>/. - It records the patch in a ledger,
.socket/vendor/state.json: which patch was used, a fingerprint of each stored package, and the edits it made, so that they can be undone. The ledger holds no credentials. - It rewrites your dependency files to load the stored package.
.socket/vendor/
├── state.json # ledger
└── npm/
└── <patch uuid>/
├── minimist-1.2.2.tgz # patched package
└── socket-patch.vendor.json # record for this patchThe lockfile change is the same two fields as in hosted mode, with a path in your repository instead of a link:
"node_modules/minimist": {
"version": "1.2.2",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.2.tgz",
- "integrity": "sha512-<hash of the upstream package>",
+ "resolved": "file:.socket/vendor/npm/<patch uuid>/minimist-1.2.2.tgz",
+ "integrity": "sha512-<hash of the patched package>",
"license": "MIT"
}Commit .socket/vendor/ and every dependency file the CLI reports. From then on a checkout installs the patched packages with no access to Socket, no token and no socket-patch binary.
Only the patched packages are vendored. Your other dependencies still come from their usual registry, mirror or cache, so test a clean offline install before you rely on an air-gapped build.
Check the vendored packages in CI. This reads only the repository and needs no network:
socket-patch vendor --check4. Keep patches up to date
New patches are published as new CVEs are disclosed, and a patch can be replaced by a better one. Rerun the scan on a schedule, in a job that opens a pull request with the changed files:
socket-patch scan # add new patches and move to better ones
socket-patch scan --max-new-patches 5 # or add at most five newly patched packages per run
socket-patch scan --min-severity high # or only patch high and critical advisoriesA project keeps the mode it already uses, so the same command works for hosted and vendored projects.
To give every contributor and CI job the same rules, commit them in a socket.yml. Scope patches with socket.yml lists what it can restrict, and Roll patches out gradually shows how to start small.
Three rules decide what a scan applies:
- One patch per package version. When a package has several patches for different advisories, the scan applies the highest ranked one and names the advisories that stay open. Upgrade the package to clear those.
- Most severe first. Patches are ranked by severity, then by the number of advisories they fix, then by publication date.
- Your own patches are left alone. A package you already patch with pnpm, Yarn,
patch-packageor a similar tool is skipped and reported. Pass--allow-patch-conflictsafter you have reviewed the overlap.
5. Prove what you patched
Auditors and vulnerability scanners need a record that a CVE is handled. There are two sources. socket-patch vex writes an OpenVEX document from your project, and Socket's SBOM and VEX exports record the patches it finds in a scan.
OpenVEX from socket-patch vex
socket-patch vexRun it after installing the patched dependencies:
socket-patch vex --output socket.vex.jsonThe document has one statement for each advisory that a patch fixes:
{
"@context": "https://openvex.dev/ns/v0.2.0",
"@id": "urn:uuid:e4759e65-c574-44e7-968b-991981cba53e",
"author": "Socket",
"timestamp": "2026-11-18T15:38:37Z",
"version": 1,
"tooling": "socket-patch 5.1.0",
"statements": [
{
"vulnerability": {
"name": "GHSA-xvch-5gv4-984h",
"aliases": ["CVE-2021-44906"]
},
"timestamp": "2026-11-18T15:38:37Z",
"products": [
{
"@id": "pkg:generic/your-app",
"subcomponents": [{ "@id": "pkg:npm/[email protected]" }]
}
],
"status": "not_affected",
"justification": "inline_mitigations_already_exist",
"impact_statement": "Patched via Socket patch 642d7f02-ebc1-4ab0-99e2-07f5dd8463cb (vendored)"
}
]
}- Status. Each statement says your product is
not_affectedby the advisory, with the justificationinline_mitigations_already_exist. The impact statement names the patch and the mode it is applied in. - Scope. The document covers only what your patches fix. It makes no claim about any other vulnerability, so use it alongside your scanner's own results.
- Product. The product is read from the Git remote or the project file. Pass
--productwhen the project has neither.
Before it writes a statement, the CLI checks that the patch is really in use:
| Mode | What is checked |
|---|---|
| Hosted | The lockfile still points at the patch link, with its integrity hash. Installed copies are checked too when they exist |
| Vendored | The committed package in .socket/vendor/, and the lockfile entry that points at it |
| Agent | The installed files, hashed against the patch record |
A patch that is recorded but no longer used by the project is left out.
| Option | What it does |
|---|---|
-O, --output <PATH> | Write the document to a file. Without it the document is printed to the terminal |
--product <ID> | Set the product the statements describe, for example pkg:generic/your-app |
--no-verify | Skip the file checks. Each statement produced this way ends with "; not verified on disk", and the run warns how many there are |
--doc-id <ID> | Set the document @id. By default every run generates a new one |
--compact | Write compact JSON instead of indented JSON |
--offline | Use only the patch records in the project. A patch with no local record is left out |
-j, --json | Print a machine-readable result of the run. It needs --output, so that the result and the document don't share the terminal |
scan and vendor can write the document in the same run:
socket-patch scan --vex socket.vex.json--vex-product,--vex-no-verify,--vex-doc-idand--vex-compactdo what the matchingvexoptions do.- Nothing is written on a
--dry-run. - If the document can't be produced, the command fails, even when patching succeeded.
- In hosted mode, a document written before you install describes what the lockfile pins. Rerun
socket-patch vexafter the install to have the installed files checked.
Patches in Socket's SBOM and VEX exports
Once Socket scans the patched code and reads the patch from the lockfile, every export of that scan records the patch:
| Export | How a patched package appears |
|---|---|
| CycloneDX | The component carries a pedigree.patches entry with a link to the patch and the advisories it resolves, plus a socket:patch:uuid property |
| SPDX | The package carries a SECURITY external reference of type fix that links the patch |
| OpenVEX | The advisory's statement has the status fixed, and status_notes names the patch |
Export SBOM and VEX shows the exact fields and the commands to pull them.
The two OpenVEX documents use different statuses for the same patch. Socket's export says fixed, and socket-patch vex says not_affected with a justification. Both tell a scanner to stop reporting the CVE.
Scope patches with socket.yml
socket.ymlA socket.yml at the repository root decides what socket-patch scan may patch: which ecosystems, which directories, which packages and how severe an advisory has to be.
version: 2
patches:
enabled: true
ecosystems: [npm, pypi]
minSeverity: high
maxNewPatches: 5
includePaths: ["apps/**", "services/**"]
ignorePaths: ["services/legacy/**"]
ignorePackages: ["pkg:npm/example-package"]Leave out the keys you don't need.
Key under patches | What it does |
|---|---|
enabled | false makes scan report the patches it would apply and change nothing |
ecosystems | Patch only these ecosystems. It takes the names in the command reference, and everyday ones such as python, go, ruby and rust |
includePaths | Patch only the projects whose dependency files match these patterns |
ignorePaths | Skip the projects whose dependency files match these patterns |
packages | Patch only these packages: names or package URLs, with or without an exact version |
ignorePackages | Never patch these packages |
minSeverity | Patch only advisories of at least critical, high, medium or low. A patch whose severity isn't known is skipped whenever this is set |
maxNewPatches | Add at most this many newly patched packages per run. See Roll patches out gradually |
- Paths select projects. A project is a directory with its own lockfile. Patterns use
.gitignoresyntax, relative to the repository root, and ignore case. A later pattern wins over an earlier one, and!brings a path back. A workspace member that shares the root lockfile belongs to the root project, so usepackagesorignorePackagesfor it. - Test directories are skipped already. Projects under
test/,tests/,fixtures/,__fixtures__/andtestdata/are left out unless you name them. To bring one back, negate it:ignorePaths: ["!/e2e/tests/"]. TheprojectIgnorePathslist that the rest of Socket reads from the same file is honored too. - The policy only narrows. It never removes a patch that is already applied, and it does not choose a mode. Use
rollbackorremoveto take a patch out. getis not restricted.socket-patch getapplies what you name, and warns when the policy would have left it out.- One file. Only the
socket.ymlorsocket.yamlat the repository root is read. A policy with a mistake in it stops the scan before it changes anything.
The command line narrows a single run the same way, and the two combine: a run patches what both the file and the options allow.
socket-patch scan apps/web # one project directory
socket-patch scan 'apps/*' # several; quote the pattern so the CLI expands it
socket-patch scan --ecosystems npm,pypi # some ecosystems
socket-patch scan --package lodash # some packages
socket-patch scan --no-socket-yml # ignore the file for this run--min-severity and --max-new-patches replace the values in the file instead of combining with them, and so do the SOCKET_MIN_SEVERITY and SOCKET_MAX_NEW_PATCHES environment variables.
In a monorepo, run scan from the repository root. It patches every project directory at or below the current one, each under its own heading. Maven, Gradle, sbt and NuGet projects are the exception: name their directory, or run scan inside it. With --json, scan one project per run.
Roll patches out gradually
You don't have to take every patch at once. Start narrow, check each batch in review and in your tests, then widen.
- Look before you change anything.
socket-patch scan --dry-runlists what a run would patch. To have a scheduled job report without patching, setenabled: falseinsocket.yml. - Start with the worst.
minSeverity: criticalpatches only critical advisories. Lower it tohigh, thenmedium, as each batch settles. - Start with one part of the repository. Use
includePaths,ecosystemsorpackagesto patch one application, ecosystem or package first, and remove the restriction later. - Cap each batch.
maxNewPatches: 5adds at most five newly patched packages per run, most severe first, and leaves the rest for the next run.
version: 2
patches:
includePaths: ["apps/web/**"] # one application first
minSeverity: critical # then high, then medium
maxNewPatches: 5 # five newly patched packages per runHow the cap works:
- It counts packages that had no patch. Moving a package that is already patched to a better patch doesn't count, so existing patches stay current.
- Each run continues from the last. A run adds the next batch on top of what is already applied. In a pull request workflow, merge one batch before the next run, or the next run proposes the same batch again. The CLI doesn't schedule runs or count open pull requests.
- One budget per run. Several project directories in one run share the cap. Separate runs each get their own.
- Overrides.
socket-patch scan --max-new-patches 0only updates existing patches, and--max-new-patches nonelifts the cap for one run.
A --dry-run shows which patches a run would take and which it would defer. With --json, the same is in the rollout and policy fields.
How permalinks work
A hosted patch link is a permalink to one patched build of one package version. For npm, PyPI and Composer it is the address of the patched package itself:
https://patch.socket.dev/patch/<ecosystem>/<package>/<version>/<link token>/<patch uuid>/<file>Cargo, RubyGems, NuGet and Maven fetch packages through a registry protocol, so their links point at a registry on the same host that serves only that patch:
https://patch.socket.dev/patch-registry/<ecosystem>/<link token>/<patch uuid>/...Go modules are replaced with patch.socket.dev/gopatch/<patch uuid>. That link has no token, because hosted Go patches are free patches.
- The patch UUID names the patch. It is the same ID you see in
socket-patch listand on the patch's page on socket.dev. - The link token records who the link was issued to: your organization, or the public patch service for a free patch fetched without a token. It only unlocks that one patch, and it is meant to be committed with your lockfile.
- The integrity hash next to the link pins the exact bytes. Your package manager refuses an install if the download doesn't match, so a link can never start serving something else.
Links are built to last:
- A link does not expire.
- A link keeps working if your subscription ends. Downloads aren't checked against your plan, so a lockfile you committed keeps installing.
- For npm, PyPI and Composer, a link keeps serving the build it always served when Socket replaces the patch with a better one or retires it. A later
socket-patch scanmoves you to the replacement.
Two cases make a link answer 410 Gone, so that installs fail instead of using it:
- The patch was withdrawn as unsafe, or its package is broken. This applies to every ecosystem.
- The patch was replaced or retired, for Cargo, RubyGems, NuGet, Maven and Go. Their links go through a registry on
patch.socket.dev, which stops serving a patch once it is no longer published.
In both cases, rerun socket-patch scan. It puts the dependency back on the upstream release, and pins the replacement patch when there is one.
If you would rather not depend on a link at all, run socket-patch vendor. It downloads each hosted patch into .socket/vendor/ and repoints the lockfile at the copy in your repository. The vendored packages are ordinary files that you own, and nothing Socket does later changes them.
Undo a patch
socket-patch rollback minimist # put one package back on the upstream release
socket-patch rollback # put every package back
socket-patch remove pkg:npm/[email protected] # the same, addressed by package URL or patch UUID
socket-patch vendor --revert # undo vendoring and delete .socket/vendor/Add --dry-run to any of them to preview. A hosted rollback looks up the upstream registry entry again, so it needs network access. Reinstall afterwards: the installed copy keeps the patched files until the next install.
Support matrix
What socket-patch 5.1 supports in each mode. Supported is covered by release testing. Beta works for the build shapes described in the ecosystem notes; preview with --dry-run and confirm with a real build. Legacy is a lockfile format the package manager itself has retired: it keeps working, with no new features. Manual means the CLI prints the configuration for you to paste.
JavaScript and TypeScript (npm)
| Package manager | Files | Hosted | Vendored | Notes |
|---|---|---|---|---|
| npm | package-lock.json, npm-shrinkwrap.json | ✅ Supported | ✅ Supported | Hosted writes allow-remote=all to .npmrc for npm 12 and later |
| Yarn classic | yarn.lock | ✅ Supported | ✅ Supported | |
| Yarn Berry (4) | yarn.lock | ✅ Supported | ✅ Supported | Yarn 2 and 3 are refused in both modes. Vendored refuses Plug'n'Play projects: switch to the node-modules or pnpm linker. Hosted mode isn't tested with Plug'n'Play |
| pnpm 9 and later | pnpm-lock.yaml | ✅ Supported | ✅ Supported | |
| pnpm 7 and 8 | pnpm-lock.yaml | ✅ Supported | 🕰️ Legacy | Re-lock with pnpm 9 or later when you can |
| pnpm 6 and earlier | pnpm-lock.yaml, shrinkwrap.yaml | ✅ Supported | ❌ Not supported | Hosted needs pnpm 1.43.1 or later |
| Bun | bun.lock (text) | ✅ Supported | ✅ Supported | Vendoring a workspace needs the lock format Bun 1.4 and later write |
| Bun | bun.lockb (binary) | 🕰️ Legacy | 🕰️ Legacy | Bun 1.2 and later write bun.lock. A hosted bun.lockb can't be rolled back by the CLI: restore it from version control |
| vlt 1.0.0-rc.15 and later | vlt-lock.json | ✅ Supported | ✅ Supported | Vendored covers direct dependencies only |
| vlt before 1.0.0-rc.15 | vlt-lock.json | 🕰️ Legacy | 🕰️ Legacy | |
| Rush | common/config/rush/pnpm-lock.yaml | ✅ Supported | ❌ Not supported |
Python (PyPI)
| Package manager | Files | Hosted | Vendored | Notes |
|---|---|---|---|---|
| pip | requirements.txt | ✅ Supported | ✅ Supported | Hash-pinned requirements are supported |
| uv | uv.lock, pylock.toml | ✅ Supported | ✅ Supported | Vendored needs uv 0.2.35 or later |
| Poetry 1.x and 2.x | poetry.lock | ✅ Supported | ✅ Supported | |
| PDM | pdm.lock | ✅ Supported | ✅ Supported | Hosted refuses the lock formats written by PDM 1.8 to 2.7: upgrade to 2.8.1 or later |
| Pipenv | Pipfile.lock | ✅ Supported | ✅ Supported | |
| Hatch 1.x | pyproject.toml, hatch.toml | ✅ Supported | ✅ Supported | Vendored environment dependencies need Hatch 1.2 or later |
Other ecosystems
| Ecosystem | Package manager | Files | Hosted | Vendored | Notes |
|---|---|---|---|---|---|
| Rust | Cargo | Cargo.toml, Cargo.lock | ✅ Supported | ✅ Supported | Hosted needs Cargo 1.68 or later and covers direct dependencies only. Use vendored mode for transitive crates |
| Go | Go modules | go.mod, go.sum, go.work | ✅ Supported | ✅ Supported | Hosted serves free patches only. Use vendored mode for paid patches |
| Ruby | Bundler | Gemfile, Gemfile.lock | ✅ Supported | ✅ Supported | Hosted also handles gems.rb and gems.locked. Bundler 2.6 or later adds a checksum pin |
| .NET | NuGet | packages.lock.json, nuget.config | ✅ Supported | ✅ Supported | |
| PHP | Composer | composer.lock | ✅ Supported | ✅ Supported | |
| Java, Kotlin | Maven | pom.xml | 🚧 Beta | 🚧 Beta | Hosted refuses multi-module builds and versions set through a ${property}: use vendored mode for those |
| Java, Kotlin | Gradle 6.8 and later | Settings files, and lockfiles in hosted mode | 🚧 Beta | 🚧 Beta | Your build scripts aren't edited |
| Scala | sbt 0.13.18 and later | Generated socket-patch.sbt (hosted) or socket-patch-vendor.sbt (vendored) | 🚧 Beta | 🚧 Beta | Run sbt update before the scan |
| Scala | scala-cli | Generated socket-patch.scala | 📋 Manual | 🚧 Beta | Hosted prints a snippet to paste. Vendored supports directory builds on Linux and macOS |
| Scala | Mill | 📋 Manual | ❌ Not supported | Hosted prints a snippet to paste | |
| Deno | Deno | deno.lock | ❌ Not supported | ❌ Not supported | Agent mode only |
What each ecosystem commits
| Ecosystem | Hosted mode changes | Vendored mode changes |
|---|---|---|
| npm | The lock entry's link and integrity hash, plus .npmrc (npm), pnpm-workspace.yaml (pnpm 9 and later) or resolutions in package.json (Yarn Berry) | The lock entry's path and integrity hash, plus an override in package.json for pnpm, Yarn Berry and vlt |
| PyPI | The pinned requirement or lock entry becomes a link with a hash | The entry points at a wheel in .socket/vendor/ |
| Rust | A socket-patch-<uuid> registry for the crate, with the source and checksum in Cargo.lock | A [patch.crates-io] path entry in the root Cargo.toml |
| Go | A replace directive in go.mod (or go.work) and its two checksum lines | A replace directive pointing at the vendored copy |
| Ruby | A source on the gem's line in the Gemfile, with the lock updated to match | A path entry in the Gemfile and Gemfile.lock |
| .NET | A package source and source mapping in nuget.config, with the content hash in packages.lock.json | A folder feed in the repository, with source mapping and the content hash |
| PHP | The download link and checksum in composer.lock | A local path in composer.lock |
| Java, Kotlin (Maven) | The dependency version gains a -socket.<id> suffix that only Socket's repository can satisfy | The same suffix, served from a repository under .socket/vendor/maven2 |
| Gradle, sbt | A generated settings or build file that swaps in the patched package | The same, loading the package from .socket/vendor/ |
Platforms
The CLI ships as a standalone binary for macOS (Apple silicon and Intel), Linux (x86_64, ARM64, 32-bit ARM and i686), Windows (x86_64, ARM64 and i686) and Android (ARM64). socket-patch --update updates a standalone install.
Command reference
socket-patch <command> -h prints the common options for a command, and --help prints all of them.
| Command | What it does |
|---|---|
scan [PATHS]... | Find the patches that apply to the project and apply them. Preview with --dry-run |
get <IDENTIFIER> | Apply the patch for one CVE, GHSA, package URL, package name or patch UUID |
list | Show the project's patches and the mode each one uses |
vendor | Move hosted patches into .socket/vendor/ |
rollback [TARGET]... | Put one package, or every package, back on the upstream release |
remove <TARGET> | Roll back and forget the patches for a package, package URL or patch UUID |
vex | Write an OpenVEX document for the CVEs your patches cover |
repair | Download vendored packages that are missing or damaged, and clean up unused ones |
apply | Reapply agent mode patches after an install |
Options for scan:
| Option | What it does |
|---|---|
--mode <hosted|vendored|agent> | Choose the patch mode. The default is the mode the project already uses, or hosted for a new project |
--package <NAMES> | Only patch these package names or package URLs. Repeat it or separate with commas |
--min-severity <SEVERITY> | Only apply patches that fix an advisory of at least critical, high, medium or low |
--max-new-patches <N> | Add at most N newly patched packages in this run, most severe first. Updates to existing patches don't count |
--no-socket-yml | Ignore the patches policy in socket.yml |
--allow-patch-conflicts | Also patch packages that you already patch with another tool |
--vex <PATH> | Write an OpenVEX document after a successful run |
--no-npm-allow-remote-config | Don't add allow-remote=all to .npmrc in hosted mode |
Options for the other commands:
| Command | Option | What it does |
|---|---|---|
get | --mode <MODE> | The same modes as scan |
get | --all-releases | Fetch every release variant of a package (PyPI wheels and sdists, gem platforms, Maven classifiers), not only the one installed. For a CVE or GHSA, also patch affected versions the project doesn't use |
get | --cve, --ghsa, --id, -p | Say what kind of identifier you passed, when it could be read more than one way |
vendor | --check | Verify the committed packages and their wiring without changing anything and without network access |
vendor | --revert | Undo vendoring and remove .socket/vendor/ |
vendor | --vex <PATH> | Write an OpenVEX document after a successful run |
vex | -O, --output <PATH> | Write the document to a file instead of the terminal |
vex | --product <ID> | Set the product the document describes, when it can't be read from the Git remote or the project file |
vex | --no-verify | Skip the check against installed files. Each statement produced this way says so |
rollback, remove | --preserve-state | Restore the dependency but keep the vendored package for later reuse |
repair | --download-only | Download what is missing and skip the cleanup |
Options every command accepts:
| Option | Environment variable | What it does |
|---|---|---|
--dry-run | SOCKET_DRY_RUN | Preview without changing anything |
-j, --json | SOCKET_JSON | Print a machine-readable result |
--cwd <DIR> | SOCKET_CWD | Run in another directory |
-e, --ecosystems <LIST> | SOCKET_ECOSYSTEMS | Limit the run to npm, pypi, cargo, gem, golang, maven, composer, nuget or deno |
--api-token <TOKEN> | SOCKET_API_TOKEN | Use this API token. Without one, only free patches are available |
-o, --org <SLUG> | SOCKET_ORG_SLUG | Choose the organization. It is worked out from the token when you leave it off |
--offline | SOCKET_OFFLINE | Never use the network, and fail if something has to be downloaded. scan and get can't run offline |
-y, --yes | SOCKET_YES | Skip confirmation prompts |
-v, --verbose | Show more detail | |
-s, --silent | Print errors only | |
--no-telemetry | SOCKET_TELEMETRY_DISABLED | Don't send usage telemetry |
With --json, every command prints one object with command, status, dryRun, events and summary. Check the exit status before you read it.
The CLI reports each command's outcome to Socket as usage telemetry: the command, the CLI version, the operating system, counts such as patches applied and, for get, the patch UUID. It sends no package names, file paths or file contents, apart from what an error message quotes. With a token and an organization the events are tied to that organization, and otherwise they are anonymous. --no-telemetry, SOCKET_TELEMETRY_DISABLED=1 or DO_NOT_TRACK=1 turns it off.
The usage guide and configuration guide on GitHub cover every option.
Agent mode and socket patch
socket patchAgent mode is the original way to apply patches. It edits the installed packages in place instead of changing what the package manager installs. Hosted and vendored modes replace it for every ecosystem except Deno.
socket-patch scan --mode agent # records patches in .socket/ and patches the installed files
socket-patch apply # run this after every dependency install, locally and in CI- Commit
.socket/manifest.jsonand.socket/blobs/. With those committed,socket-patch apply --offlineneeds no network. - A fresh install puts the original files back, so every environment that installs dependencies has to run
socket-patch applyafterwards.socket-patch apply --checkverifies that the patches are in place without changing anything. socket-patch setup, which added a postinstall hook to do this, was removed in version 5.
The socket patch command in the Socket CLI (npm install -g socket) runs an earlier release of this tool. It works only in agent mode, still has setup, and prints JSON with different field names.
To move a project from agent mode to hosted mode:
socket-patch rollback # restore the installed files and remove the agent records
socket-patch scan # patch again in hosted modeThen remove socket patch apply or socket-patch apply from your postinstall script and CI steps, commit the changes, and reinstall.
Verify
-
socket-patch listshows each patched package, its patch and its mode -
git diffon the lockfile shows only the link or path and the integrity hash changing for each patched package - A clean install (
rm -rf node_modules && npm ci) succeeds, and your tests pass - In vendored mode,
socket-patch vendor --checkpasses and a clean install works with the network off -
socket-patch vex --output socket.vex.jsonlists the patched CVEs asnot_affected - Socket's CycloneDX export of the patched scan shows
pedigree.patcheson the patched components - After the next Socket scan of the default branch of an npm, Python, Go, Rust or Ruby project, the patched CVEs carry the Patched badge in the dashboard, and the Patch Status filter lists them under Patch applied
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
No SOCKET_API_TOKEN set ... free patches only | No token was found, so the CLI is using the public patch service | Set SOCKET_API_TOKEN, or run socket login |
A scan finds a patch but reports still unpatched CVEs for the same package | One patch is applied per package version | Upgrade the package to clear the remaining advisories |
Not hosted ...: no lockfile entry pinning it could be rewritten | The package is installed in the environment but isn't pinned in the project's lockfile | Pin it in the lockfile and rerun, or ignore it if it isn't part of the project |
A package with a patch is skipped with user_patch_conflict | You already patch that package with pnpm, Yarn, patch-package or a similar tool | Review the overlap, then rerun with --allow-patch-conflicts |
npm fails with EALLOWREMOTE | npm 12 and later refuse packages from another host by default | Commit the .npmrc the scan wrote, which sets allow-remote=all |
npm fails with E404 or EINTEGRITY on a patched package | replace-registry-host or omit-lockfile-registry-resolved in your npm config rewrites or drops the hosted link | Set replace-registry-host=npmjs and omit-lockfile-registry-resolved=false in the project .npmrc, or use vendored mode |
An install gets 410 Gone from patch.socket.dev | Socket withdrew that patch as unsafe or broken. For Cargo, RubyGems, NuGet, Maven and Go, a patch that was replaced or retired answers the same way | Run socket-patch scan to go back to the upstream release and pick up the replacement |
An install gets 403 from patch.socket.dev | The link was edited, so its token no longer matches the patch | Restore the lockfile from version control, or rerun socket-patch scan |
mode_ambiguous | The project holds patches in more than one mode | Pass --mode hosted or --mode vendored to choose |
| Vendored mode refuses a Yarn Plug'n'Play or Rush project | Those layouts can't load a package from a path in the repository | For Plug'n'Play, set nodeLinker: node-modules in .yarnrc.yml and reinstall. For Rush, use hosted mode |
| A Go patch is refused in hosted mode | Hosted Go links serve free patches only | Use --mode vendored |
| The dashboard still shows Patch available after you patched | The Alerts page shows the default branch and updates on its next scan. Socket reads applied patches from npm, Python, Go, Rust and Ruby lockfiles | Merge the lockfile change to the default branch and let Socket scan it. For other ecosystems, use socket-patch vex as the record |
Reference
- Socket Certified Patches
- About Socket Certified Patches: how patches are tested and delivered
socket-patchCLI: a page for every command- Socket Patch FAQ
socket-patchon GitHub, with the ecosystem notes behind the support matrix- Fix what matters for CVEs that do have an upgrade
- Export SBOM and VEX for the exports Socket produces from a scan
Updated 14 days ago