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 doesPoints your lockfile at the patched package on patch.socket.devCommits the patched package into your repository under .socket/vendor/
What you commitThe lockfile, and for some package managers one registry setting.socket/vendor/ and the lockfile
What installs needNetwork access to patch.socket.devNothing from Socket
Choose it whenYou want the smallest change and ordinary installsYour 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.

TierPatches includedWhat you need
FreePatches for critical CVEsNothing. No account and no token
PaidPatches for all CVEs, at every severityAn 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, run npm install -g @socketsecurity/socket-patch. socket-patch --version should print 5.0.0 or later.
  • A project with a lockfile from the support matrix. You don't need to install dependencies first: socket-patch reads 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-org to set it yourself. A socket login from the Socket CLI is picked up too.
  • Network access to patches-api.socket.dev (no token) or api.socket.dev (with a token) when you run socket-patch, and to patch.socket.dev when you install in hosted mode or when socket-patch vendors a package.
📘

socket patch in the Socket CLI is an older version

The socket patch command that ships with the Socket CLI runs an earlier release of this tool. It has no hosted or vendored mode. Use the standalone socket-patch binary for everything on this page. Agent mode and socket patch covers 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 -u

Drop 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-run

The 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 only

The 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
🚧

scan applies patches unless you pass --dry-run

A bare socket-patch scan edits your dependency files without asking, and so does socket-patch scan --json. Use --dry-run whenever 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 UUID

get 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 mode

Here is what the CLI does:

  1. It downloads the prebuilt patched package from Socket and checks the archive and the hashes of the patched files.
  2. It stores the package under .socket/vendor/<ecosystem>/<patch uuid>/.
  3. 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.
  4. 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 patch

The 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 --check

4. 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 advisories

A 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-package or a similar tool is skipped and reported. Pass --allow-patch-conflicts after 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

Run it after installing the patched dependencies:

socket-patch vex --output socket.vex.json

The 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_affected by the advisory, with the justification inline_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 --product when the project has neither.

Before it writes a statement, the CLI checks that the patch is really in use:

ModeWhat is checked
HostedThe lockfile still points at the patch link, with its integrity hash. Installed copies are checked too when they exist
VendoredThe committed package in .socket/vendor/, and the lockfile entry that points at it
AgentThe installed files, hashed against the patch record

A patch that is recorded but no longer used by the project is left out.

OptionWhat 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-verifySkip 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
--compactWrite compact JSON instead of indented JSON
--offlineUse only the patch records in the project. A patch with no local record is left out
-j, --jsonPrint 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-id and --vex-compact do what the matching vex options 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 vex after 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:

ExportHow a patched package appears
CycloneDXThe component carries a pedigree.patches entry with a link to the patch and the advisories it resolves, plus a socket:patch:uuid property
SPDXThe package carries a SECURITY external reference of type fix that links the patch
OpenVEXThe 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

A 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 patchesWhat it does
enabledfalse makes scan report the patches it would apply and change nothing
ecosystemsPatch only these ecosystems. It takes the names in the command reference, and everyday ones such as python, go, ruby and rust
includePathsPatch only the projects whose dependency files match these patterns
ignorePathsSkip the projects whose dependency files match these patterns
packagesPatch only these packages: names or package URLs, with or without an exact version
ignorePackagesNever patch these packages
minSeverityPatch only advisories of at least critical, high, medium or low. A patch whose severity isn't known is skipped whenever this is set
maxNewPatchesAdd 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 .gitignore syntax, 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 use packages or ignorePackages for it.
  • Test directories are skipped already. Projects under test/, tests/, fixtures/, __fixtures__/ and testdata/ are left out unless you name them. To bring one back, negate it: ignorePaths: ["!/e2e/tests/"]. The projectIgnorePaths list 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 rollback or remove to take a patch out.
  • get is not restricted. socket-patch get applies what you name, and warns when the policy would have left it out.
  • One file. Only the socket.yml or socket.yaml at 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.

  1. Look before you change anything. socket-patch scan --dry-run lists what a run would patch. To have a scheduled job report without patching, set enabled: false in socket.yml.
  2. Start with the worst. minSeverity: critical patches only critical advisories. Lower it to high, then medium, as each batch settles.
  3. Start with one part of the repository. Use includePaths, ecosystems or packages to patch one application, ecosystem or package first, and remove the restriction later.
  4. Cap each batch. maxNewPatches: 5 adds 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 run

How 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 0 only updates existing patches, and --max-new-patches none lifts 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 list and 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 scan moves 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 managerFilesHostedVendoredNotes
npmpackage-lock.json, npm-shrinkwrap.json✅ Supported✅ SupportedHosted writes allow-remote=all to .npmrc for npm 12 and later
Yarn classicyarn.lock✅ Supported✅ Supported
Yarn Berry (4)yarn.lock✅ Supported✅ SupportedYarn 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 laterpnpm-lock.yaml✅ Supported✅ Supported
pnpm 7 and 8pnpm-lock.yaml✅ Supported🕰️ LegacyRe-lock with pnpm 9 or later when you can
pnpm 6 and earlierpnpm-lock.yaml, shrinkwrap.yaml✅ Supported❌ Not supportedHosted needs pnpm 1.43.1 or later
Bunbun.lock (text)✅ Supported✅ SupportedVendoring a workspace needs the lock format Bun 1.4 and later write
Bunbun.lockb (binary)🕰️ Legacy🕰️ LegacyBun 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 latervlt-lock.json✅ Supported✅ SupportedVendored covers direct dependencies only
vlt before 1.0.0-rc.15vlt-lock.json🕰️ Legacy🕰️ Legacy
Rushcommon/config/rush/pnpm-lock.yaml✅ Supported❌ Not supported

Python (PyPI)

Package managerFilesHostedVendoredNotes
piprequirements.txt✅ Supported✅ SupportedHash-pinned requirements are supported
uvuv.lock, pylock.toml✅ Supported✅ SupportedVendored needs uv 0.2.35 or later
Poetry 1.x and 2.xpoetry.lock✅ Supported✅ Supported
PDMpdm.lock✅ Supported✅ SupportedHosted refuses the lock formats written by PDM 1.8 to 2.7: upgrade to 2.8.1 or later
PipenvPipfile.lock✅ Supported✅ Supported
Hatch 1.xpyproject.toml, hatch.toml✅ Supported✅ SupportedVendored environment dependencies need Hatch 1.2 or later

Other ecosystems

EcosystemPackage managerFilesHostedVendoredNotes
RustCargoCargo.toml, Cargo.lock✅ Supported✅ SupportedHosted needs Cargo 1.68 or later and covers direct dependencies only. Use vendored mode for transitive crates
GoGo modulesgo.mod, go.sum, go.work✅ Supported✅ SupportedHosted serves free patches only. Use vendored mode for paid patches
RubyBundlerGemfile, Gemfile.lock✅ Supported✅ SupportedHosted also handles gems.rb and gems.locked. Bundler 2.6 or later adds a checksum pin
.NETNuGetpackages.lock.json, nuget.config✅ Supported✅ Supported
PHPComposercomposer.lock✅ Supported✅ Supported
Java, KotlinMavenpom.xml🚧 Beta🚧 BetaHosted refuses multi-module builds and versions set through a ${property}: use vendored mode for those
Java, KotlinGradle 6.8 and laterSettings files, and lockfiles in hosted mode🚧 Beta🚧 BetaYour build scripts aren't edited
Scalasbt 0.13.18 and laterGenerated socket-patch.sbt (hosted) or socket-patch-vendor.sbt (vendored)🚧 Beta🚧 BetaRun sbt update before the scan
Scalascala-cliGenerated socket-patch.scala📋 Manual🚧 BetaHosted prints a snippet to paste. Vendored supports directory builds on Linux and macOS
ScalaMill📋 Manual❌ Not supportedHosted prints a snippet to paste
DenoDenodeno.lock❌ Not supported❌ Not supportedAgent mode only

What each ecosystem commits

EcosystemHosted mode changesVendored mode changes
npmThe 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
PyPIThe pinned requirement or lock entry becomes a link with a hashThe entry points at a wheel in .socket/vendor/
RustA socket-patch-<uuid> registry for the crate, with the source and checksum in Cargo.lockA [patch.crates-io] path entry in the root Cargo.toml
GoA replace directive in go.mod (or go.work) and its two checksum linesA replace directive pointing at the vendored copy
RubyA source on the gem's line in the Gemfile, with the lock updated to matchA path entry in the Gemfile and Gemfile.lock
.NETA package source and source mapping in nuget.config, with the content hash in packages.lock.jsonA folder feed in the repository, with source mapping and the content hash
PHPThe download link and checksum in composer.lockA local path in composer.lock
Java, Kotlin (Maven)The dependency version gains a -socket.<id> suffix that only Socket's repository can satisfyThe same suffix, served from a repository under .socket/vendor/maven2
Gradle, sbtA generated settings or build file that swaps in the patched packageThe 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.

CommandWhat 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
listShow the project's patches and the mode each one uses
vendorMove 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
vexWrite an OpenVEX document for the CVEs your patches cover
repairDownload vendored packages that are missing or damaged, and clean up unused ones
applyReapply agent mode patches after an install

Options for scan:

OptionWhat 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-ymlIgnore the patches policy in socket.yml
--allow-patch-conflictsAlso patch packages that you already patch with another tool
--vex <PATH>Write an OpenVEX document after a successful run
--no-npm-allow-remote-configDon't add allow-remote=all to .npmrc in hosted mode

Options for the other commands:

CommandOptionWhat it does
get--mode <MODE>The same modes as scan
get--all-releasesFetch 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, -pSay what kind of identifier you passed, when it could be read more than one way
vendor--checkVerify the committed packages and their wiring without changing anything and without network access
vendor--revertUndo 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-verifySkip the check against installed files. Each statement produced this way says so
rollback, remove--preserve-stateRestore the dependency but keep the vendored package for later reuse
repair--download-onlyDownload what is missing and skip the cleanup

Options every command accepts:

OptionEnvironment variableWhat it does
--dry-runSOCKET_DRY_RUNPreview without changing anything
-j, --jsonSOCKET_JSONPrint a machine-readable result
--cwd <DIR>SOCKET_CWDRun in another directory
-e, --ecosystems <LIST>SOCKET_ECOSYSTEMSLimit the run to npm, pypi, cargo, gem, golang, maven, composer, nuget or deno
--api-token <TOKEN>SOCKET_API_TOKENUse this API token. Without one, only free patches are available
-o, --org <SLUG>SOCKET_ORG_SLUGChoose the organization. It is worked out from the token when you leave it off
--offlineSOCKET_OFFLINENever use the network, and fail if something has to be downloaded. scan and get can't run offline
-y, --yesSOCKET_YESSkip confirmation prompts
-v, --verboseShow more detail
-s, --silentPrint errors only
--no-telemetrySOCKET_TELEMETRY_DISABLEDDon'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

Agent 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.json and .socket/blobs/. With those committed, socket-patch apply --offline needs no network.
  • A fresh install puts the original files back, so every environment that installs dependencies has to run socket-patch apply afterwards. socket-patch apply --check verifies 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 mode

Then remove socket patch apply or socket-patch apply from your postinstall script and CI steps, commit the changes, and reinstall.

Verify

  • socket-patch list shows each patched package, its patch and its mode
  • git diff on 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 --check passes and a clean install works with the network off
  • socket-patch vex --output socket.vex.json lists the patched CVEs as not_affected
  • Socket's CycloneDX export of the patched scan shows pedigree.patches on 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

SymptomCauseFix
No SOCKET_API_TOKEN set ... free patches onlyNo token was found, so the CLI is using the public patch serviceSet SOCKET_API_TOKEN, or run socket login
A scan finds a patch but reports still unpatched CVEs for the same packageOne patch is applied per package versionUpgrade the package to clear the remaining advisories
Not hosted ...: no lockfile entry pinning it could be rewrittenThe package is installed in the environment but isn't pinned in the project's lockfilePin 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_conflictYou already patch that package with pnpm, Yarn, patch-package or a similar toolReview the overlap, then rerun with --allow-patch-conflicts
npm fails with EALLOWREMOTEnpm 12 and later refuse packages from another host by defaultCommit the .npmrc the scan wrote, which sets allow-remote=all
npm fails with E404 or EINTEGRITY on a patched packagereplace-registry-host or omit-lockfile-registry-resolved in your npm config rewrites or drops the hosted linkSet 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.devSocket withdrew that patch as unsafe or broken. For Cargo, RubyGems, NuGet, Maven and Go, a patch that was replaced or retired answers the same wayRun socket-patch scan to go back to the upstream release and pick up the replacement
An install gets 403 from patch.socket.devThe link was edited, so its token no longer matches the patchRestore the lockfile from version control, or rerun socket-patch scan
mode_ambiguousThe project holds patches in more than one modePass --mode hosted or --mode vendored to choose
Vendored mode refuses a Yarn Plug'n'Play or Rush projectThose layouts can't load a package from a path in the repositoryFor Plug'n'Play, set nodeLinker: node-modules in .yarnrc.yml and reinstall. For Rush, use hosted mode
A Go patch is refused in hosted modeHosted Go links serve free patches onlyUse --mode vendored
The dashboard still shows Patch available after you patchedThe Alerts page shows the default branch and updates on its next scan. Socket reads applied patches from npm, Python, Go, Rust and Ruby lockfilesMerge the lockfile change to the default branch and let Socket scan it. For other ecosystems, use socket-patch vex as the record

Reference


Did this page help you?