Threat feeds

Threat feeds tell Pratique which versions to refuse, and a version listed by any feed is refused. OSV is built in, and you can add your own blocklist or a vendor's feed.

The Threat feeds page

Open Threat feeds from the sidebar, under Policy. It lists every source and whether it is working:

ColumnWhat it shows
SourceThe feed's name and address. A query string in a custom feed's address is hidden, because it often holds an API key.
TypeBuilt in for OSV, or Custom for your own feeds.
CoversWhat the feed provides, and for a custom feed, how many packages it lists.
StatusWorking, Waiting before the first update, Failing with the error, or Off.
Last updateWhen the feed last updated successfully.

The page also lists two checks Pratique does on its own: the built-in list of popular package names that the typosquat rule uses, and what registry metadata says about install scripts, publishers, provenance and licenses. Tune those under Settings. See Risk rules.

OSV

OSV is a public database of malware reports and known vulnerabilities. Pratique uses it by default, with one row on the page for each registry: npm, Python, Composer and Go. It gives Pratique two kinds of data:

  • Malware reports, which refuse the versions they name.
  • Known vulnerabilities, which the Known vulnerabilities rule and fast-track security fixes use.

How OSV stays current

Pratique keeps OSV data current in three ways:

On request
Per package. When a client asks for a package, Pratique asks OSV about that package. It reuses the answer for up to an hour.
Every 5 minutes
Change feed. Pratique reads OSV's list of new and changed reports for each registry, so a new report reaches stored packages within minutes.
Every hour
Recheck. Pratique asks OSV again about every package it has stored, every package a project's lockfile lists, and every package a build from the last 90 days used.

The change feed starts from the moment Pratique first runs, because the per-package queries already cover the past. If the change feed stops, the hourly recheck still runs, but new reports take longer to arrive. Alert on the pratique_feed_last_sync_timestamp_seconds metric going stale. See Monitoring.

Private package names are never sent to OSV. Public reports about a name you reserve aren't about your package.

When OSV can't be reached

If OSV is down, Pratique uses the last copy it has for a package, for up to 7 days. If it has never had threat data for a package, or its copy is older than 7 days, it doesn't serve that package. The client gets a 503 error that says threat data is unavailable, and can try again later. Pratique fails closed rather than serve a package it couldn't check.

Use a different OSV service

To use an internal mirror of OSV, set PRATIQUE_OSV_URL and PRATIQUE_OSV_FEED_URL, or threat_feeds.osv.url and threat_feeds.osv.feed_url in the config file.

Add your own feeds

Add your own blocklist, or a vendor's feed in OSV format, alongside OSV. Custom feeds are set in the config file only, so start Pratique with --config pratique.yaml:

yamlpratique.yaml
threat_feeds:
  custom:
    - name: security-team
      url: https://intel.example.com/blocklist.txt?key=${INTEL_KEY}
      format: blocklist          # lines of: registry name version reason
    - name: vendor
      url: https://vendor.example.com/osv.json
      format: osv

Each feed has a name, a url that starts with https:// (plain http:// only for localhost), and a format. Use ${VAR} to keep an API key out of the file. A variable that isn't set stops Pratique from starting.

Only add sources you trust

Everything listed in a custom feed is refused, whatever its severity. A wrong entry in a feed blocks that package for every team, until the feed changes or an admin allows the version.

The blocklist format

A blocklist is a text file with one package per line: the registry, the name, the version, and an optional reason. Use * as the version to list every version. Lines that start with # and empty lines are ignored.

textblocklist.txt
# registry  name             version  reason
npm         left-padd        *        Typosquat seen in our incident 142
python      requests-toolbox 1.2.3    Reported by the security team
composer    acme/fake-lib    *        Not an approved vendor

The registry can be npm, python or pypi, composer or packagist, and go or golang. A line with fewer than three fields, an unknown registry or an invalid package name makes the whole file fail. The error names the line number.

The osv format

The osv format reads records in the OSV format, as a JSON array or as an object with a vulns array. Pratique refuses every version that a record lists as affected, whatever the record says about severity. Withdrawn records are ignored, and so are packages from registries Pratique doesn't proxy.

How custom feeds refresh

  • Every 15 minutes. Each feed refreshes on its own, so one broken source doesn't affect the others.
  • The last good copy stays. If a refresh fails, or the file can't be read, Pratique keeps using the last good copy. The feed shows as Failing with the error, and "Using the last good copy". A feed that listed packages and then returns none counts as failing too, so a broken export can't unblock everything.
  • One bad record is skipped. An unreadable record in an osv feed is logged and skipped, and the rest of the feed is used.
  • Retire a feed by removing it from the config file. Its entries stop counting.
  • Limits. A feed can be up to 64 MB, and can list up to 500,000 packages. A feed that redirects to another host fails.
  • New entries are checked against what you have. When a refresh adds a package that a client already pulled, Pratique rechecks that package straight away.

Turn OSV off

You can turn OSV off in the config file:

yamlpratique.yaml
threat_feeds:
  osv:
    enabled: false

Only do this if you get the same data from another source. With OSV off:

  • Pratique won't refuse reported malware unless a custom feed lists it.
  • There is no vulnerability data, so the Known vulnerabilities rule and fast-track security fixes have nothing to act on.
  • The OSV rows on the Threat feeds page show Off, and the page warns that malware is only refused when a custom feed lists it.

Quarantine, hash checks and the other risk rules still work.

When a version you pulled is reported

A release can be reported as malware long after it cleared quarantine and reached your machines. When a feed reports a version that a client already downloaded, or that a project or build uses:

  1. Further downloads of that version are refused, and listings no longer offer it to clients.
  2. An incident opens. It names who downloaded the version and from where, the projects whose lockfiles list it, and the builds that used it.
  3. Your webhook gets an alert, if you've set one.
  4. The package's page shows a banner that the version was already downloaded, and by how many clients.

Stopping the version doesn't remove the copies clients already have. See Incidents and threats for how to respond.