Remediation PRs

Let Socket open pull requests that remediate vulnerabilities, by patching the version you already use or by upgrading to one that isn't vulnerable.

Remediation PRs let Socket open pull requests that remediate vulnerabilities in your repositories. Socket prepares the change, opens the pull request through the Socket GitHub App, and links it back to the alert. You review and merge it like any other pull request.

There are two kinds of remediation PR.

Patch PRUpgrade PR
What it doesApplies Socket Certified Patches, which remove the vulnerability from the version you already use.Moves the dependency to a version that isn't vulnerable.
Version changesNoneYes
How manyOne rolling pull request per repository, which Socket keeps up to date.One pull request per vulnerability.
Branchsocket/patch/<base branch>socket/fix/<GHSA ID>
How it startsAn automationAn automation, or a click on a vulnerability alert
The Remediation PRs settings page with the Automations tab, the list of automations and the Add automation button.

Before you start

  • The Socket GitHub App. Remediation PRs work on repositories connected through Socket for GitHub. Repositories that are only scanned through the Socket CLI or the API can still be remediated locally, with the socket-patch CLI for patches and socket fix for upgrades.
  • Write access for the app. The Socket GitHub App needs Contents and Pull requests write access on the repository. See GitHub App permissions.
  • Access to the remediation method. Team plans and above include upgrade PRs. If patch PRs are enabled for your organization, you can use free patches for critical vulnerabilities. The Socket Patches add-on gives you access to paid patches as well.
  • Private code access. Both methods require private code access. Free, Team and Business plans include it. On Enterprise, your organization needs the Private code access add-on.
  • A default branch scan. Socket computes patches and upgrades against the repository's default branch.

Supported ecosystems

EcosystemUpgrade PRsPatch PRs
npmYesYes
PyPIYesYes
RubyGemsYesYes
GoYesYes
MavenYesNot yet
NuGetYesNot yet
CargoYesNot yet

Enable Remediation PRs

An organization owner or admin can turn on Remediation PRs for the whole organization.

  1. In the Socket dashboard, go to Settings → Alerts → Remediation PRs.
  2. Click Enable Remediation PRs to open the disclaimer.
  3. Read the disclaimer, check I agree that Socket may temporarily store repository clones, then click Agree and enable.
The Remediation PRs settings page while the feature is off, with the Enable Remediation PRs button.

To open a pull request, Socket temporarily clones the repository into an isolated sandbox and deletes the clone once the pull request has been opened or the attempt has failed. This applies to both patch PRs and upgrade PRs. Accepting the disclaimer means you accept that Socket holds these temporary clones.

The Enable Remediation PRs dialog with the agreement checkbox and the Agree and enable button.

Disable Remediation PRs

On the Remediation PRs settings page, open the Settings tab. It shows who enabled Remediation PRs and when, and View disclaimer shows the text they accepted.

The Settings tab with the Disclaimer card and the Disable Remediation PRs card.

To turn Remediation PRs off, click Disable Remediation PRs and confirm. Socket stops opening and updating pull requests for all automations, including queued requests. Pull requests that are already open stay open, and your automations stay saved. Turning Remediation PRs back on asks you to accept the disclaimer again.

The confirmation dialog for disabling Remediation PRs.

Automations

An automation opens remediation PRs for you when a matching vulnerability shows up on a repository's default branch. Automations only run while Remediation PRs are enabled.

To create one, go to Settings → Alerts → Remediation PRs, open the Automations tab and click Add automation.

The Automations tab lists your automations with the repositories each one applies to, its method and its status. Use Filter and Search to narrow the list. To change or remove an automation, open the menu at the end of its row and choose Edit or Delete.

The Add automation dialog for a Patch or upgrade automation, with matching conditions, advanced options and the Start with setting.

Choose a remediation method

Add automation creates a Patch or upgrade automation. To use another method, click the arrow next to the button and pick one from the menu. The dialog names the method at the top.

The Add automation button with its method menu open.
MethodWhat Socket does
Patch or upgradePatches keep your current version. If no patch exists, or your plan doesn't include it, Socket opens an upgrade PR.
Patch onlySocket never changes versions. Vulnerabilities without a patch are left for you to handle.
Upgrade onlyOne upgrade PR per vulnerability.

The methods you can pick depend on your plan.

Choose what to match

An automation matches on:

  • Priority: Socket's composite priority for the finding, from Critical to Low.
  • Repositories: all repositories, or the ones you pick. A repository shows up in the list once the Socket GitHub App can access it.
  • Ecosystems

Show advanced options adds:

  • Severity: the severity of the vulnerability itself.
  • Reachability
  • Minimum EPSS score (%): only alerts whose exploit probability is at least this value.
  • Known exploited vulnerabilities only: only alerts listed in the CISA KEV catalog.

These conditions apply to both patch and upgrade PRs. For example, if you select a repository, npm and High priority, that automation contributes only matching npm findings from that repository to the patch PR. A condition you leave empty matches anything.

Choose where to start

Automations that patch have a Start with setting.

  • Future findings only: patch vulnerabilities found from now on. You can include existing ones later.
  • Existing and future findings: also patch the vulnerabilities you have today.

Under both options, a repository you connect after creating the automation has every matching vulnerability patched, including the ones it already had when you connected it.

With Existing and future findings selected, Run preview shows which repositories and findings the automation would change before you save it.

How automations behave

  • An automation only looks at alerts on a repository's default branch that your security policy doesn't ignore.
  • Each repository and advisory pair is attempted once for an upgrade PR. If the attempt fails or you close the pull request, the automation doesn't try that pair again. You can still open one from the alert.
  • Upgrade PRs from automations count toward the open pull request limit. Patch PRs are still opened and updated when the limit is reached.
  • Use the Status toggle in the list, or Active in the dialog, to pause an automation. If no other active patch automation covers the repository, the patch PR stays open and Socket stops updating it. A build already in progress can finish with the previous settings.
  • If you narrow the conditions, Socket rebuilds the patch PR using the findings that still match active automations. If no active patch automation covers the repository after the change, its patch PR stays open and Socket stops updating it.
  • When you delete an automation, the confirmation dialog lets you close open patch PRs that no other active patch automation covers. Leave the box unchecked to keep them open. Upgrade PRs stay open.

Open an upgrade PR from an alert

Once Remediation PRs are enabled, Owners, Admins, Members and Contributors can open an upgrade PR straight from a vulnerability alert.

  1. Open a vulnerability alert on the Alerts page.
  2. Go to the Remediation tab.
  3. Click Open upgrade PR.

Socket upgrades the dependency and regenerates the lockfiles in an isolated sandbox. This usually takes 5 to 15 minutes, and longer for large repositories. When the pull request opens, the button turns into View upgrade PR.

Open upgrade PR in the Socket Fix section of a vulnerability alert.

A few things to know:

  • One pull request per vulnerability. If an upgrade PR for the advisory is already open on the repository, Socket links you to it.
  • Draft pull requests. When Socket can't regenerate every lockfile on its side, for example because a package comes from a private registry, it opens the pull request as a draft. The description explains what to run locally to finish it.
  • Partial upgrades. When Socket can't remove every vulnerable version, the description says so and lists what it left out and why.
  • Closed pull requests. If you close an upgrade PR without merging it, Socket treats the upgrade as declined. Use Re-open upgrade PR on the alert to get a new one.
  • Open pull request limit. An organization can have at most 10 upgrade PRs open or in progress at once. Merge or close some to make room. Patch PRs don't count toward this limit. If you need a higher limit, contact your Socket sales representative.
An upgrade PR description showing the change to jsonwebtoken 5.0.0 and the two files it updates.

Patch PRs

Socket keeps one patch PR per repository. Each time there's something new to patch, Socket updates that same pull request, so you don't get a new pull request per vulnerability. When a run shows there's nothing left to patch, Socket closes it.

The pull request description lists the patched packages with their advisories and severity, the files that changed, and any package manager setting Socket had to add so the patched packages install.

A patch PR description listing the advisory for qs, the changed lockfile and two packages left unpatched.

Socket only updates the branch while it holds Socket's own commits:

  • If you push to the patch PR, Socket stops updating it and leaves one comment saying so. Your commits, the title and the description stay as they are. After you merge or close it, Socket opens a new one when there's more to patch.
  • If you close the patch PR without merging, Socket treats that set of patches as declined. It opens a new patch PR when the set of patches changes.
  • If you merge the patch PR, the vulnerabilities show as patched after the next scan of the default branch.

Repositories that commit Socket patch files under .socket/vendor can't get patch PRs. Remove those files from the default branch first.

Track remediation PRs

Open Remediation in the dashboard sidebar. The Patch PRs and Upgrade PRs tabs show what Socket did and why.

While Remediation PRs are off, the page says so. Owners and admins get an Open in Settings button that takes them to the settings page.

The Remediation page while Remediation PRs are off, with the Open in Settings button.

Patch PRs tab

Each row is a repository and base branch, with Latest run, Pull request and Last update. The Pull request column shows the state of the patch PR and the automations that cover the repository.

StateMeaning
No PR yetSocket hasn't opened a patch PR for this repository.
OpenThe patch PR is open and waiting for review.
Merged, waiting for scanYou merged it. Socket is waiting for a scan of the default branch.
MergedSocket has scanned the default branch since the PR was merged.
ClosedThe patch PR was closed without being merged.

Latest run shows how the most recent run for the repository went.

Latest runMeaning
QueuedThe run is waiting to start.
BuildingSocket is preparing the patches.
Opened PRThe run opened a new patch PR.
Updated PRThe run updated the open patch PR.
Left PR unchangedThe open patch PR already holds everything there is to patch.
Stopped updating PRSocket closed the patch PR and left a comment on it that says why.
Nothing to patchNo vulnerability needed a patch, and no patch PR was open.
FailedSocket couldn't finish the run. Click Why? for the reason.
SkippedSocket left the repository alone, for example because the last patch PR was closed without being merged. Click Why? for the reason.

Use History to see recent runs for the repository. Each run shows what started it, for example Automation saved, Alert changed, Scan finished or Scheduled check, and how many packages weren't patched.

Click Run now to have Socket check the repository for patches right away. An active automation has to cover the repository, and there's a short wait between runs.

The Patch PRs tab on the Remediation page with History open for a patch PR.

Upgrade PRs tab

Open upgrade pull requests shows how many of the organization's upgrade PRs are open or being prepared, out of the limit. A banner appears when three or fewer are left, and when the limit is reached.

Each attempt has a row with Repository, Attempt status, Pull request and Last update. The advisory is listed under the repository. The Pull request column also shows who requested the upgrade or which automation started it.

Attempt statusMeaning
QueuedThe attempt is waiting to start.
Applying upgradeSocket is upgrading the dependency.
Finalizing upgradeSocket is finishing the upgrade and opening the pull request.
Opened PRThe pull request is open and ready for review.
Opened draft PRThe pull request opened as a draft because a lockfile needs to be finalized locally.
FailedSocket couldn't open a pull request. Click Why? for the reason.
SkippedSocket didn't open a pull request, for example because one was already open.
No patch availableA Patch or upgrade automation found no usable patch for a vulnerability that was already there when the automation was created.
The Upgrade PRs tab on the Remediation page with the open upgrade pull request counter and attempts in different states.

Troubleshooting

What you seeWhat to do
There's no Open upgrade PR button on the alert.The feature isn't available to your organization or your plan, or your role can't open upgrade PRs.
"An organization admin has to enable Remediation PRs in Settings before Socket can open one."Ask an organization admin to enable Remediation PRs.
The repository isn't connected through the Socket GitHub App.Install the Socket GitHub App on the repository, or remediate locally with the socket-patch CLI or socket fix.
The Socket GitHub App needs Contents and Pull requests write access.Update the app's permissions on GitHub. See GitHub App permissions.
"Open upgrade PR limit reached for this organization"Merge or close some of the open upgrade PRs, or contact your Socket sales representative to request a higher limit.
Socket can't open upgrade PRs for this package's ecosystem yet.See Supported ecosystems.
Socket found no upgrade path for the alert.The default branch may differ from the scanned commit, or no safe version fits your other dependencies. Trying again gives the same result until the repository changes.
The directories the upgrade changes have no lockfile Socket can update.Commit the lockfile your package manager writes to the default branch, then try again.
The attempt timed out.Large repositories can time out on the first attempt. Try again from the alert.
The repository’s GitHub connection changed after the upgrade was requested.Check the repository’s GitHub connection, then request the upgrade again.
Socket held back a partially written lockfile.Use socket fix locally to apply the upgrade and regenerate the lockfile.
The patch PR branch already exists and belongs to someone else.Review the existing branch with its owner. Once the branch name is available, Socket can open a patch PR.

Related


Did this page help you?