Skip to content
AnswerWell geo Documentation

Research · 8 min read · Answerwell

Package Registry Security: HTTP Policies, Selectors and Ecosystem Detection

How secure web gateways detect package downloads from URL structure and enforce allow or block rules with pkg selectors, versions, and logging.

This page summarises Cloudflare Gateway documentation on package registry security: inspecting developer and CI/CD traffic to spot software package downloads and applying HTTP policies with pkg.* selectors. If you need to block a malicious npm package, stop PyPI installs org-wide, or force installs through an internal Artifactory host, the same mechanism applies.

Package registry security: what it controls on the wire

Section titled “Package registry security: what it controls on the wire”

Package registry security lets a secure web gateway recognise when HTTP traffic is a package download (as opposed to a generic API call) and extract ecosystem, name, version, and namespace so you can Allow or Block with normal HTTP policy actions.

Cloudflare Gateway can now detect software package downloads and give you policy control over supply chain traffic. When a developer or CI/CD pipeline downloads a package through Gateway, the proxy identifies the registry protocol from the request URL and extracts the package ecosystem, name, version, and namespace. You can then write HTTP policies using pkg.* selectors to allow or block package downloads.

— Cloudflare, Detect and control software package downloads with package registry security

The feature is aimed at supply chain traffic: anything that pulls installable artifacts through the gateway, from laptops to build agents.

For the full product description and policy examples, see Package registry security. Selector reference also appears under HTTP policies.

How package detection works from the download URL

Section titled “How package detection works from the download URL”

Detection runs on the HTTP request URL structure, not on a fixed list of registry hostnames. The gateway learns each supported registry’s download API shape and classifies a request when the path looks like a known artifact download.

Package detection operates entirely on the HTTP request URL structure. Gateway recognizes the API contract of each supported registry protocol, not the hostname serving the traffic. This means detection works the same way whether traffic goes to the official public registry, a self-hosted mirror, a corporate proxy registry such as Artifactory or Nexus, or any other compatible endpoint.

— Cloudflare, Package registry security

That design matters when traffic hits registry.npmjs.org, JFrog Artifactory, Sonatype Nexus, AWS CodeArtifact, a self-hosted mirror, or a CDN-fronted endpoint: if the path matches the ecosystem’s download pattern, pkg.* fields populate the same way. To distinguish where a package was fetched, combine pkg.* with http.request.host (documented in the mirror and sanctioned-registry examples on the same page).

Fail-open behaviour when the URL is not a package download

Section titled “Fail-open behaviour when the URL is not a package download”

If the URL cannot be classified as a package download, the request continues as ordinary non-package traffic. Classification failure does not block installs by itself.

Detection is fail-open. If the URL cannot be classified as a package download, the request proceeds as normal non-package traffic. A classification failure will never block or break a package install.

— Cloudflare, Package registry security

The initial capability covers download operations, where name, version, and ecosystem are derivable from the URL path across supported registries. Resolve (metadata lookups), publish, and other registry operations use different endpoints or methods and are not classified from the URL path alone.

Supported package ecosystems and URL patterns

Section titled “Supported package ecosystems and URL patterns”

Gateway detects downloads across seven ecosystems. The namespace column is what you match with pkg.namespace when the ecosystem defines one (npm scope, Maven group ID, Go module path).

Ecosystem Example artifact pattern Namespace
npm /{package}/-/{package}-{version}.tgz Scope (for example, @babel)
PyPI /packages/{hash}/…/{package}-{version}.whl —
RubyGems /gems/{package}-{version}.gem —
Cargo /crates/{package}/{package}-{version}.crate —
Go /{module}/@v/{version}.zip Module path
Maven /maven2/{group}/{artifact}/{version}/{artifact}-{version}.jar Group ID
NuGet /{package}/{version}/{package}.{version}.nupkg —

Source: Package registry security — Supported ecosystems.

pkg.* selectors for HTTP Allow and Block policies

Section titled “pkg.* selectors for HTTP Allow and Block policies”

Five selectors attach to HTTP policies with Allow and Block actions. In the dashboard, choose Package Ecosystem first; nested fields for name, version, and namespace appear after you pick a single ecosystem.

Selector UI name Role
pkg.ecosystem Package Ecosystem Registry type from the URL (for example npm, pypi)
pkg.name Package Name Package name from the download URL
pkg.version Package Version Version string; supports exact match and comparison operators
pkg.namespace Package Namespace Scope, group ID, or module path when the ecosystem has one
pkg.purl Package URL PURL derived from coordinates (API only)

API examples from HTTP policies:

  • pkg.ecosystem == "npm"
  • pkg.name == "lodash"
  • pkg.namespace == "@babel"
  • pkg.version == "4.17.21"
  • pkg.purl == "pkg:npm/lodash@4.17.21"

Granularity is intentional: you can block an entire ecosystem, one package at any version, or one version line.

Dashboard expression rules vs API wirefilter

Section titled “Dashboard expression rules vs API wirefilter”

When you build policies in the dashboard, extra UI rules apply. The API accepts combined wirefilter expressions without those constraints.

Rule Effect
Ecosystem first You must select an ecosystem before other package fields appear
Exactly one ecosystem Using in / not in for multiple ecosystems disables nested name, version, and namespace fields
Name before version You must set a package name before adding a version constraint
Namespace label Shown only for ecosystems with namespaces (Scope, Group ID, Module namespace)
pkg.purl Not available in the dashboard; use the API

Details: Build expressions in the dashboard.

pkg.version: ecosystem-aware version comparison

Section titled “pkg.version: ecosystem-aware version comparison”

pkg.version supports ==, !=, >, >=, <, and <= using each ecosystem’s native ordering—not plain string sort.

Ecosystem Versioning standard
npm SemVer
Cargo SemVer
PyPI PEP 440
RubyGems Gem::Version
Go Go module versions
Maven Maven version ordering
NuGet NuGet normalization and ordering

If a version string cannot be parsed under those rules, or the detected ecosystem does not match the comparison context, the comparison matches nothing—including !=. Range syntax such as npm ^1.2.3, PyPI ~=1.4, or Maven interval notation is not supported; use the comparison operators instead.

Cross-ecosystem version comparisons are not supported.

These patterns are taken from Package registry security. Order matters when you pair Allow (higher priority) with Block (lower priority).

Block every PyPI download:

pkg.ecosystem == "pypi"

Block npm package event-stream:

pkg.ecosystem == "npm" and pkg.name == "event-stream"

Block lodash versions below 4.17.21:

pkg.ecosystem == "npm" and pkg.name == "lodash" and pkg.version < "4.17.21"

Allow only a sanctioned npm mirror, block other npm downloads

Section titled “Allow only a sanctioned npm mirror, block other npm downloads”

Policy 1 (Allow, higher priority):

pkg.ecosystem == "npm" and http.request.host == "npm.internal.example.com"

Policy 2 (Block, lower priority):

pkg.ecosystem == "npm"

Public registry and internal mirror both classify as npm; the Allow rule wins for the sanctioned host.

Block an internal scoped package except from corporate registry

Section titled “Block an internal scoped package except from corporate registry”

Policy 1 (Allow from sanctioned host):

pkg.ecosystem == "npm" and pkg.namespace == "@acme" and pkg.name == "internal-sdk" and http.request.host == "npm.internal.example.com"

Policy 2 (Block same coordinates from anywhere else):

pkg.ecosystem == "npm" and pkg.namespace == "@acme" and pkg.name == "internal-sdk"

Logging and verification fields (Gateway HTTP)

Section titled “Logging and verification fields (Gateway HTTP)”

When a download is detected, package metadata is written to Gateway HTTP logs (activity logs and Logpush).

Gateway Activity Log fields include Package Ecosystem and Package URL (PURL). Logpush exposes a PackageInfo object on the gateway_http dataset:

Field Type Description
PackageInfo.Ecosystem string Detected ecosystem
PackageInfo.Namespace string Namespace when applicable
PackageInfo.Name string Package name
PackageInfo.Version string Version string
PackageInfo.Purl string PURL string

Information about the software package detected in the HTTP request, including its ecosystem, namespace, name, version, and package URL (PURL).

— Cloudflare, Gateway HTTP — PackageInfo

Use these fields to confirm that installs through Artifactory, Nexus, or the public registry are classified as expected.

Limitations and mistakes that break detection

Section titled “Limitations and mistakes that break detection”
Issue What goes wrong
TLS decryption off or Do Not Inspect Downloads are invisible to pkg.*
App-specific trust stores Node, Python, Ruby, Rust, Java, or Go clients may fail TLS to the inspection cert if only the OS trust store was updated
Non-download registry operations Resolve, publish, and similar traffic are not classified
Range syntax in policies ^, ~=, Maven intervals in policy values do not work; use >, <, etc.
Dependencies inside archives Dependencies inside shaded or fat JARs are not detected

Full list: Package registry security — Limitations.

  1. Confirm TLS decryption is enabled for developer and CI paths that fetch packages, and that clients trust the inspection certificate (see limitations in Package registry security).
  2. Run a controlled install (for example npm install or pip install) through Cloudflare Gateway from a managed device or test user.
  3. Open Gateway activity logs and confirm Package Ecosystem, name, version, or PURL appear on the download request.
  4. If you use Logpush, query the gateway_http dataset and inspect PackageInfo on a known install.
  5. Temporarily add a narrow Block rule (test package or sandbox ecosystem), retry the install, and confirm the policy action matches the wirefilter you documented in HTTP policies.

You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match the official docs or your deployment, email yimasynthetic@gmail.com with the page URL and the exact wording you are questioning.