S07-12 - Dependency Gate
Purpose: How wb-proxyd keeps young and vulnerable package
versions from the guest on the gated registries.
Design
Section titled “Design”Dependency gate
Section titled “Dependency gate”This page serves SEC07-dep-gateSEC07-dep-gate: Dependency gatePackage downloads (npm, PyPI, Go modules, crates) are refused when the version is younger than a minimum age or has a known vulnerability at or above a severity threshold.. For npm, PyPI, the Go module proxy
and crates.io, wb-proxyd looks up each version’s publish time and
known vulnerabilities (OSV data). Publish times are on their own page,
S07-13-publish-timeS07-13-publish-time: Publish TimeWhere the dependency gate gets each version's publish time, and how it builds a clock for Go modules from the checksum database..
The minimum age is 7 days by default. It is applied twice, to metadata and to downloads.
Metadata
Section titled “Metadata”Versions younger than the minimum age are removed from the registry’s metadata responses. A resolver then picks an older version. This covers:
- npm packument
versionsanddist-tags, withlatestmoved to the newest remaining release; - npm
/-/package/<name>/dist-tags, filtered like the packument’sdist-tags; - the PyPI JSON simple index (PEP 691);
- crates.io sparse index lines;
- Go
@v/listand@latest.
For PyPI:
- The PyPI JSON API (
/pypi/<name>/json, which Poetry reads) loses its youngreleases. - When that response’s
infodescribes a young release, the response is refused. - A PyPI client that doesn’t accept the JSON simple index is refused.
Downloads
Section titled “Downloads”A download is refused when the version is younger than the minimum age, or has a known vulnerability at or above the threshold. The error names the package, the version, its publish time, and the date it becomes allowed.
On the gated hosts this catches lockfile pins, which never fetch metadata.
For the Go module proxy, only .zip is a download.
.infoand.modare not age-gated. The path forms (“Mapping a request”) still apply to them.- The clock lookup key and the upstream download URL are built from the same parsed module path and version. The fuzz target of the path mapper (C07-dependency-gateC07-dependency-gate: Dependency GateThe test cases for the dependency gate: registry paths, minimum age and known vulnerabilities, the Go checksum database clock, and Homebrew bottles from ghcr.io.) checks that they agree.
Vulnerability threshold
Section titled “Vulnerability threshold”The default threshold is CRITICAL (I73I73 (closed): S07-egress-gateway: vulnerability threshold of the dependency gateFound by the X21-dep-gate-registries spike (#32).).
- A malicious-package report, an OSV ID starting
MAL-, is refused whatever its severity. - A vulnerability below the threshold is allowed. It is logged with
the advisory and the rule
vuln-below-threshold(SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.), and shown inwb status.
The severity is the record’s database_specific.severity. Where that
is missing, wb-proxyd scores the record’s CVSS vector.
- A record with no severity at all is allowed, and logged with the
rule
vuln-no-severity. - A failed lookup is still refused.
The gate covers the registry hosts above, and nothing else. The same packages fetched another way are not gated:
- Go with
GOPROXY=direct, orGOPRIVATEfrom a git host; git+https:andgithub:dependencies;- archive downloads from a git host (
codeload.github.com); - cargo
gitdependencies; - mirrors such as
registry.npmmirror.com,goproxy.cnor an Artifactory server.
That residual is T07-ungated-sourcesT07-ungated-sources: Dependencies from ungated sourcesThe dependency gate (SEC07-dep-gate) covers the npm, PyPI, Go module proxy and crates.io hosts only.. These rules narrow it:
- the git hosting profile denies archive downloads;
- the approval risk check flags a host that mirrors a gated registry.
Mapping a request
Section titled “Mapping a request”Each gated host accepts only explicit path forms:
| Registry | Path form |
|---|---|
| npm | a package name and tarball |
| PyPI | a PEP 503 project name, with a PEP 440 version in a distribution file name |
| Go module proxy | an escaped module path, with a semantic or pseudo-version |
| crates.io | a crate name, with a semantic version |
A request that fits none of them gets a 403 that names the rule.
The gate identifies a package by its percent-decoded name. So
/@scope/name, /@scope%2fname and /@scope%2Fname get the same
decision. A request on a gated host whose package can’t be identified
is refused.
- Parsed names and versions are validated before they go into a lookup URL or an OSV query.
- A download is mapped from its URL alone.
- A PyPI file name is checked against the project’s JSON API.
Go module redirects
Section titled “Go module redirects”The Go module proxy answers a .zip request with a redirect.
wb-proxyd follows it itself, one hop, and only to
https://storage.googleapis.com/. Any other Location is refused and
logged with the rule. So the redirect can’t reach the host, the LAN or
another site (SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable.).
Holding the body
Section titled “Holding the body”OSV is queried while the download runs. No byte of the body reaches the guest before the verdict.
- A held body is buffered in memory up to a fixed size per stream, and spooled to a bounded temporary file beyond it.
- The number of gated downloads in flight per VM is bounded (SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.).
OSV answers are cached for one hour, keyed on package, version and threshold. During an OSV outage, only answers less than an hour old are used. Every other download is refused. A malicious-package report published within that hour can be missed.
If the publish time can’t be found or a lookup fails, the request is refused (fail closed).
Per-project overrides are explicit and audited. They apply to the whole VM while the project has a session in it (S07-01-per-vm-policyS07-01-per-vm-policy: Enforced per VMWhy the VM is the unit the gateway enforces, how the policies of its projects combine, and what happens when they conflict or change.).
Logging
Section titled “Logging”Each filtered metadata response is an audit event, with the package,
the versions hidden and the rule min-age (SEC10-auditSEC10-audit: AuditEvery egress decision, approval, and returned change is recorded on the host in a persisted log the guest cannot alter.). wb status
shows it. So a package with only young versions reads as too new, and
not as a typo (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).
On gated metadata requests, wb-proxyd removes If-None-Match and
If-Modified-Since. A rewritten body goes out without ETag or
Last-Modified.
Private registries
Section titled “Private registries”The gate fetches publish times itself, before credentials are injected. So a package on a private registry fails closed. How the gate authenticates its own fetch is open (B32-dep-gate-registriesB32-dep-gate-registries: Can the dependency gate refuse young packages without breaking installs?Yes, with conditions.).
Homebrew
Section titled “Homebrew”Bottles are not gated (T08-homebrew-ungatedT08-homebrew-ungated: Young Homebrew bottlesHomebrew bottles from homebrew/core are not age-gated or checked against OSV.).
Casks (homebrew/cask) are outside the ghcr.io scope in V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there.. So
brew install --cask raises an approval prompt for the host its
download comes from.
OpenShell middleware
Section titled “OpenShell middleware”The gate implements OpenShell’s supervisor middleware API
(SupervisorMiddleware, RFC 0009). It runs inside wb-proxyd, after
policy allows a request and before credentials are injected. So it
never sees a credential.
In process
Section titled “In process”The gate implements the Go interface generated from
supervisor_middleware.proto (package openshell.middleware.v1,
OpenShell v0.1.2, S10-tech-stackS10-tech-stack: Technology ChoicesFix languages, libraries, packaging, and repository layout, with the reason for each choice.). wb-proxyd calls it as a Go
method, with no listener and no gRPC hop (X24-openshell-artifactsX24-openshell-artifacts: OpenShell artifactsDo the OpenShell parts that S07-egress-gateway, S09-policy-credentials-audit and S10-tech-stack build on exist in the assumed form, under a permissive license, at a version that can be pinned: the networkpolicies sche…).
- Download checks use
EvaluateHttpRequest. - The metadata filter uses the messages of the
HttpResponsePreReturnservice, which the spike didn’t exercise. - An error returned by a gate method is a refusal.
Not bound by OpenShell’s proxy
Section titled “Not bound by OpenShell’s proxy”OpenShell’s own proxy doesn’t offer a middleware the body of a compressed response. It doesn’t pass a middleware’s free-form deny reason to the client either. Those limits belong to OpenShell’s caller, not the API.
wb-proxyd is the caller here. So it writes its own refusal message.
It decodes metadata before filtering, under these rules
(SEC13-bounded-resourcesSEC13-bounded-resources: Bounded resourcesCPU, memory and disk of each VM are capped.):
- It sets
Accept-Encodingon the upstream request itself, to the encodings it decodes. - It caps the decoded size, and the ratio of decoded to received bytes. A response past either cap is refused with a 403 that names the rule (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).
- It assembles the whole body before filtering. It spools a body past its memory limit to disk, within the size cap.
Decisions
Section titled “Decisions”Apply the minimum age twice
Section titled “Apply the minimum age twice”The gate filters young versions out of metadata, and refuses young downloads, with the three PyPI rules above.
- Why: refusing only the download fails nearly every fresh install (X21-dep-gate-registriesX21-dep-gate-registries: Dependency gate on real registriesCan wb-proxyd map a download to package, version and publish time for npm, PyPI, the Go module proxy, crates.io and Homebrew?).
- Decided: I32I32 (closed): X21-dep-gate-registries: Dependency gate on real registriesX21-dep-gate-registries (added to S11-verification-and-spikes in #14) accepted the three PyPI rules.
Threshold CRITICAL
Section titled “Threshold CRITICAL”- Why: at HIGH, 8 of 10 lockfile installs measured in X21-dep-gate-registriesX21-dep-gate-registries: Dependency gate on real registriesCan wb-proxyd map a download to package, version and publish time for npm, PyPI, the Go module proxy, crates.io and Homebrew? would have been refused, mostly for development tools. Users would have learned to override.
- Decided: I73I73 (closed): S07-egress-gateway: vulnerability threshold of the dependency gateFound by the X21-dep-gate-registries spike (#32)..
Accepted residuals
Section titled “Accepted residuals”T07-ungated-sourcesT07-ungated-sources: Dependencies from ungated sourcesThe dependency gate (SEC07-dep-gate) covers the npm, PyPI, Go module proxy and crates.io hosts only. is accepted, with the two rules of “Scope”. So is a malicious-package report missed within the hour an OSV answer is cached (“Holding the body”).
Bottles not gated
Section titled “Bottles not gated”- Why: Homebrew offers one version per formula, and signs its formula metadata. So there is nothing to filter, and no older version to fall back to. OSV has no Homebrew data. With a 7-day minimum age, about a third of the most installed formulae would be refused.
Status: Draft