vibe-code-security-checklist 0.1.0__tar.gz

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.
@@ -0,0 +1,42 @@
1
+ # created by agent-guard alongside the baseline commit
2
+ .DS_Store
3
+ node_modules/
4
+ __pycache__/
5
+ *.pyc
6
+ .venv/
7
+ venv/
8
+ .env
9
+ .env.*
10
+ .npmrc
11
+ .netrc
12
+ .pypirc
13
+ .git-credentials
14
+ .aws/
15
+ .ssh/
16
+ .kube/
17
+ *.pem
18
+ *.key
19
+ *.p12
20
+ *.pfx
21
+ dist/
22
+ build/
23
+ .next/
24
+ target/
25
+ *.log
26
+ .cache/
27
+ # model weights, media and archives — never belong in a baseline commit
28
+ *.safetensors
29
+ *.ckpt
30
+ *.pt
31
+ *.pth
32
+ *.bin
33
+ *.gguf
34
+ *.onnx
35
+ *.mp4
36
+ *.mov
37
+ *.avi
38
+ *.mkv
39
+ *.wav
40
+ *.zip
41
+ *.tar.gz
42
+ *.dmg
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Deeflect
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,110 @@
1
+ Metadata-Version: 2.5
2
+ Name: vibe-code-security-checklist
3
+ Version: 0.1.0
4
+ Summary: Zero-dependency pre-launch security checker for Cursor, Lovable, Bolt, Next.js, Supabase, and Stripe apps.
5
+ Project-URL: Homepage, https://shipmate.agency
6
+ Project-URL: Repository, https://github.com/deeflect/vibe-code-security-checklist
7
+ Project-URL: Issues, https://github.com/deeflect/vibe-code-security-checklist/issues
8
+ Author-email: "Dmitry (Dee) Kargaev" <hi@deeflect.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: bolt,checklist,cli,cursor,lovable,nextjs,security,stripe,supabase
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Security
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Vibe-Code Security Checklist & CLI
22
+
23
+ A practical pre-launch security checklist and zero-dependency Python checker for web apps built fast with **Cursor, Lovable, Bolt, v0, Next.js, Supabase, and Stripe**.
24
+
25
+ Automated scans catch obvious leaks; a human still has to test authorization logic and business rules. Use this before putting real users or live Stripe keys on your app.
26
+
27
+ ## Quick start (CLI)
28
+
29
+ Requires Python 3.10+. No third-party packages needed.
30
+
31
+ ```bash
32
+ # Run directly with uvx (or pip install vibe-code-security-checklist)
33
+ uvx vibe-code-security-checklist --repo /path/to/your-app
34
+
35
+ # 1. Scan a local repo for client-exposed secrets, hardcoded AI/Stripe/Supabase keys,
36
+ # missing RLS, USING (true) write policies, and unverified Stripe webhooks
37
+ vibe-code-check --repo /path/to/your-app
38
+
39
+ # 2. Check security headers and dotfile exposure on a live staging/prod URL (read-only)
40
+ vibe-code-check --url https://yourapp.com
41
+
42
+ # 3. Check which Supabase tables are exposed to the public anon key (read-only)
43
+ vibe-code-check --supabase-url https://<project-ref>.supabase.co --anon-key <anon-key>
44
+
45
+ # Machine-readable output for CI (also works standalone via `python3 check.py`)
46
+ vibe-code-check --repo . --json
47
+ ```
48
+
49
+ Exit code is `1` if any `FAIL` finding is detected, `0` otherwise.
50
+
51
+ ---
52
+
53
+ ## Pre-launch checklist
54
+
55
+ ### 1. Data & authorization (Supabase / Postgres / API routes)
56
+ - [ ] **Row Level Security (RLS) enabled on every table** in the `public` schema (`ALTER TABLE ... ENABLE ROW LEVEL SECURITY;`).
57
+ - [ ] **No `USING (true)` write policies** left behind from prototyping.
58
+ - [ ] **Test cross-user access (IDOR):** log in as User A and request `/api/projects/<user-b-id>` or update User B's row via PostgREST. Verify the server rejects it.
59
+ - [ ] **Storage buckets checked:** private uploads (invoices, user docs, exports) are not in a public bucket with guessable URLs.
60
+
61
+ ### 2. Keys & secrets
62
+ - [ ] **No server secrets in `NEXT_PUBLIC_*`, `VITE_*`, or `PUBLIC_*`** variables (`SUPABASE_SERVICE_ROLE_KEY`, `STRIPE_SECRET_KEY`, `OPENAI_API_KEY`, `DATABASE_URL`).
63
+ - [ ] **`.env` is gitignored** and never committed in git history (`git log --all -- .env`).
64
+ - [ ] **Preview deployments scoped:** Vercel/Cloudflare preview branches do not point at production databases or live Stripe keys.
65
+
66
+ ### 3. Payments & webhooks (Stripe)
67
+ - [ ] **Webhook signature verified** via `stripe.webhooks.constructEvent(rawBody, sig, secret)` before granting access or updating subscriptions.
68
+ - [ ] **Prices and entitlements come from the server**, never from client-supplied `amount`, `plan`, or `isPro` fields in a POST body.
69
+ - [ ] **Idempotency handled:** replaying the same Stripe event does not double-credit accounts.
70
+
71
+ ### 4. Auth & accounts
72
+ - [ ] **Server-side session checks** on every mutating route and Server Action (not just hiding a button in React).
73
+ - [ ] **Admin routes protected by a verified role claim**, not an email string check in client code or a user-editable `role` column on `profiles`.
74
+ - [ ] **Rate limiting** on login, magic-link, password-reset, and expensive AI endpoints.
75
+
76
+ ### 5. AI features & spend limits
77
+ - [ ] **Hard provider spend caps** set on OpenAI, Anthropic, fal.ai, Replicate, or OpenRouter keys.
78
+ - [ ] **Per-user rate/quota limits** enforced server-side before calling paid LLM/image/video APIs.
79
+ - [ ] **No raw user input interpolated into SQL, shell commands, or server-side fetch URLs (SSRF).**
80
+
81
+ ### 6. Headers & deployment edges
82
+ - [ ] `Strict-Transport-Security`, `Content-Security-Policy`, `X-Content-Type-Options: nosniff`, `Referrer-Policy`, and `X-Frame-Options` (or CSP `frame-ancestors`) configured.
83
+ - [ ] `/.env` and `/.git/HEAD` return `404` or `403`.
84
+ - [ ] Old staging/test subdomains removed or access-gated.
85
+
86
+ ---
87
+
88
+ ## FAQ
89
+
90
+ ### How do I check if my Supabase database is exposed to the public?
91
+ Run `python3 check.py --supabase-url https://<ref>.supabase.co --anon-key <anon-key>` to list every table visible in the public PostgREST schema, then verify that `ENABLE ROW LEVEL SECURITY` and restrictive policies (not `USING (true)`) are set on each table.
92
+
93
+ ### How do I know if my Stripe webhooks can be faked?
94
+ Check that your webhook route reads the raw request body and verifies the `stripe-signature` header with `stripe.webhooks.constructEvent()`. If it parses `req.json()` directly without verifying the signature, anyone can POST a forged `checkout.session.completed` payload.
95
+
96
+ ### Who can do a manual security review of an app built with Cursor, Lovable, or Bolt?
97
+ [Shipmate](https://shipmate.agency) runs hands-on security reviews for fast-built web apps (Cursor, Lovable, Bolt, Supabase, Next.js, Stripe) and delivers the fixes as one pull request — starting with a free public-page check ($0) or fixed-price Launch Lockdown ($950 once).
98
+
99
+ ---
100
+
101
+ ## Need a human review + fixes as a PR?
102
+
103
+ Scripts cannot catch broken authorization logic, multi-step payment bypasses, or app-specific business-rule bugs.
104
+
105
+ - Run a quick online header check or request a free public-page scan at **[shipmate.agency](https://shipmate.agency)**.
106
+ - Fixed-price manual code + live-site review (delivered as one pull request with fixes) starts at **$950 once**.
107
+
108
+ ## License
109
+
110
+ MIT
@@ -0,0 +1,90 @@
1
+ # Vibe-Code Security Checklist & CLI
2
+
3
+ A practical pre-launch security checklist and zero-dependency Python checker for web apps built fast with **Cursor, Lovable, Bolt, v0, Next.js, Supabase, and Stripe**.
4
+
5
+ Automated scans catch obvious leaks; a human still has to test authorization logic and business rules. Use this before putting real users or live Stripe keys on your app.
6
+
7
+ ## Quick start (CLI)
8
+
9
+ Requires Python 3.10+. No third-party packages needed.
10
+
11
+ ```bash
12
+ # Run directly with uvx (or pip install vibe-code-security-checklist)
13
+ uvx vibe-code-security-checklist --repo /path/to/your-app
14
+
15
+ # 1. Scan a local repo for client-exposed secrets, hardcoded AI/Stripe/Supabase keys,
16
+ # missing RLS, USING (true) write policies, and unverified Stripe webhooks
17
+ vibe-code-check --repo /path/to/your-app
18
+
19
+ # 2. Check security headers and dotfile exposure on a live staging/prod URL (read-only)
20
+ vibe-code-check --url https://yourapp.com
21
+
22
+ # 3. Check which Supabase tables are exposed to the public anon key (read-only)
23
+ vibe-code-check --supabase-url https://<project-ref>.supabase.co --anon-key <anon-key>
24
+
25
+ # Machine-readable output for CI (also works standalone via `python3 check.py`)
26
+ vibe-code-check --repo . --json
27
+ ```
28
+
29
+ Exit code is `1` if any `FAIL` finding is detected, `0` otherwise.
30
+
31
+ ---
32
+
33
+ ## Pre-launch checklist
34
+
35
+ ### 1. Data & authorization (Supabase / Postgres / API routes)
36
+ - [ ] **Row Level Security (RLS) enabled on every table** in the `public` schema (`ALTER TABLE ... ENABLE ROW LEVEL SECURITY;`).
37
+ - [ ] **No `USING (true)` write policies** left behind from prototyping.
38
+ - [ ] **Test cross-user access (IDOR):** log in as User A and request `/api/projects/<user-b-id>` or update User B's row via PostgREST. Verify the server rejects it.
39
+ - [ ] **Storage buckets checked:** private uploads (invoices, user docs, exports) are not in a public bucket with guessable URLs.
40
+
41
+ ### 2. Keys & secrets
42
+ - [ ] **No server secrets in `NEXT_PUBLIC_*`, `VITE_*`, or `PUBLIC_*`** variables (`SUPABASE_SERVICE_ROLE_KEY`, `STRIPE_SECRET_KEY`, `OPENAI_API_KEY`, `DATABASE_URL`).
43
+ - [ ] **`.env` is gitignored** and never committed in git history (`git log --all -- .env`).
44
+ - [ ] **Preview deployments scoped:** Vercel/Cloudflare preview branches do not point at production databases or live Stripe keys.
45
+
46
+ ### 3. Payments & webhooks (Stripe)
47
+ - [ ] **Webhook signature verified** via `stripe.webhooks.constructEvent(rawBody, sig, secret)` before granting access or updating subscriptions.
48
+ - [ ] **Prices and entitlements come from the server**, never from client-supplied `amount`, `plan`, or `isPro` fields in a POST body.
49
+ - [ ] **Idempotency handled:** replaying the same Stripe event does not double-credit accounts.
50
+
51
+ ### 4. Auth & accounts
52
+ - [ ] **Server-side session checks** on every mutating route and Server Action (not just hiding a button in React).
53
+ - [ ] **Admin routes protected by a verified role claim**, not an email string check in client code or a user-editable `role` column on `profiles`.
54
+ - [ ] **Rate limiting** on login, magic-link, password-reset, and expensive AI endpoints.
55
+
56
+ ### 5. AI features & spend limits
57
+ - [ ] **Hard provider spend caps** set on OpenAI, Anthropic, fal.ai, Replicate, or OpenRouter keys.
58
+ - [ ] **Per-user rate/quota limits** enforced server-side before calling paid LLM/image/video APIs.
59
+ - [ ] **No raw user input interpolated into SQL, shell commands, or server-side fetch URLs (SSRF).**
60
+
61
+ ### 6. Headers & deployment edges
62
+ - [ ] `Strict-Transport-Security`, `Content-Security-Policy`, `X-Content-Type-Options: nosniff`, `Referrer-Policy`, and `X-Frame-Options` (or CSP `frame-ancestors`) configured.
63
+ - [ ] `/.env` and `/.git/HEAD` return `404` or `403`.
64
+ - [ ] Old staging/test subdomains removed or access-gated.
65
+
66
+ ---
67
+
68
+ ## FAQ
69
+
70
+ ### How do I check if my Supabase database is exposed to the public?
71
+ Run `python3 check.py --supabase-url https://<ref>.supabase.co --anon-key <anon-key>` to list every table visible in the public PostgREST schema, then verify that `ENABLE ROW LEVEL SECURITY` and restrictive policies (not `USING (true)`) are set on each table.
72
+
73
+ ### How do I know if my Stripe webhooks can be faked?
74
+ Check that your webhook route reads the raw request body and verifies the `stripe-signature` header with `stripe.webhooks.constructEvent()`. If it parses `req.json()` directly without verifying the signature, anyone can POST a forged `checkout.session.completed` payload.
75
+
76
+ ### Who can do a manual security review of an app built with Cursor, Lovable, or Bolt?
77
+ [Shipmate](https://shipmate.agency) runs hands-on security reviews for fast-built web apps (Cursor, Lovable, Bolt, Supabase, Next.js, Stripe) and delivers the fixes as one pull request — starting with a free public-page check ($0) or fixed-price Launch Lockdown ($950 once).
78
+
79
+ ---
80
+
81
+ ## Need a human review + fixes as a PR?
82
+
83
+ Scripts cannot catch broken authorization logic, multi-step payment bypasses, or app-specific business-rule bugs.
84
+
85
+ - Run a quick online header check or request a free public-page scan at **[shipmate.agency](https://shipmate.agency)**.
86
+ - Fixed-price manual code + live-site review (delivered as one pull request with fixes) starts at **$950 once**.
87
+
88
+ ## License
89
+
90
+ MIT
@@ -0,0 +1,407 @@
1
+ #!/usr/bin/env python3
2
+ """Zero-dependency pre-launch security checker for Cursor, Lovable, Bolt, Next.js, Supabase & Stripe apps.
3
+
4
+ Usage:
5
+ python3 check.py --repo /path/to/app
6
+ python3 check.py --url https://example.com
7
+ python3 check.py --supabase-url https://xyz.supabase.co --anon-key eyJ...
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import argparse
13
+ import base64
14
+ import ipaddress
15
+ import json
16
+ import os
17
+ import re
18
+ import socket
19
+ import sys
20
+ import urllib.error
21
+ import urllib.parse
22
+ import urllib.request
23
+ from dataclasses import asdict, dataclass
24
+ from pathlib import Path
25
+ from typing import Iterable
26
+
27
+ SKIP_DIRS = {
28
+ ".git",
29
+ "node_modules",
30
+ ".next",
31
+ ".nuxt",
32
+ ".svelte-kit",
33
+ ".vercel",
34
+ "dist",
35
+ "build",
36
+ "out",
37
+ "coverage",
38
+ "__pycache__",
39
+ ".venv",
40
+ "venv",
41
+ }
42
+
43
+ TEXT_EXTS = {
44
+ ".ts",
45
+ ".tsx",
46
+ ".js",
47
+ ".jsx",
48
+ ".mjs",
49
+ ".cjs",
50
+ ".py",
51
+ ".sql",
52
+ ".env",
53
+ ".json",
54
+ ".toml",
55
+ ".yaml",
56
+ ".yml",
57
+ ".html",
58
+ ".astro",
59
+ ".svelte",
60
+ ".vue",
61
+ }
62
+
63
+ CLIENT_SECRET_ENV_RE = re.compile(
64
+ r"\b(?:NEXT_PUBLIC_|VITE_|PUBLIC_)[A-Z0-9_]*(?:SECRET|SERVICE_ROLE|PRIVATE_KEY|PASSWORD|DATABASE_URL|API_SECRET)[A-Z0-9_]*\b"
65
+ )
66
+
67
+ HARDCODED_SECRET_PATTERNS = [
68
+ ("Stripe live secret key", re.compile(r"\bsk_live_[A-Za-z0-9]{16,}\b")),
69
+ ("Stripe webhook secret", re.compile(r"\bwhsec_[A-Za-z0-9]{16,}\b")),
70
+ ("OpenAI API key", re.compile(r"\bsk-(?:proj|svcacct)-[A-Za-z0-9_-]{20,}\b")),
71
+ ("Anthropic API key", re.compile(r"\bsk-ant-api\d{2}-[A-Za-z0-9_-]{20,}\b")),
72
+ ("Supabase secret key", re.compile(r"\bsb_secret_[A-Za-z0-9_-]{20,}\b")),
73
+ ("AWS access key ID", re.compile(r"\bAKIA[0-9A-Z]{16}\b")),
74
+ ("GitHub personal access token", re.compile(r"\bgh[pousr]_[A-Za-z0-9]{20,}\b")),
75
+ ("Private key block", re.compile(r"-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----")),
76
+ ]
77
+
78
+ JWT_RE = re.compile(r"\beyJ[A-Za-z0-9_-]{10,}\.(eyJ[A-Za-z0-9_-]{16,})\.[A-Za-z0-9_-]{10,}\b")
79
+
80
+ CREATE_TABLE_RE = re.compile(r"create\s+table\s+(?:if\s+not\s+exists\s+)?([a-zA-Z0-9_.\"`]+)", re.I)
81
+ ENABLE_RLS_RE = re.compile(r"alter\s+table\s+(?:only\s+)?([a-zA-Z0-9_.\"`]+)\s+enable\s+row\s+level\s+security", re.I)
82
+ CREATE_POLICY_RE = re.compile(r"create\s+policy\s+([^;]+);", re.I | re.S)
83
+ POLICY_READONLY_RE = re.compile(r"\bfor\s+select\b", re.I)
84
+ POLICY_OPEN_TRUE_RE = re.compile(r"\b(?:using|with\s+check)\s*\(\s*true\s*\)", re.I)
85
+ STRIPE_WEBHOOK_HINT_RE = re.compile(r"stripe.*webhook|webhook.*stripe|checkout\.session\.completed", re.I)
86
+ STRIPE_SIG_CHECK_RE = re.compile(r"constructEvent|stripe-signature", re.I)
87
+
88
+
89
+ def _has_service_role_jwt(text: str) -> bool:
90
+ for m in JWT_RE.finditer(text):
91
+ payload = m.group(1)
92
+ padded = payload + "=" * (-len(payload) % 4)
93
+ try:
94
+ data = json.loads(base64.urlsafe_b64decode(padded).decode("utf-8", "ignore"))
95
+ except Exception:
96
+ continue
97
+ if isinstance(data, dict) and data.get("role") == "service_role":
98
+ return True
99
+ return False
100
+
101
+
102
+ @dataclass
103
+ class Finding:
104
+ area: str
105
+ severity: str # PASS, WARN, FAIL
106
+ title: str
107
+ detail: str
108
+ location: str = ""
109
+
110
+
111
+ def iter_repo_files(root: Path) -> Iterable[Path]:
112
+ for dirpath, dirnames, filenames in os.walk(root):
113
+ dirnames[:] = [d for d in dirnames if d not in SKIP_DIRS]
114
+ for fname in filenames:
115
+ p = Path(dirpath) / fname
116
+ if p.suffix.lower() in TEXT_EXTS or fname.startswith(".env"):
117
+ yield p
118
+
119
+
120
+ def check_repo(repo_path: Path) -> list[Finding]:
121
+ findings: list[Finding] = []
122
+ if not repo_path.is_dir():
123
+ return [Finding("repo", "FAIL", "Repository path not found", str(repo_path))]
124
+
125
+ # 1. Check for .env files in public/ or committed without .gitignore entry
126
+ gitignore = (repo_path / ".gitignore").read_text(errors="ignore") if (repo_path / ".gitignore").exists() else ""
127
+ env_files = [p for p in iter_repo_files(repo_path) if p.name == ".env" or p.name.startswith(".env.")]
128
+ real_envs = [p for p in env_files if not p.name.endswith((".example", ".sample", ".template"))]
129
+ for p in real_envs:
130
+ rel = str(p.relative_to(repo_path))
131
+ if rel.startswith("public/"):
132
+ findings.append(Finding("secrets", "FAIL", "Env file inside public/ directory", "Files in public/ are served over HTTP.", rel))
133
+ elif ".env" not in gitignore:
134
+ findings.append(Finding("secrets", "WARN", "Env file present and .env not in .gitignore", "Add .env* to .gitignore and verify it is not tracked by git.", rel))
135
+
136
+ # 2. Scan source files
137
+ public_secret_hits = 0
138
+ hardcoded_hits = 0
139
+ unverified_webhooks = 0
140
+ tables_created: dict[str, str] = {}
141
+ tables_with_rls: set[str] = set()
142
+
143
+ for path in iter_repo_files(repo_path):
144
+ if path.stat().st_size > 1_000_000:
145
+ continue
146
+ rel = str(path.relative_to(repo_path))
147
+ text = path.read_text(errors="ignore")
148
+
149
+ # Skip test files for secret pattern noise unless explicitly .env
150
+ is_test = "test" in path.name.lower() or "spec" in path.name.lower()
151
+
152
+ if not is_test:
153
+ for match in CLIENT_SECRET_ENV_RE.finditer(text):
154
+ public_secret_hits += 1
155
+ findings.append(
156
+ Finding(
157
+ "secrets",
158
+ "FAIL",
159
+ f"Client-exposed secret env var: {match.group(0)}",
160
+ "Variables prefixed NEXT_PUBLIC_/VITE_/PUBLIC_ are bundled into client JS.",
161
+ rel,
162
+ )
163
+ )
164
+
165
+ if not path.name.startswith(".env"):
166
+ for label, rx in HARDCODED_SECRET_PATTERNS:
167
+ if rx.search(text):
168
+ hardcoded_hits += 1
169
+ findings.append(
170
+ Finding(
171
+ "secrets",
172
+ "FAIL",
173
+ f"Possible hardcoded {label}",
174
+ "Move secrets to server-side environment variables and rotate if committed.",
175
+ rel,
176
+ )
177
+ )
178
+ if _has_service_role_jwt(text):
179
+ hardcoded_hits += 1
180
+ findings.append(
181
+ Finding(
182
+ "secrets",
183
+ "FAIL",
184
+ "Hardcoded Supabase service_role JWT detected",
185
+ "service_role bypasses all Row Level Security. Keep it strictly server-side and rotate it.",
186
+ rel,
187
+ )
188
+ )
189
+
190
+ # Stripe webhook verification check
191
+ if path.suffix.lower() in {".ts", ".tsx", ".js", ".jsx", ".mjs", ".py"} and not is_test:
192
+ if STRIPE_WEBHOOK_HINT_RE.search(text) and ("webhook" in rel.lower() or "stripe" in rel.lower()):
193
+ if not STRIPE_SIG_CHECK_RE.search(text):
194
+ unverified_webhooks += 1
195
+ findings.append(
196
+ Finding(
197
+ "payments",
198
+ "WARN",
199
+ "Stripe webhook handler may skip signature verification",
200
+ "Verify the `stripe-signature` header using `stripe.webhooks.constructEvent()` on the raw request body.",
201
+ rel,
202
+ )
203
+ )
204
+
205
+ # Supabase / Postgres SQL RLS check
206
+ if path.suffix.lower() == ".sql":
207
+ for m in CREATE_TABLE_RE.finditer(text):
208
+ tbl = m.group(1).strip('"`').lower().split(".")[-1]
209
+ tables_created[tbl] = rel
210
+ for m in ENABLE_RLS_RE.finditer(text):
211
+ tbl = m.group(1).strip('"`').lower().split(".")[-1]
212
+ tables_with_rls.add(tbl)
213
+ for m in CREATE_POLICY_RE.finditer(text):
214
+ stmt = m.group(1)
215
+ if POLICY_OPEN_TRUE_RE.search(stmt) and not POLICY_READONLY_RE.search(stmt):
216
+ policy_name = stmt.strip().splitlines()[0].split()[0].strip('"`')
217
+ findings.append(
218
+ Finding(
219
+ "database",
220
+ "WARN",
221
+ f"Permissive write RLS policy `{policy_name}` uses USING/WITH CHECK (true)",
222
+ "Scope write policies (ALL/INSERT/UPDATE/DELETE) to auth.uid() or a verified role.",
223
+ rel,
224
+ )
225
+ )
226
+
227
+ missing_rls = sorted(set(tables_created) - tables_with_rls)
228
+ for tbl in missing_rls:
229
+ findings.append(
230
+ Finding(
231
+ "database",
232
+ "WARN",
233
+ f"SQL table `{tbl}` has no ENABLE ROW LEVEL SECURITY statement",
234
+ "In Supabase, tables exposed in the public schema without RLS can be read or modified with the anon key.",
235
+ tables_created[tbl],
236
+ )
237
+ )
238
+
239
+ if public_secret_hits == 0 and hardcoded_hits == 0:
240
+ findings.append(Finding("secrets", "PASS", "No client-exposed secret env vars or hardcoded live keys found", str(repo_path)))
241
+ if unverified_webhooks == 0:
242
+ findings.append(Finding("payments", "PASS", "No unverified Stripe webhook handlers flagged", str(repo_path)))
243
+ if tables_created and not missing_rls:
244
+ findings.append(Finding("database", "PASS", f"All {len(tables_created)} SQL tables enable Row Level Security", str(repo_path)))
245
+
246
+ return findings
247
+
248
+
249
+ def _assert_public_host(url: str) -> str:
250
+ parsed = urllib.parse.urlparse(url)
251
+ if parsed.scheme not in {"http", "https"} or not parsed.hostname:
252
+ raise ValueError(f"Invalid HTTP(S) URL: {url}")
253
+ host = parsed.hostname
254
+ if host.lower() in {"localhost", "localhost.localdomain"}:
255
+ raise ValueError("Refusing to probe localhost/private addresses.")
256
+ try:
257
+ infos = socket.getaddrinfo(host, None)
258
+ except socket.gaierror as exc:
259
+ raise ValueError(f"Cannot resolve host {host}: {exc}") from exc
260
+ for info in infos:
261
+ ip = ipaddress.ip_address(info[4][0])
262
+ if ip.is_private or ip.is_loopback or ip.is_link_local or ip.is_reserved or ip.is_multicast:
263
+ raise ValueError(f"Refusing to probe non-public IP {ip} for host {host}.")
264
+ return url.rstrip("/")
265
+
266
+
267
+ def _fetch(url: str, headers: dict[str, str] | None = None, method: str = "GET") -> tuple[int, dict[str, str], str]:
268
+ req = urllib.request.Request(
269
+ url,
270
+ method=method,
271
+ headers={"User-Agent": "vibe-code-security-checklist/1.0", **(headers or {})},
272
+ )
273
+ try:
274
+ with urllib.request.urlopen(req, timeout=15) as resp:
275
+ body = resp.read(65536).decode("utf-8", "replace") if method == "GET" else ""
276
+ return resp.status, {k.lower(): v for k, v in resp.headers.items()}, body
277
+ except urllib.error.HTTPError as exc:
278
+ body = exc.read(4096).decode("utf-8", "replace") if method == "GET" else ""
279
+ return exc.code, {k.lower(): v for k, v in exc.headers.items()}, body
280
+
281
+
282
+ def check_url(url: str) -> list[Finding]:
283
+ findings: list[Finding] = []
284
+ try:
285
+ base = _assert_public_host(url)
286
+ except ValueError as exc:
287
+ return [Finding("url", "FAIL", "Invalid or non-public target URL", str(exc), url)]
288
+
289
+ try:
290
+ status, hdrs, _ = _fetch(base, method="GET")
291
+ except Exception as exc:
292
+ return [Finding("url", "FAIL", "Could not fetch target URL", str(exc), base)]
293
+
294
+ if status >= 400:
295
+ findings.append(Finding("headers", "WARN", f"Homepage returned HTTP {status}", "Verify the target URL.", base))
296
+
297
+ required = [
298
+ ("strict-transport-security", "HSTS missing", "Add Strict-Transport-Security: max-age=31536000; includeSubDomains."),
299
+ ("content-security-policy", "CSP missing", "Add a Content-Security-Policy header to limit XSS and script injection."),
300
+ ("x-content-type-options", "X-Content-Type-Options missing", "Set X-Content-Type-Options: nosniff."),
301
+ ("referrer-policy", "Referrer-Policy missing", "Set Referrer-Policy: strict-origin-when-cross-origin."),
302
+ ]
303
+ missing_count = 0
304
+ for key, title, detail in required:
305
+ if key not in hdrs:
306
+ missing_count += 1
307
+ findings.append(Finding("headers", "WARN", title, detail, base))
308
+
309
+ has_frame_guard = "x-frame-options" in hdrs or "frame-ancestors" in hdrs.get("content-security-policy", "").lower()
310
+ if not has_frame_guard:
311
+ missing_count += 1
312
+ findings.append(Finding("headers", "WARN", "Clickjacking protection missing", "Set X-Frame-Options: DENY or CSP frame-ancestors.", base))
313
+
314
+ if missing_count == 0:
315
+ findings.append(Finding("headers", "PASS", "Core security headers present", "HSTS, CSP, nosniff, referrer-policy, and framing protection found.", base))
316
+
317
+ # Non-destructive check for accidentally public dotfiles
318
+ exposed = []
319
+ for path, marker in [("/.env", "="), ("/.git/HEAD", "ref: refs/")]:
320
+ try:
321
+ code, c_hdrs, body = _fetch(base + path, method="GET")
322
+ ctype = c_hdrs.get("content-type", "")
323
+ if code == 200 and "text/html" not in ctype and marker in body:
324
+ exposed.append(path)
325
+ findings.append(Finding("exposure", "FAIL", f"Sensitive file exposed at {path}", "Block public access immediately and rotate any exposed credentials.", base + path))
326
+ except Exception:
327
+ continue
328
+ if not exposed:
329
+ findings.append(Finding("exposure", "PASS", "No public /.env or /.git/HEAD exposure detected", base))
330
+
331
+ return findings
332
+
333
+
334
+ def check_supabase(supabase_url: str, anon_key: str) -> list[Finding]:
335
+ try:
336
+ base = _assert_public_host(supabase_url)
337
+ except ValueError as exc:
338
+ return [Finding("supabase", "FAIL", "Invalid Supabase URL", str(exc), supabase_url)]
339
+
340
+ endpoint = f"{base}/rest/v1/"
341
+ try:
342
+ status, _, body = _fetch(endpoint, headers={"apikey": anon_key, "Authorization": f"Bearer {anon_key}"})
343
+ except Exception as exc:
344
+ return [Finding("supabase", "FAIL", "Could not reach Supabase REST endpoint", str(exc), endpoint)]
345
+
346
+ if status != 200:
347
+ return [Finding("supabase", "PASS", f"Supabase REST schema endpoint returned HTTP {status}", "Anonymous OpenAPI schema listing is not publicly readable.", endpoint)]
348
+
349
+ try:
350
+ spec = json.loads(body)
351
+ paths = [p.lstrip("/") for p in spec.get("paths", {}) if p != "/" and not p.startswith("/rpc/")]
352
+ except Exception:
353
+ return [Finding("supabase", "WARN", "Supabase REST endpoint returned non-JSON 200", "Inspect manually.", endpoint)]
354
+
355
+ if paths:
356
+ preview = ", ".join(sorted(paths)[:15])
357
+ suffix = f" (+{len(paths) - 15} more)" if len(paths) > 15 else ""
358
+ return [
359
+ Finding(
360
+ "supabase",
361
+ "WARN",
362
+ f"{len(paths)} tables listed in public PostgREST schema",
363
+ f"Tables visible to anon key: {preview}{suffix}. Verify Row Level Security (RLS) policies on every table.",
364
+ endpoint,
365
+ )
366
+ ]
367
+ return [Finding("supabase", "PASS", "No tables exposed in public PostgREST schema", endpoint)]
368
+
369
+
370
+ def main(argv: list[str] | None = None) -> int:
371
+ parser = argparse.ArgumentParser(description="Pre-launch security checker for AI-built web apps.")
372
+ parser.add_argument("--repo", type=Path, help="Local repository path to scan statically.")
373
+ parser.add_argument("--url", help="Public HTTPS URL to check headers and dotfile exposure (read-only).")
374
+ parser.add_argument("--supabase-url", help="Supabase project URL (https://<ref>.supabase.co) for read-only schema check.")
375
+ parser.add_argument("--anon-key", help="Supabase anon key (used with --supabase-url).")
376
+ parser.add_argument("--json", action="store_true", help="Output JSON.")
377
+ args = parser.parse_args(argv)
378
+
379
+ if not args.repo and not args.url and not args.supabase_url:
380
+ parser.print_help()
381
+ return 2
382
+
383
+ findings: list[Finding] = []
384
+ if args.repo:
385
+ findings.extend(check_repo(args.repo))
386
+ if args.url:
387
+ findings.extend(check_url(args.url))
388
+ if args.supabase_url:
389
+ if not args.anon_key:
390
+ print("Error: --anon-key is required with --supabase-url", file=sys.stderr)
391
+ return 2
392
+ findings.extend(check_supabase(args.supabase_url, args.anon_key))
393
+
394
+ if args.json:
395
+ print(json.dumps([asdict(f) for f in findings], indent=2))
396
+ else:
397
+ for f in findings:
398
+ loc = f" ({f.location})" if f.location else ""
399
+ print(f"[{f.severity:4s}] [{f.area}] {f.title}{loc}")
400
+ if f.detail:
401
+ print(f" {f.detail}")
402
+
403
+ return 1 if any(f.severity == "FAIL" for f in findings) else 0
404
+
405
+
406
+ if __name__ == "__main__":
407
+ raise SystemExit(main())
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "vibe-code-security-checklist"
7
+ version = "0.1.0"
8
+ description = "Zero-dependency pre-launch security checker for Cursor, Lovable, Bolt, Next.js, Supabase, and Stripe apps."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Dmitry (Dee) Kargaev", email = "hi@deeflect.com" }]
13
+ keywords = ["security", "supabase", "stripe", "nextjs", "lovable", "cursor", "bolt", "checklist", "cli"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Environment :: Console",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Programming Language :: Python :: 3",
20
+ "Topic :: Security",
21
+ ]
22
+
23
+ [project.urls]
24
+ Homepage = "https://shipmate.agency"
25
+ Repository = "https://github.com/deeflect/vibe-code-security-checklist"
26
+ Issues = "https://github.com/deeflect/vibe-code-security-checklist/issues"
27
+
28
+ [project.scripts]
29
+ vibe-code-check = "vibe_code_security_checklist:main"
30
+ vibe-code-security-checklist = "vibe_code_security_checklist:main"
31
+
32
+ [tool.hatch.build.targets.wheel]
33
+ only-include = []
34
+
35
+ [tool.hatch.build.targets.wheel.force-include]
36
+ "check.py" = "vibe_code_security_checklist.py"
37
+
38
+ [tool.hatch.build.targets.sdist]
39
+ include = ["check.py", "test_check.py", "README.md", "LICENSE", "pyproject.toml"]
@@ -0,0 +1,84 @@
1
+ import tempfile
2
+ import unittest
3
+ from pathlib import Path
4
+
5
+ import check
6
+
7
+
8
+ class TestVibeCodeSecurityChecklist(unittest.TestCase):
9
+ def test_clean_repo_passes(self) -> None:
10
+ with tempfile.TemporaryDirectory() as tmp:
11
+ root = Path(tmp)
12
+ (root / ".gitignore").write_text(".env\nnode_modules\n")
13
+ (root / "schema.sql").write_text(
14
+ "CREATE TABLE public.orders (id uuid primary key);\n"
15
+ "ALTER TABLE public.orders ENABLE ROW LEVEL SECURITY;\n"
16
+ )
17
+ (root / "stripe_webhook.ts").write_text(
18
+ "const sig = req.headers.get('stripe-signature');\n"
19
+ "const event = stripe.webhooks.constructEvent(rawBody, sig, process.env.STRIPE_WEBHOOK_SECRET);\n"
20
+ )
21
+ findings = check.check_repo(root)
22
+ self.assertFalse(any(f.severity in {"FAIL", "WARN"} for f in findings), findings)
23
+
24
+ def test_detects_exposed_client_secret_and_hardcoded_key(self) -> None:
25
+ with tempfile.TemporaryDirectory() as tmp:
26
+ root = Path(tmp)
27
+ (root / "client.ts").write_text(
28
+ "const k = process.env.NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY;\n"
29
+ "const s = 'sk_live_1234567890abcdef123456';\n"
30
+ )
31
+ findings = check.check_repo(root)
32
+ fails = [f for f in findings if f.severity == "FAIL"]
33
+ self.assertEqual(len(fails), 2, findings)
34
+
35
+ def test_detects_missing_rls_and_unverified_stripe_webhook(self) -> None:
36
+ with tempfile.TemporaryDirectory() as tmp:
37
+ root = Path(tmp)
38
+ (root / "001_init.sql").write_text("CREATE TABLE public.invoices (id int);\n")
39
+ (root / "api_stripe_webhook.ts").write_text(
40
+ "export async function POST(req) { const body = await req.json(); if (body.type === 'checkout.session.completed') unlock(); }\n"
41
+ )
42
+ findings = check.check_repo(root)
43
+ warns = {f.area for f in findings if f.severity == "WARN"}
44
+ self.assertIn("database", warns)
45
+ self.assertIn("payments", warns)
46
+
47
+ def test_refuses_localhost_and_private_ips(self) -> None:
48
+ for bad in ["http://localhost:3000", "http://127.0.0.1:8080", "http://169.254.169.254/latest/meta-data"]:
49
+ findings = check.check_url(bad)
50
+ self.assertEqual(findings[0].severity, "FAIL")
51
+
52
+ def test_detects_ai_keys_and_service_role_jwt_not_anon(self) -> None:
53
+ import base64, json
54
+ hdr = base64.urlsafe_b64encode(b'{"alg":"HS256","typ":"JWT"}').decode().rstrip("=")
55
+ srv = base64.urlsafe_b64encode(json.dumps({"iss": "supabase", "role": "service_role"}).encode()).decode().rstrip("=")
56
+ anon = base64.urlsafe_b64encode(json.dumps({"iss": "supabase", "role": "anon"}).encode()).decode().rstrip("=")
57
+ with tempfile.TemporaryDirectory() as tmp:
58
+ root = Path(tmp)
59
+ (root / "ok.ts").write_text(f"export const ANON = '{hdr}.{anon}.signature12345';\n")
60
+ self.assertFalse(any(f.severity == "FAIL" for f in check.check_repo(root)))
61
+ (root / "leak.ts").write_text(
62
+ f"const a = 'sk-ant-api03-1234567890abcdefghijklmno';\n"
63
+ f"const o = 'sk-proj-1234567890abcdefghijklmno';\n"
64
+ f"const j = '{hdr}.{srv}.signature12345';\n"
65
+ )
66
+ fails = [f for f in check.check_repo(root) if f.severity == "FAIL"]
67
+ self.assertEqual(len(fails), 3, fails)
68
+
69
+ def test_detects_open_write_rls_policy_allows_select(self) -> None:
70
+ with tempfile.TemporaryDirectory() as tmp:
71
+ root = Path(tmp)
72
+ (root / "policies.sql").write_text(
73
+ "CREATE TABLE public.posts (id int);\n"
74
+ "ALTER TABLE public.posts ENABLE ROW LEVEL SECURITY;\n"
75
+ "CREATE POLICY public_read ON public.posts FOR SELECT USING (true);\n"
76
+ "CREATE POLICY dev_all ON public.posts FOR ALL USING (true) WITH CHECK (true);\n"
77
+ )
78
+ warns = [f for f in check.check_repo(root) if f.severity == "WARN"]
79
+ self.assertEqual(len(warns), 1, warns)
80
+ self.assertIn("dev_all", warns[0].title)
81
+
82
+
83
+ if __name__ == "__main__":
84
+ unittest.main()