NpmToken detector should verify against the registry URL, if present #1455
Labels
contributions welcomed
Signal for help from the community!
enhancement
pkg/detectors
PRs and Issues related to the `detectors` package
Community Note
Description
The NpmToken v1 & v2 detectors are hard-coded to verify tokens against
https://registry.npmjs.org/-/whoami
:trufflehog/pkg/detectors/npmtoken/npmtoken.go
Line 53 in a99d89d
trufflehog/pkg/detectors/npmtokenv2/npmtokenv2.go
Line 53 in a99d89d
However, npm can be used with registries other than the default (
registry.npmjs.org
), meaning that valid tokens can inadvertently be marked as unverified. This is especially likely in enterprise environments which often have internal instances of Nexus Repository, Artifactory, or other artifact repository managers, and do not useregistry.npmjs.org
directly..Problem to be Addressed
The NpmToken detectors should verify the tokens against the relevant registry/registries, where possible.
Description of the Preferred Solution
NpmTokens are often found in the
.npmrc
configuration file, where they are required to be scoped to a specific registry.For example, the following NpmTokens have enough contextual information for TruffleHog to determine what registries they should be checked against instead of
registry.npmjs.org
:https://docs.npmjs.com/cli/v9/configuring-npm/npmrc#auth-related-configuration
Additional Context
References
N/A
The text was updated successfully, but these errors were encountered: