Skip to content

Commit 28eecf1

Browse files
JeymzCopilot
andauthored
NPM_Security_Cheet_Sheet - Artifact Governance (#1858)
* fix(1372): Add secure Java authentication example to LDAP Injection Prevention Cheat Sheet * fix: Update RFC links - Update RFC links for LDAP encoding functions in the LDAP Injection Prevention Cheat Sheet * fix(1372): Revision for PR feedback - LDAPS: Switched from ldap://example.com:389 to ldaps://example.com:636 for secure simple authentication. - Anonymous Search: Opened a context with "none" authentication to look up the DN by uid. - Flexible Filter: The search filter now only requires uid, no assumption about objectClass=person, which makes it work for service accounts or other directory objects. - Resource Safety: Explicitly closing the anonymous context after the search. * fix(1795): Enhance NPM Security Cheat Sheet with governance and verification steps * fix: Update Java escaping examples and remove insecure patterns * Update LDAP_Injection_Prevention_Cheat_Sheet.md Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 08037a8 commit 28eecf1

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

cheatsheets/NPM_Security_Cheat_Sheet.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ Many popular npm packages have been found to be vulnerable and may carry a signi
7575
Security doesn’t end by just scanning for security vulnerabilities when installing a package but should also be streamlined with developer workflows to be effectively adopted throughout the entire lifecycle of software development, and monitored continuously when code is deployed:
7676

7777
- Scan for security vulnerabilities in [third-party open source projects](https://owasp.org/www-community/Component_Analysis)
78-
- Monitor snapshots of your project's manifests so you can receive alerts when new CVEs impact them
78+
- Monitor snapshots of your project's manifests so you can receive alerts when new CVEs impact them [OWASP Dependency-Track](https://owasp.org/www-project-dependency-track/)
7979

80-
## 6) Use a local npm proxy
80+
## 6) Artifact governance and supply chain protections
81+
82+
### Use a local npm proxy
8183

8284
The npm registry is the biggest collection of packages that is available for all JavaScript developers and is also the home of the most of the Open Source projects for web developers. But sometimes you might have different needs in terms of security, deployments or performance. When this is true, npm allows you to switch to a different registry:
8385

@@ -97,6 +99,52 @@ Hosting your own registry was never so easy! Let’s check the most important fe
9799
- If your project is based in Docker, using the official image is the best choice.
98100
- It enables really fast bootstrap for testing environments, and is handy for testing big mono-repos projects.
99101

102+
### Governance & Verification Steps
103+
104+
Supply-chain attacks increasingly target build artifacts, registries and CI credentials. Add lightweight governance and verification steps to reduce risk and improve response time:
105+
106+
- Track provenance and produce an SBOM for builds (CycloneDX/SPDX) so you can trace what was built and where inputs originated.
107+
108+
CycloneDX Example:
109+
110+
```bash
111+
# Generate SBOM
112+
npm install @cyclonedx/cyclonedx-npm
113+
npx @cyclonedx/cyclonedx-npm --validate > sbom.json # Use the flag `--omit dev` to exclude dev dependencies from SBOM if needed
114+
```
115+
116+
- Sign artifacts and build provenance (for example, use Sigstore / cosign or similar signing tools) so consumers can verify integrity before installing.
117+
118+
Sigstore Example:
119+
120+
```javascript
121+
// sign-and-verify.js
122+
// npm install sigstore fs
123+
124+
import * as fs from 'fs';
125+
import * as sigstore from 'sigstore';
126+
127+
// Path to your built npm package (via `npm pack`)
128+
const artifact = 'my-lib-1.0.0.tgz';
129+
130+
// --- Sign ---
131+
const payload = fs.readFileSync(artifact);
132+
const bundle = await sigstore.sign(payload);
133+
fs.writeFileSync(`${artifact}.sigstore.json`, JSON.stringify(bundle, null, 2));
134+
console.log('Signed:', artifact);
135+
136+
// --- Verify ---
137+
await sigstore.verify(payload, bundle);
138+
console.log('Verified OK!');
139+
```
140+
141+
- Prefer immutable, access-controlled registries or vetted mirrors (private registries, Verdaccio with an upstream cache, or [approved mirrors](#use-a-local-npm-proxy)) and enable retention / immutability policies where available.
142+
- Restrict, scope and rotate CI and publisher tokens. Bind publisher tokens to workflows or IP ranges and minimize privileges.
143+
- Verify packages during CI: check signatures or provenance, validate the SBOM, [run SCA and static analysis](#5-audit-for-vulnerabilities-in-open-source-dependencies), and [install from pinned lockfile resolutions](#2-enforce-the-lockfile).
144+
- Automate monitoring and alerts for unusual publishes, token usage or dependency changes and keep a documented remediation playbook (revoke tokens, deprecate/yank compromised packages, publish fixes and notify consumers).
145+
146+
These measures are incremental and low-risk to adopt. Combined they make supply-chain attacks harder and speed up identification & recovery if a compromise occurs.
147+
100148
## 7) Responsibly disclose security vulnerabilities
101149

102150
When security vulnerabilities are found, they pose a potentially serious threat if they are publicised without prior warning or appropriate remedial action for users who cannot protect themselves.

0 commit comments

Comments
 (0)