Fix Dependabot Security Alert
Goal: given a Dependabot alert URL ($ARGUMENTS), eliminate the vulnerable version from the dependency tree (or apply the documented mitigation when a fix is not yet installable), verify nothing breaks, then commit, push to a new branch, and open a PR. Do not merge the PR. Do not dismiss the alert unless explicitly instructed.
1. Understand the alert
- Parse owner, repo, and alert number from the URL:
https://github.com/<owner>/<repo>/security/dependabot/<number>. - Fetch the alert details:
Extract: the vulnerable package and ecosystem, affected version range, first patched version, severity, CVE/GHSA IDs, the manifest file (e.g.gh api repos/<owner>/<repo>/dependabot/alerts/<number>yarn.lock), and whether the dependency scope isruntimeordevelopment. - Read the advisory itself for context and workarounds:
gh api /advisories/<ghsa-id> - Classify the situation, because it determines the whole strategy:
- Direct dependency, patched version exists: simple bump in
package.json+ lockfile. - Transitive dependency, patched version exists: the parent may not accept it yet. You will need a resolution/override, or a parent bump that pulls the fixed version.
- No installable patched version (Dependabot says it "cannot update X to a non-vulnerable version"): check whether the fixed version was released since the alert; if truly not installable, fall back to the advisory's documented workaround or assess exposure.
- Direct dependency, patched version exists: simple bump in
2. Check out the repo and create a working branch
If not already inside a clone of the repo, clone it first. Then:
git checkout <default-branch> && git pull
git checkout -b fix/dependabot-<number>-<package>Detect the package manager from the lockfile present (pnpm-lock.yaml, yarn.lock, package-lock.json) and use only that one for every install and lockfile operation.
3. Map the dependency path
Find out exactly how the vulnerable package enters the tree:
# yarn classic
yarn why <package>
# yarn berry
yarn why <package> -R
# npm
npm ls <package> --all
# pnpm
pnpm why <package>Note every parent chain. A vulnerable package can be introduced by several parents at several versions; all paths must end up on a patched version (or be removed).
4. Choose the remediation, in order of preference
- Bump the direct dependency to a version at or above the first patched version, respecting semver in
package.json. Prefer the latest stable within the same major; only cross a major if required to reach the patch, and treat that as a migration (read release notes first). - Bump the parent(s) of a transitive dependency if a newer parent release pulls in the fixed version. Check the parent's changelog or its
package.jsonon the registry to confirm before bumping. - Force the transitive version when parents lag behind:
- yarn (classic and berry):
"resolutions": { "<package>": ">=<patched>" }inpackage.json - npm:
"overrides": { "<package>": ">=<patched>" } - pnpm:
"pnpm": { "overrides": { "<package>": ">=<patched>" } }Verify afterward that the forced version is actually compatible with its parents (install must succeed cleanly and the affected functionality must still work). If the parent hard-pins an incompatible range and breaks, do not ship the override.
- yarn (classic and berry):
- Remove or replace the parent if it is unmaintained and the only path to the vulnerable package, and a maintained alternative exists. Only do this when the change is small and clearly safe; otherwise report it as a recommendation instead.
- Apply the advisory's workaround when no patched version is installable (e.g. blocking specific codepaths or input types as documented in the advisory). Put the mitigation where the package is actually used, add a
TODOcomment referencing the alert number and the version that will make it removable. - Assess and report only as a last resort. If the dependency is dev-only or the vulnerable codepath is unreachable in this project (e.g. it never processes untrusted input through the affected API), and none of the above are practical, explain the exposure honestly in the report. Never silently dismiss.
5. Apply, install, and verify the tree
- Make the change, then reinstall cleanly:
rm -rf node_modules && <pm> install. - Confirm the vulnerable version is gone from the lockfile:
Every resolved version must be >= the first patched version.yarn why <package> # or the pm equivalent grep -n "<package>@" <lockfile> | head -50 - Run the audit tool as a second check (
yarn audit,npm audit,pnpm audit) and confirm this advisory no longer appears. Ignore unrelated advisories; do not scope-creep into fixing every alert unless asked.
6. Make sure nothing broke
Read .github/workflows/*.yml for the exact commands CI runs (install, build, lint, typecheck, test) and run them locally in the same order with the same package manager. Fix any breakage caused by the bump, keeping changes minimal and scoped. Do not refactor unrelated code and do not delete tests to make them pass. If the remediation is truly unworkable (e.g. the override breaks the parent at runtime), revert to the next option in step 4.
7. Commit, push, and open a PR
- Commit with a conventional message referencing the alert and CVEs, e.g.:
fix(deps): force sharp >=0.35.0 to resolve GHSA-xxxx (CVE-2026-33327 et al.) - add resolutions entry for sharp, introduced transitively via netlify-cli - regenerate lockfile - fixes Dependabot alert #218 - Push and open the PR against the default branch:
In the PR body: link the alert URL, list the CVE/GHSA IDs, state the remediation chosen and why, and note any follow-up (e.g. "remove the resolutions entry once netlify-cli ships sharp >=0.35.0").git push -u origin <branch> gh pr create --repo <owner>/<repo> --title "..." --body "..."
8. Verify CI and the alert
- Watch checks:
gh pr checks <pr-number> --repo <owner>/<repo> --watch. If a check fails remotely but passed locally, pull the logs (gh run view <run-id> --log-failed), diagnose, fix, push again. - Dependabot re-scans on push. After CI is green, re-check the alert state:
The alert auto-resolves once the fixed lockfile lands on the default branch, so it may still showgh api repos/<owner>/<repo>/dependabot/alerts/<number> --jq .stateopenuntil the PR merges; say so in the report rather than treating it as a failure.
9. Report
End with a short summary: the vulnerability and its path into the tree, the remediation chosen (and options rejected, if relevant), the commit(s) and PR link, CI status, and what will close the alert. If the fix is a temporary override or workaround, state clearly when and how it should be removed.