Repository navigation
Report entries whose package is gone, and end each sweep with one report - #1895
Merged
Merged
Conversation
The daily sweep now also asks npm, PyPI, NuGet and crates.io whether each listed package still exists, and reports the server versions pointing at one that does not. Every sweep ends with one JSON line holding everything a maintainer has to look at, malware first, with a summary for the alert email. The alerts read that line: one email a day when there is something to review, critical if any of it is malware. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved existence-check filtering and threshold errors suppress valid missing-package findings and warnings, while listing failures omit the required incomplete report.
4 open issues
What changed in this PR
This PR extends the daily malware sweep to identify missing packages and consolidate findings into a bounded JSON report for maintainer alerts.
Changes:
- Adds package-existence checks with registry-specific concurrency, timeouts, and safeguards against unreliable responses.
- Introduces summary reports and report-based alerts, with guarded retirement of the previous per-hit policy.
- Updates configuration, tests, and operational documentation.
| File | Description |
|---|---|
tools/admin/configure-malware-alerts.py |
Adds report-based policies and guarded removal of obsolete alerts. |
internal/malware/sweep.go |
Integrates existence checks, findings, and report emission. |
internal/malware/sweep_test.go |
Tests missing packages, safeguards, timeouts, and reports. |
internal/malware/report.go |
Defines bounded JSON reports and sanitized summaries. |
internal/malware/osv.go |
Adds repository contact information to the user agent. |
internal/malware/existence.go |
Implements concurrent package-registry probes and response safeguards. |
internal/config/config.go |
Adds the missing-package check toggle. |
docs/administration/admin-operations.md |
Documents reports and maintainer response procedures. |
deploy/README.md |
Describes registry requests, timing, and alert migration. |
deploy/pkg/k8s/malware_sweep.go |
Updates the deployment comment to describe existence checks. |
cmd/registry/main.go |
Wires sweep settings, timeout, and additional result counts. |
.env.example |
Documents the missing-package check setting. |
Review effort: Balanced
npm keeps answering 200 at a package's own address after every version of it has been unpublished, with a record that holds no versions, so the sweep read such a package as present. Those are the names anyone can register again. Ask for the package's latest release instead, which is gone with the package: still one HEAD request per package. Checked against npm on 1,594 packages the registry lists: both addresses gave the same answer for every one of them, so nothing that exists is newly reported. Co-authored-by: Copilot App <[email protected]>
…eference - The implausibility floor counts the packages reported missing, not the packages asked about, so a few genuine removals in a small registry are still reported. - A sweep that could not read the whole listing writes its report too, with what the pages it read held. - A reference that names no release OSV can be asked about is still checked for existence. - Whether the existence check was incomplete is decided for each package registry by share alone, and a registry that was not believed counts. Co-authored-by: Copilot App <[email protected]>
…atest release npm turns away a client that asks for /<name>/latest more than a few hundred times: after about 530 requests it answered 429 with a retry-after of 470 seconds, which would leave most of npm unknown in every sweep. The package's own address is not limited that way, at 32 requests at a time. So the sweep fetches the first kilobyte of the package's short record there. A package whose every version was unpublished has a record of its name and a date, shorter than that and with no dist-tags; a record that long, or one with dist-tags, is a package with a release. Run against production's listing: 23,938 packages in 4m16s, none unknown. 71 unpublished packages are newly reported, and each was confirmed to have no release. Co-authored-by: Copilot App <[email protected]>
This was referenced Nov 22, 2026
rdimitrov
added a commit
that referenced
this pull request
Nov 22, 2026
Sets `mcp-registry:imageTag` to `1.8.13`. Nothing else in the stack file changes. ## What production gets v1.8.13 is `main` at 57332f3. Since v1.8.12: - **#1895**: the daily malware sweep also asks npm, PyPI, NuGet and crates.io whether each listed package still exists, and ends with one JSON report line. The registry server itself is unchanged by it: the new code runs only in the `registry-malware-sweep` CronJob. - **#1893**: the three operational Grafana dashboards. This is `deploy/` code already on `main`, so the production deploy applies it with this PR. - #1892 and #1894 touch documentation and the alert script only. Both images exist: `ghcr.io/modelcontextprotocol/registry:1.8.13` and `registry-usage-collector:1.8.13`. ## Measured on staging Two hand-run sweeps of the same build on 2026-11-22, on a copy of production's data (280,909 server versions, 23,945 distinct packages): | | v1.8.12 sweep | this build | |---|---|---| | Duration | 2 min 54 s | 5 min 58 s and 5 min 51 s | | Sweep pod, peak | about 120 MiB | 273m CPU, 124 MiB | | Packages left unknown | n/a | 0 | The extra three minutes are requests to the package registries; the registry and Postgres see the same listing read as before. The report arrived in Cloud Logging as `jsonPayload` (10 KB, inside one log line), and the new alert fired with the report's summary attached. ## After this deploys 1. Run `tools/admin/configure-malware-alerts.py` for the production project. Until a production sweep has written a report, it keeps the current per-hit policy, so production is watched throughout. 2. The first sweep on this build is the next 03:40 UTC run, or one started by hand. ## What to expect The first report will list about 650 server versions (206 servers) that point at a package that is gone, and send the warning email every day until they are dealt with. That backlog is existing data, not something this change causes. ## Rollback Set `imageTag` back to `1.8.12`. The freshness and publish alerts work with either build. If the alert script has by then removed the per-hit policy, a v1.8.12 sweep that finds malware would send no email, because it writes no report: check its log by hand, or roll forward again. Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
The daily sweep told a maintainer about malware one log line at a time, and said nothing about an entry whose package has been removed from its own registry. This changes both.
REGISTRY_MALWARE_SWEEP_MISSING). An npm package whose every version was unpublished counts as gone: npm still answers 200 at its address, and those are the unscoped names anyone can register again. A package that exists without the version an entry names is not reported."event":"REGISTRY_MALWARE_SWEEP_REPORT") holding the counts, a summary and the entries, malware first. It stays inside one 16 KiB log line; the per-entry lines still hold the whole list. A failed sweep writes it too, with"complete":false, including one that could not read the whole listing.tools/admin/configure-malware-alerts.pyreplaces the per-hit policy with two that read the report: critical if any entry is malware, a warning for anything else to review. Exactly one matches a report with something in it, and the summary is carried into the email. Report and publish alerts now close after 30 minutes, since an open alert sends nothing for a further match.How npm is asked
PyPI, NuGet and crates.io get a
HEAD. npm gets aGETof the first kilobyte (Range) of the package's short record: a fully unpublished package's record is its name and a date, about 60 bytes with nodist-tags; anything a kilobyte long, or withdist-tags, has a release.Asking for
/<name>/latestinstead tells the two apart as well, but npm limits that address: after about 530 requests it answered 429 withretry-after: 470. The package's own address took 32 requests at a time for 18,000 packages without one 429.Safeguards
existence_unknownand is not reported; the sweep still succeeds with what OSV said."existence_incomplete":trueand the warning email is sent, so a registry that stops answering is not read as one that has lost nothing.name) is unknown, not missing.MCP_REGISTRY_MALWARE_SWEEP_MISSING_PACKAGES=falseswitches the requests off.Measured
Read-only runs against production from outside the cluster on 2026-11-22: 281,000 server versions, 24,000 distinct packages.
HEAD, 8 at a timeHEAD, 32 at a timeBetween the first two runs 74 of those versions were taken down. The last run adds 219 versions pointing at 71 unpublished npm packages, all unscoped; each of the 71 was checked again by hand and has no release.
Not verified yet
These need the staging cluster, after merge:
jsonPayload.labelExtractorsand${log.extracted_label.summary}), and at what length.Production keeps running the current sweep and alerts until a release is promoted; the new alert script should not be run there before that.
Tests
go test -race ./internal/malware/,golangci-lintv2.14.0,go -C deploy test ./..., and the alert script's--dry-run.