Security rules
NGB049: Insecure dependency source
Reads the project's package.json files (dependencies, devDependencies, optionalDependencies, peerDependencies, overrides, resolutions) and reports dependency specifiers that can change under you or be tampered with in transit: plain http:// tarballs and git:// URLs (high), Git / GitHub dependencies not pinned to a full commit SHA (medium), https:// tarballs and unbounded ranges such as *, latest, >=1.0 (low).
| Property | Value |
|---|---|
| Rule ID | NGB049 |
| Category | Supply chain |
| Default severity | medium |
| CWE | CWE-494, CWE-829 |
| Built-in presets | recommended: error, strict: error |
Confidence is reported per finding (high, medium, low) and is independent of severity. See Reading findings.
What it checks
Reads the project's package.json files (dependencies, devDependencies, optionalDependencies, peerDependencies, overrides, resolutions) and reports dependency specifiers that can change under you or be tampered with in transit: plain http:// tarballs and git:// URLs (high), Git / GitHub dependencies not pinned to a full commit SHA (medium), https:// tarballs and unbounded ranges such as *, latest, >=1.0 (low). Confidence is lower when a lockfile is present.
Why it matters
Registry packages are immutable per version and integrity-checked through the lockfile. A Git branch, a moving tag or an unbounded range is not: whoever controls the repository (or compromises it) changes what your next install and CI build execute, including postinstall scripts with access to your CI secrets. Plain HTTP and git:// let anyone on the network path swap the code.
Detection behavior and supported patterns
"lib": "http://…/lib.tgz"and"lib": "git://…"/git+http://(high)"lib": "github:org/repo","org/repo#main","git+https://…#v1.2","git+ssh://…"without a 40-character commit SHA (medium)"lib": "https://…/lib.tgz","*","latest",">=1.0.0"(low)workspace:,file:,link:,npm:aliases and pinned semver ranges are not reported- Manifests under
node_modules,distand build output folders are ignored
Example
"dependencies": { "legacy-widget": "github:acme/legacy-widget#main", "charts": "*" }Safer alternative
"dependencies": { "legacy-widget": "github:acme/legacy-widget#4f1c2e9d3b7a6f5e8d9c0b1a2f3e4d5c6b7a8f9e", "charts": "^4.4.1" }Remediation
Depend on published registry versions, pin Git dependencies to a full commit SHA (github:org/repo#<40-hex sha>), never use http:// or git://, and commit a lockfile so CI installs exactly what was reviewed (npm ci, pnpm install --frozen-lockfile).
False-positive considerations
- Forked dependencies on a Git branch you control are reported; pin them to a commit SHA to remove the finding.
Known limitations
- The lockfile content is not parsed; its presence only lowers confidence.
- Known-vulnerable or malicious package versions are out of scope (use
npm audit/ an SCA tool).
References
Run it
ngbastion explain NGB049