Skip to content

npm audit signatures does not report how many packages it skipped for want of registry keys #10018

Open

Description

@nortesoftware

Current behaviour

When a registry does not publish signing keys, audit signatures skips the packages installed
from it. That part is intended — #5479 asked for E400 to be treated like E404 for exactly
this reason, and the summary counts only what was checked, through auditedWithKeysCount.

What the summary does not say is how much was skipped. In a tree where some dependencies resolve
from a registry with keys and some from a registry without, the output and the exit code are
indistinguishable from a tree that was fully verified.

Reproduced on npm 10.9.8 with a local registry that answers 404 on /-/npm/v1/keys:

$ cat package.json
{ "name":"mixed-test","version":"1.0.0",
  "dependencies":{ "@nl/nokeys-dep":"1.0.0", "lodash":"4.17.21" } }
$ cat .npmrc
@nl:registry=http://127.0.0.1:8899

$ npm audit signatures
audited 1 package in 0s

1 package has a verified registry signature
$ echo $?
0

@nl/nokeys-dep is in the tree and carries no signature. It is not in the audited count, not
under missing, not under invalid. Nothing in the output indicates it exists.

When nothing can be audited the command already does the right thing:

$ npm audit signatures
npm error found no dependencies to audit that were installed from a supported registry
$ echo $?
1

Why it matters

A pipeline that runs npm audit signatures and branches on the exit code is asking "is this tree
verified". In the mixed case it is told yes, when the honest answer is "the part of it that could
be checked". The configuration where this arises — part of the tree resolving through an internal
mirror, a proxy or a third-party registry that does not publish keys — is a common one, and
arguably the one where the gate matters most.

The tree's total is not printed next to the audited count, so the two cannot be compared without
counting the lockfile separately.

Suggested change

Report the skipped count. Something like:

audited 1 package in 0s
1 package skipped: no signing keys published by http://127.0.0.1:8899

1 package has a verified registry signature

The information is already in hand at that point — the edges walked, the registries resolved and
auditedWithKeysCount — so this is a reporting change rather than a behavioural one. Whether a
skipped package should also affect the exit code is a separate decision, and a flag along the
lines of --require-signatures would leave the current default alone.

I am not suggesting the skip itself should change.

Activity

  1. nortesoftware commented on Sep 26, 2026

    @nortesoftware
    Author

    The issue says nothing in the output indicates the skipped package. That holds on 10.9.8, where it was reproduced, but not from 11.2.0 on: since #8080 there is a line for each registry outside the Sigstore trust root. The mixed tree from the issue, on 12.1.0:

    $ npm audit signatures
    npm warn Fetching verification keys using TUF failed.  Fetching directly from http://127.0.0.1:8899.
    audited 1 package in 0s
    
    1 package has a verified registry signature
    $ echo $?
    0
    

    The same line appears for a registry that serves keys and whose packages verify, so it names the registry without saying whether its packages were checked. The summary and the exit code are unchanged.

    npm/rfcs#550 proposed a warning for a mirror or proxy that omits signatures.

  2. nortesoftware commented on Oct 8, 2026

    @nortesoftware
    Author

    Three corrections to the issue.

    The skip needs more than a registry without keys: that registry's document for the package has to carry neither signatures nor attestations. npmmirror publishes no keys, and for some versions its documents carry npmjs's signatures. audit signatures then stops instead of skipping. On 12.1.0, with @types sent to npmmirror and the default on npmjs:

    $ cat .npmrc
    @types:registry=https://registry.npmmirror.com/
    $ grep -o '"resolved": "[^"]*"' package-lock.json
    "resolved": "https://registry.npmmirror.com/@types/lodash/-/lodash-4.17.25.tgz"
    "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
    $ npm audit signatures
    npm warn Fetching verification keys using TUF failed.  Fetching directly from https://registry.npmmirror.com/.
    npm error code EMISSINGSIGNATUREKEY
    npm error @types/[email protected] has a registry signature with keyid: SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U but no corresponding public key can be found
    npm error A complete log of this run can be found in: …
    $ echo $?
    1
    

    With @types/[email protected], whose document there carries neither, the same configuration prints audited 1 package and exits 0, as in the issue. 10.9.8 gives both results. The registry that counts is the one the configuration names when the audit runs, not the one in the lockfile.

    The issue said the command already errors when nothing can be audited. That holds on 10.9.8. From 11.11.0 (#9026) a keyless attestation is verified without registry keys, and it can be enough to pass a tree from a registry without keys. A local registry that publishes no keys, serving semver 7.8.5 with no signatures and, as its only attestation, the SLSA provenance from npmjs's, and a package with neither signatures nor attestations, on 12.1.0:

    $ cat .npmrc
    registry=http://127.0.0.1:8897/
    $ npm audit signatures
    npm warn Fetching verification keys using TUF failed.  Fetching directly from http://127.0.0.1:8897/.
    audited 0 package in 0s
    
    1 package has a verified attestation
    (use --json --include-attestations to view attestation details)
    $ echo $?
    0
    

    The second package is counted nowhere. 10.9.8 stops with EMISSINGSIGNATUREKEY on the same tree, and without the attestation both give "found no dependencies to audit". I have not measured other trees.

    The issue also called the configuration a common one, with an internal mirror or a proxy as the example. I have no figure for that. A mirror without keys as the only registry makes the audit fail, outside the attestation case. The silent case needs a scope sent to one kind of registry and the rest to the other, in either direction. With npmmirror as the default and a scope on npmjs, 12.1.0 refuses the install with its default settings (EALLOWREMOTE), and passes the tree once it is installed with --replace-registry-host=never or --allow-remote=all, or by 10.9.8.

    A count of skipped packages has to decide what to do with the packages 11.11.0 and later verify by keyless attestation without registry keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions