Risk rules
Risk rules look at what a registry says about each release, such as install scripts, new publishers or known vulnerabilities. Each rule can be off, warn or block, so you can watch what a rule catches before you let it stop anything.
Off, warn and block
Each rule has an Action:
| Action | What happens |
|---|---|
| Off | The rule isn't checked, and its warning doesn't appear anywhere. |
| Warn | The version is still Cleared. Its package page shows the warning, and each download is logged as flagged. |
| Block | The version is Refused. Clients get the newest version that passes instead, and a direct request gets an error that names the rule. |
Most rules start on warn. That lets you see what a rule would catch, on your own traffic, before it stops anyone.
Flagged downloads
A download that a warn rule flags is logged twice: once as flagged, with the rule and the warning, and
once as cleared. In Activity it shows as one row, labelled Cleared, with
warnings. To see only these downloads, open the Flagged tab, or search for
decision:flagged. A flagged event records the code of its first warning as its rule, so
decision:flagged rule:install-script only finds downloads where that warning came first. Use
Preview to see everything one rule affects. See Overview and activity.
On a package's page, the Versions tab lists each version's warnings under its rule. Warnings that repeat across many versions are shown once, at the top.
The rules
Rules are under Settings, in Risk rules, in four groups. Each row shows the registries the rule applies to. The code is the name to use in the config file and in an Activity search.
Known risks
| Rule | Code | Registries | Default | Flags |
|---|---|---|---|---|
| Remote dependencies | remote-dependency | npm | Block | The package depends on a URL or Git repository. npm fetches those directly, which skips every check here. |
| Known vulnerabilities | cve | npm, Python, Composer | Warn, High | The version is affected by a published vulnerability at or above the Minimum severity. |
| Possible typosquat | typosquat | npm, Python, Composer | Warn | The package name is one small edit from a popular package. |
| License deny list | license | npm, Python, Composer | Warn, empty list | The license is on your Denied licenses list. |
Signs of a takeover
| Rule | Code | Registries | Default | Flags |
|---|---|---|---|---|
| Sudden release after silence | dormant-release | npm, Python, Composer | Warn, 12 months | A recent version arrived after a long gap since the one before it. Hijacked accounts often wake up old packages, though a maintainer returning looks the same. |
| Provenance doesn't verify | provenance-invalid | npm, Python | Warn | A release's signed build record fails, or doesn't cover its file. |
| Built from another repository | provenance-repo | npm, Python | Warn | A verified release was built from a different repository than the one before it, or than the one you require. |
| Manifest mismatch | manifest-mismatch | npm | Warn | A downloaded file has an install script or a dependency that the registry's listing hides. |
| Install script newly added | install-script-added | npm | Warn | A recent version runs code during install, and the version before it didn't. |
| New publisher | new-publisher | npm | Warn | A recent version was published by an account that hasn't published this package before. |
| Provenance dropped | provenance-dropped | npm, Python | Warn | A recent version has no build provenance, and the version before it did. |
Code that runs at install
| Rule | Code | Registries | Default | Flags |
|---|---|---|---|---|
| Install scripts | install-script | npm | Warn | The version runs code during install. Many legitimate packages do this, and so does most npm malware. |
| Composer plugins | composer-plugin | Composer | Warn | The package is a Composer plugin, which runs code during install. Composer never runs scripts from dependencies, so plugins are the risk to watch. |
Package health
| Rule | Code | Registries | Default | Flags |
|---|---|---|---|---|
| Deprecated or abandoned | deprecated | npm, Python, Composer | Warn | The maintainer has marked this version deprecated or yanked, or the whole package abandoned. |
| Unmaintained | unmaintained | npm, Python, Composer | Off, 2 years | The package has had no release for a long time. Many finished libraries look like this, so this rule starts off. |
"A recent version" means one published in the last 90 days. A maintainer change from three years ago isn't an attack in progress, and flagging it would bury the ones that might be. A package that moves to npm's trusted publishing isn't flagged as a new publisher.
One more rule, Fast-track security fixes, changes quarantine instead of flagging anything. It is under Quarantine by registry. See Fast-track security fixes.
Change a rule
Choose the action
In the rule's row under Settings, choose Off, Warn or Block under Action. If the rule has a setting, such as Minimum severity or Silent for at least, set it too.
Preview it
Select Preview to see what the rule would have done. See preview a rule.
Save it
Select Save in the same row. Each row saves on its own, and the change applies to the next request.
A changed row shows Not saved yet until you save it, and the browser warns you if you leave the page with unsaved changes. Only admins can change rules. A rule set in the config file shows In code and can't be changed in the UI.
A team can set its own action and setting for any rule. See Teams.
Known vulnerabilities
The Known vulnerabilities rule uses vulnerability reports from OSV. Choose a Minimum severity of Low, Moderate, High or Critical. The default is High. Only reports at or above that severity count, and a report that gives no severity doesn't count.
A package's page lists every advisory that affects it under Known vulnerabilities, with links to OSV and to the CVE. Each version lists the ones that affect it.
On block, installs move to a patched version. A lockfile pinned to an affected version stops working until someone updates it. If OSV is turned off, this rule has no data to act on. See Threat feeds.
License deny list
Enter the licenses to deny under Denied licenses, separated by commas, such as
AGPL-3.0, GPL-3.0. The list starts empty, so the rule flags nothing until you add to it.
- Add
unknownto include packages that declare no license. - Entries match the start of a license name.
GPL-3.0coversGPL-3.0-onlybut notAGPL-3.0. - For a choice such as
MIT OR GPL-3.0, a package is denied only when every choice is on your list. - Python uses the newest release's license for every version.
Possible typosquat
Pratique compares each package name with a built-in list of popular package names for the same registry. It flags a
name that is one edit away from a popular name: one letter added, removed or changed, or two neighbouring letters
swapped. It also flags names that differ only by dashes, underscores or dots, such as react_dom for
react-dom.
To avoid false alarms, it skips popular names shorter than 5 characters. It also skips a package with a long history of its own: at least 5 releases, the first more than a year ago. An old, busy package that happens to be one edit from another isn't imitating it.
Provenance
Provenance is a signed record of where a release was built. A stolen publish token can upload anything, but it can't sign as your project's CI. npm and Python publish provenance. Composer has no equivalent.
For the three newest releases of each package clients request, and any prereleases published among them, Pratique fetches that record from the registry. It verifies the signature against Sigstore's public trust root and transparency log, and checks that the record covers the exact file listed. It never fetches the package itself, so this also works while a release is in quarantine.
Two rules use the result:
- Provenance doesn't verify flags a record that fails. Honest releases should never do this, so consider blocking.
- Built from another repository flags a verified release built from a different repository than the release before it, or than the one you require.
A failure opens an incident, and so does a change of repository. Pratique only checks provenance while at least one of these two rules is on.
Many packages don't publish provenance, and that isn't flagged. A package that drops provenance it used to have is flagged by Provenance dropped.
Hold a package to one repository
On a package's Provenance tab, an admin can use Require a repository. Releases published after that must be verified as built from that repository. A release from anywhere else, or with no verifiable build, is flagged by Built from another repository. Set that rule to block to stop them. See Package pages.
With that rule on block, a release published after you required a repository isn't cleared until its check has finished. A check that can't finish counts as a mismatch.
Provenance checks need outbound access to tuf-repo-cdn.sigstore.dev. If it is unavailable, releases of
packages without a required repository stay unchecked rather than flagged.
Manifest mismatch
Manifest mismatch catches what is known as manifest confusion. npm's registry lists what a version's manifest says, but clients run what is in the tarball, and nothing makes the two agree. So a package can show no install script in its listing and ship one.
Pratique compares the package.json in each stored npm file with the registry's listing for that version.
If the file has an install script or a dependency the listing hides, an incident opens, whatever the rule is set to.
The rule then flags or blocks that version, as you set it.
Know these limits:
- It acts after the first download. It reads only files clients already pulled, so it downloads nothing extra. Blocking stops later downloads of a version, not the first one.
- It ignores what the listing adds. The registry adds things to listings, such as an install script for a native build. Only what the file has and the listing hides is flagged.
Before you block
Watch each rule on warn under Activity for a while, and preview it, before you set it to block. Some things to expect:
- Known vulnerabilities refuses a lot. Most older versions of popular packages have a vulnerability.
- Install scripts catches legitimate packages such as
esbuildandsharp. Add an exception for the ones you trust. - Remote dependencies starts on block, because npm fetches those dependencies straight from the URL.
In a sample of 291 popular packages, no latest version was affected, and 0.58% of all versions were, mostly old
pm2releases. - Provenance rules start on warn, so watch them first. Use Require a repository for the packages that matter most.
- Manifest mismatch can't stop the first download of a version.
Exceptions and rules
An exception is a person's decision, and it ranks above the rules:
- An exception on one version overrides every rule.
- An exception on a whole package overrides the rules too, but not the malware check.
Use an exception when one package breaks a rule for a reason you've reviewed. Change the rule when it is wrong for everyone. See how decisions rank.
Preview a rule
Preview shows what a rule would have done to the last 30 days of real downloads, including who would have been affected, without changing anything. Rules are judged with today's data.
The preview shows Versions it would stop, Downloads affected and People and systems affected, and a table of the affected versions. Only blocking stops downloads, so preview a rule on block to see its effect. If you can't change a rule, because you're a viewer or the rule is set in the config file, select Preview blocking in its row instead.
Set rules in the config file
Each rule is a key under rules, named by its code. Every rule takes an action of
off, warn or block. Some rules take one more key:
severityforcve:low,moderate,highorcritical.valuefordormant-releasein months, and forunmaintainedin years: a whole number from 1 to 120.denyforlicense: a list of licenses.
The values in this example are choices, not the defaults:
rules: # action is off, warn or block
dormant-release: { action: warn, value: 12 } # months of silence
deprecated: { action: warn }
manifest-mismatch: { action: warn }
provenance-invalid: { action: warn }
provenance-repo: { action: warn }
unmaintained: { action: off, value: 2 } # years without a release
remote-dependency: { action: block }
cve: { action: warn, severity: critical }
install-script: { action: warn }
install-script-added: { action: block }
composer-plugin: { action: warn }
new-publisher: { action: warn }
provenance-dropped: { action: warn }
typosquat: { action: block }
license: { action: block, deny: [AGPL-3.0, unknown] }
A rule you leave out keeps its default and stays editable in the UI. An unknown rule, a wrong action or a value out of
range stops Pratique from starting, so a typo can't quietly weaken a policy. Check the file with
pratique config check pratique.yaml. See Configuration.