
Automation tool written in Go to scan GitHub repositories, detect vulnerable Next.js versions (CVE-2025-66478), and automatically create Pull Requests with the specific security patch.
Make sure you have the following installed and configured in your environment:
gh)Before running the tool, you must be authenticated in the GitHub CLI:
gh auth login
# Select "SSH" as git protocol and "GitHub.com"
Clone this repository (where you saved the main.go script):
git clone <your-tools-repo-url>
cd auto-patcher
Install Go dependencies:
We need the semver library for intelligent version comparison.
go get github.com/Masterminds/semver/v3
go mod tidy
Currently, configuration is done directly in the constants of the main.go file. Review these lines before running:
main function, edit the gh command if you want to limit the search to a specific organization or user:
// main.go
cmd := exec.Command("gh", "repo", "list", "YOUR_ORG_OR_USER", "--limit", "100", ...)
const (
TargetBranch = "fix/security-nextjs-cve"
PRTitle = "fix(deps): upgrade next.js to patch CVE-2025-66478"
)
Simply run the main script:
go run main.go
gh repo list./tmp/repo-fixer-*).package.json files.next version against the security rules table (SemVer).package.json with the minimum required safe version.The script applies strict rules to avoid breaking compatibility (doesn't update to latest, but to the safe patch of your minor version):
| Detected Version | Applied Patch |
|---|---|
Check nextJsRules in main.go for the complete list.
15.0.x^15.0.5 |
15.1.x | ^15.1.9 |
15.2.x | ^15.2.6 |
| ... | ... |