guardvibe 3.0.10 → 3.0.11
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.
|
@@ -34,7 +34,7 @@ export const advancedSecurityRules = [
|
|
|
34
34
|
severity: "low",
|
|
35
35
|
owasp: "API4:2023 Unrestricted Resource Consumption",
|
|
36
36
|
description: "API endpoint reads request body without explicit size limit. Note: Next.js/Vercel applies a default 4.5MB limit, so this is informational for those platforms. For custom servers, attackers can send large payloads to exhaust memory.",
|
|
37
|
-
pattern: /export\s+(?:async\s+)?function\s+(?:POST|PUT|PATCH)\s*\([^)]*\)\s*\{(?:(?!content-length|maxBodySize|limit|MAX_)[\s\S]){5,}?(?:req\.json|req\.text|req\.body|req\.formData|request\.json|request\.text)\s*\(\s*\)/g,
|
|
37
|
+
pattern: /export\s+(?:async\s+)?function\s+(?:POST|PUT|PATCH)\s*\([^)]*\)\s*\{(?:(?!content-length|maxBodySize|limit|MAX_|parseBody|checkBodySize|bodyParser|bodyLimit|sizeLimit)[\s\S]){5,}?(?:req\.json|req\.text|req\.body|req\.formData|request\.json|request\.text)\s*\(\s*\)/g,
|
|
38
38
|
languages: ["javascript", "typescript"],
|
|
39
39
|
fix: "Check Content-Length header before parsing body, or use a body parser with size limit.",
|
|
40
40
|
fixCode: '// Check body size before parsing\nexport async function POST(req: Request) {\n const contentLength = parseInt(req.headers.get("content-length") || "0");\n if (contentLength > 1024 * 1024) { // 1MB limit\n return new Response("Payload too large", { status: 413 });\n }\n const body = await req.json();\n}',
|
|
@@ -188,7 +188,7 @@ export const advancedSecurityRules = [
|
|
|
188
188
|
severity: "medium",
|
|
189
189
|
owasp: "A05:2025 Security Misconfiguration",
|
|
190
190
|
description: "Security headers are configured but Referrer-Policy is missing. Without it, the full URL (including query parameters with tokens/IDs) is sent to external sites in the Referer header.",
|
|
191
|
-
pattern: /(?:async\s+)?headers\s*\(\s*\)
|
|
191
|
+
pattern: /(?:async\s+)?headers\s*\(\s*\)(?=[\s\S]*(?:X-Frame-Options|Strict-Transport-Security|Content-Security-Policy))(?![\s\S]*Referrer-Policy)/g,
|
|
192
192
|
languages: ["javascript", "typescript"],
|
|
193
193
|
fix: "Add Referrer-Policy: strict-origin-when-cross-origin to your security headers.",
|
|
194
194
|
fixCode: '{ key: "Referrer-Policy", value: "strict-origin-when-cross-origin" }',
|
|
@@ -201,7 +201,7 @@ export const advancedSecurityRules = [
|
|
|
201
201
|
severity: "medium",
|
|
202
202
|
owasp: "A05:2025 Security Misconfiguration",
|
|
203
203
|
description: "Security headers are configured but Permissions-Policy is missing. Without it, embedded iframes and scripts can access camera, microphone, geolocation, and other sensitive browser APIs.",
|
|
204
|
-
pattern: /(?:async\s+)?headers\s*\(\s*\)
|
|
204
|
+
pattern: /(?:async\s+)?headers\s*\(\s*\)(?=[\s\S]*(?:X-Frame-Options|Strict-Transport-Security|Content-Security-Policy))(?![\s\S]*Permissions-Policy)/g,
|
|
205
205
|
languages: ["javascript", "typescript"],
|
|
206
206
|
fix: "Add Permissions-Policy header to restrict browser API access.",
|
|
207
207
|
fixCode: '{ key: "Permissions-Policy", value: "camera=(), microphone=(), geolocation=()" }',
|
|
@@ -330,7 +330,7 @@ export const advancedSecurityRules = [
|
|
|
330
330
|
severity: "medium",
|
|
331
331
|
owasp: "A01:2025 Broken Access Control",
|
|
332
332
|
description: "POST/PUT/PATCH/DELETE route handler performs database mutations without CSRF token verification. Cross-site requests from malicious pages can trick authenticated users into performing unwanted actions.",
|
|
333
|
-
pattern: /export\s+(?:async\s+)?function\s+(?:POST|PUT|PATCH|DELETE)\s*\([^)]*\)\s*\{(?:(?!csrf|csrfToken|CSRF|x-csrf|verifyCsrf|validateCsrf|anti.?forgery)[\s\S]){10,}?(?:\.create\s*\(|\.update\s*\(|\.delete\s*\(|\.insert\s*\(|\.upsert\s*\()/g,
|
|
333
|
+
pattern: /export\s+(?:async\s+)?function\s+(?:POST|PUT|PATCH|DELETE)\s*\([^)]*\)\s*\{(?:(?!csrf|csrfToken|CSRF|x-csrf|verifyCsrf|validateCsrf|anti.?forgery|requireAdmin|requireAuth|checkAuth|withAuth|protectRoute|authenticate|x-csrf-protection)[\s\S]){10,}?(?:\.create\s*\(|\.update\s*\(|\.delete\s*\(|\.insert\s*\(|\.upsert\s*\()/g,
|
|
334
334
|
languages: ["javascript", "typescript"],
|
|
335
335
|
fix: "Add CSRF token verification to state-changing endpoints.",
|
|
336
336
|
fixCode: '// Verify CSRF token from header\nexport async function POST(req: Request) {\n const csrfToken = req.headers.get("x-csrf-token");\n if (!verifyCsrfToken(csrfToken)) {\n return new Response("CSRF validation failed", { status: 403 });\n }\n}',
|
|
@@ -269,7 +269,7 @@ export const modernStackRules = [
|
|
|
269
269
|
severity: "high",
|
|
270
270
|
owasp: "A05:2025 Security Misconfiguration",
|
|
271
271
|
description: "Next.js app does not set a Content-Security-Policy header. CSP is the strongest defense against XSS — without it, injected scripts run freely in your users' browsers.",
|
|
272
|
-
pattern: /(?:async\s+)?headers\s*\(\s*\)\s
|
|
272
|
+
pattern: /(?:async\s+)?headers\s*\(\s*\)(?=[\s\S]*(?:X-Frame-Options|Strict-Transport-Security|X-Content-Type-Options))(?![\s\S]*Content-Security-Policy)/g,
|
|
273
273
|
languages: ["javascript", "typescript"],
|
|
274
274
|
fix: "Add a Content-Security-Policy header in next.config.ts headers().",
|
|
275
275
|
fixCode: "// next.config.ts\nasync headers() {\n return [{\n source: '/(.*)',\n headers: [{\n key: 'Content-Security-Policy',\n value: \"default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:;\"\n }]\n }];\n}",
|
|
@@ -476,7 +476,7 @@ export const modernStackRules = [
|
|
|
476
476
|
severity: "high",
|
|
477
477
|
owasp: "A01:2025 Broken Access Control",
|
|
478
478
|
description: "User-uploaded file's original filename is used directly for storage without sanitization. Attackers can use directory traversal (../../etc/passwd), null bytes (file.php%00.jpg), double extensions (file.jpg.exe), or Unicode tricks to overwrite files, bypass type checks, or achieve remote code execution.",
|
|
479
|
-
pattern: /(?:file\.name|originalname|
|
|
479
|
+
pattern: /(?:file\.name|originalname|req\.file\.originalname|formData\.get\s*\(\s*['"]file['"])(?:(?!randomUUID|uuid|nanoid|sanitize|safeFilename|safeName|allowedExt|allowedExtensions|\.replace\s*\(\s*\/\[)[\s\S]){0,100}?(?:writeFile|createWriteStream|save|upload|putObject|mv\s*\(|rename|storage)/gi,
|
|
480
480
|
languages: ["javascript", "typescript"],
|
|
481
481
|
fix: "Generate a random filename (UUID/nanoid) and validate the extension against an allowlist. Never use the original filename for storage.",
|
|
482
482
|
fixCode: 'import { randomUUID } from "crypto";\nimport path from "path";\n\n// Generate safe filename\nconst ext = path.extname(file.name).toLowerCase();\nconst ALLOWED_EXT = [".jpg", ".jpeg", ".png", ".webp", ".pdf"];\nif (!ALLOWED_EXT.includes(ext)) throw new Error("Invalid file type");\nconst safeName = `${randomUUID()}${ext}`;\nawait fs.writeFile(`/uploads/${safeName}`, buffer);',
|
|
@@ -66,7 +66,7 @@ export const nextjsRules = [
|
|
|
66
66
|
severity: "medium",
|
|
67
67
|
owasp: "A05:2025 Security Misconfiguration",
|
|
68
68
|
description: "next.config is missing important security headers (Content-Security-Policy, Strict-Transport-Security, X-Frame-Options).",
|
|
69
|
-
pattern: /(?:async\s+)?headers\s*\(\s*\)\s
|
|
69
|
+
pattern: /(?:async\s+)?headers\s*\(\s*\)(?![\s\S]*(?:X-Frame-Options|Strict-Transport-Security|Content-Security-Policy))/g,
|
|
70
70
|
languages: ["javascript", "typescript"],
|
|
71
71
|
fix: "Add security headers in next.config.ts headers() function.",
|
|
72
72
|
fixCode: '// next.config.ts\nasync headers() {\n return [{\n source: "/(.*)",\n headers: [\n { key: "X-Frame-Options", value: "DENY" },\n { key: "X-Content-Type-Options", value: "nosniff" },\n { key: "Strict-Transport-Security", value: "max-age=63072000; includeSubDomains" },\n ]\n }];\n}',
|
|
@@ -388,6 +388,14 @@ export function formatAuditResult(result, format) {
|
|
|
388
388
|
remediationPlan: {
|
|
389
389
|
totalSectionsWithFindings: plan.length,
|
|
390
390
|
warning: `MANDATORY: You must fix ALL ${plan.length} sections below. Do NOT fix only the code section and skip the rest. Work through each section in priority order. After completing ALL sections, call verify_remediation to confirm.`,
|
|
391
|
+
rules: [
|
|
392
|
+
"Do NOT dismiss findings as 'false positive' without running the section-specific tool first and verifying the finding is genuinely wrong.",
|
|
393
|
+
"Do NOT say 'npm audit is clean' to skip dependencies — GuardVibe uses the OSV database which may detect CVEs that npm audit misses.",
|
|
394
|
+
"Do NOT say 'already in .gitignore' to skip secrets — if GuardVibe detects secrets, they exist in the scanned files and must be removed or moved to env vars.",
|
|
395
|
+
"Do NOT skip auth-coverage by saying routes are 'intentionally public' — either add auth guards or add them to .guardviberc authExceptions so the scanner recognizes them.",
|
|
396
|
+
"After fixing each section, re-run the section-specific tool to confirm the finding count dropped. If it didn't drop, your fix didn't work.",
|
|
397
|
+
"Only call verify_remediation AFTER you have worked through ALL sections and confirmed each one improved.",
|
|
398
|
+
],
|
|
391
399
|
steps: plan,
|
|
392
400
|
},
|
|
393
401
|
});
|
|
@@ -464,6 +472,13 @@ export function formatAuditResult(result, format) {
|
|
|
464
472
|
lines.push(``);
|
|
465
473
|
lines.push(`> **IMPORTANT: You MUST fix ALL ${plan.length} sections below. Do NOT fix only the code section and skip the rest. Work through each section in priority order. After completing ALL sections, call \`verify_remediation\` to confirm.**`);
|
|
466
474
|
lines.push(``);
|
|
475
|
+
lines.push(`**Rules:**`);
|
|
476
|
+
lines.push(`- Do NOT dismiss findings as "false positive" without running the section-specific tool first`);
|
|
477
|
+
lines.push(`- Do NOT say "npm audit is clean" to skip dependencies — GuardVibe uses OSV which may detect CVEs npm misses`);
|
|
478
|
+
lines.push(`- Do NOT say "already in .gitignore" to skip secrets — if detected, they exist in scanned files`);
|
|
479
|
+
lines.push(`- After fixing each section, re-run the section tool to confirm finding count dropped`);
|
|
480
|
+
lines.push(`- Only call verify_remediation AFTER all sections show improvement`);
|
|
481
|
+
lines.push(``);
|
|
467
482
|
for (const step of plan) {
|
|
468
483
|
lines.push(`### Step ${step.priority}: ${step.section} (${step.findings} findings — ${step.critical} critical, ${step.high} high)`);
|
|
469
484
|
lines.push(``);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "guardvibe",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"mcpName": "io.github.goklab/guardvibe",
|
|
5
5
|
"description": "Security MCP for vibe coding. 335 rules, 36 tools, CLI + doctor. Host security, auth coverage mapping, LLM-powered deep scan (IDOR/business logic), taint analysis. Plus Next.js, Supabase, Clerk, Stripe, Prisma, tRPC, Hono, GraphQL, Convex, Turso, Uploadthing, AI SDK, and the full AI-generated stack.",
|
|
6
6
|
"type": "module",
|