Sample Deliverable: Redacted
A redacted deliverable from a one-week VERKRIT code audit. We inspect repository git history, database schemas, API contracts, security perimeters, and infrastructure cost leaks to deliver a prioritized technical roadmap.
Turnaround
5 business days
Repository Scope
42,000 LOC, 38 tables
Access Required
Read-only Git and Schema
Primary Deliverable
Report and 30-Day Backlog
01Executive Assessment
Readiness score and go/no-go recommendation
Authentication and billing flaws prevent a safe public launch. The prototype works in demos, but cannot safely process external customer credit cards or multi-tenant documents until the three critical findings are patched.
Permissive RLS and leaked client OpenAI secret
N+1 query cascades on dashboard overview
Business logic coupled inside React components
Missing Stripe idempotency check and retry handling
Vercel deploy works; temporary SQLite files wiped
No integration tests on critical payment paths
02Risk Register
Detailed findings and fixes
Permissive Supabase RLS policy exposes entire multi-tenant user table
File: supabase/migrations/20261101_users_table.sql
Observed Defect
Row Level Security (RLS) is enabled on the profiles table, but the SELECT policy was generated with USING (true). Any client holding the public anon key can read all user records, emails, and organization IDs through direct REST calls.
// Vulnerable policy generated by AI prototype:
CREATE POLICY "Allow public read"
ON public.profiles
FOR SELECT
USING (true);// Correct tenant-isolated policy:
DROP POLICY IF EXISTS "Allow public read" ON public.profiles;
CREATE POLICY "Users read own profile"
ON public.profiles
FOR SELECT
USING (auth.uid() = id);OpenAI API secret key leaked in client-side JavaScript bundle
File: src/components/PromptAssistant.tsx
Observed Defect
The client component initializes the OpenAI SDK directly using process.env.OPENAI_API_KEY. Because bundlers include this code in client chunks, the secret key is visible in browser network and script inspection.
// Vulnerable client component:
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY, // Secret baked into public client bundle!
dangerouslyAllowBrowser: true,
});// Remediated: Route through an authenticated Server Route Handler
// app/api/assistant/route.ts
import { auth } from "@/lib/auth";
import { openai } from "@/lib/server-openai";
export async function POST(req: Request) {
const session = await auth();
if (!session) return new Response("Unauthorized", { status: 401 });
// Call OpenAI securely on the server with user rate limiting
}Missing idempotency in Stripe webhook handler causes duplicate subscriptions
File: app/api/webhooks/stripe/route.ts
Observed Defect
When Stripe retries invoice.paid or customer.subscription.created events after transient network lag, the endpoint credits user balances twice without checking whether the event ID was already processed.
// Missing idempotency check:
export async function POST(req: Request) {
const event = stripe.webhooks.constructEvent(...);
if (event.type === "invoice.paid") {
await db.user.update({ where: { id: userId }, data: { credits: { increment: 500 } } });
}
}// Remediated: Atomic transaction check using event.id
export async function POST(req: Request) {
const event = stripe.webhooks.constructEvent(...);
const processed = await db.processedEvents.create({
data: { id: event.id, type: event.type }
}).catch(() => null);
if (!processed) return new Response("Event already processed", { status: 200 });
// Process balance credit safely
}N+1 database query loop in workspace team dashboard
File: src/pages/WorkspaceOverview.tsx
Observed Defect
The overview page loads a workspace with 40 members, then maps over every member running individual queries for their open tasks and completed runs. This triggers 81 sequential roundtrips to Postgres. At 30 concurrent users, connection pool exhaustion causes 504 gateway timeouts.
// Inefficient sequential loop:
const members = await getWorkspaceMembers(workspaceId);
const stats = await Promise.all(
members.map(async (m) => ({
member: m,
tasks: await getMemberTasks(m.id), // 40 separate queries!
}))
);// Remediated: Single batch join with JSON aggregation
SELECT m.id, m.name, json_agg(t.*) as tasks
FROM workspace_members m
LEFT JOIN tasks t ON t.assignee_id = m.id
WHERE m.workspace_id = $1
GROUP BY m.id;Ephemeral SQLite database wiped on container redeployment
File: src/lib/cache.ts
Observed Defect
A local SQLite file inside /tmp/preview-cache.db stores intermediate document vectors. Every Vercel or container redeployment rebuilds the container image, deleting the SQLite file and triggering an unnecessary four-hour re-indexing run.
// Dangerous local path in containerized deployment:
import Database from "better-sqlite3";
const db = new Database("/tmp/preview-cache.db");// Remediated: Centralized Redis or Postgres cache table
import { Redis } from "@upstash/redis";
const redis = Redis.fromEnv();03Execution Roadmap
Recommended 30-day remediation plan
Our audit categorizes every issue into Keep, Refactor, or Rebuild. Engineering effort focuses strictly on what unblocks launch.
Unblock launch and fix security
- ✓Patch Supabase RLS policies across all 38 tables
- ✓Revoke leaked OpenAI API key and rotate through Next.js server actions
- ✓Add idempotency checks to the Stripe webhook handler
Reliability and database scaling
- ✓Refactor N+1 queries into indexed batch joins
- ✓Migrate ephemeral SQLite cache to Upstash Redis
- ✓Write Playwright integration tests for payment and login flows
Hardening and handover
- ✓Set up error tracking and alert routing
- ✓Produce architecture diagrams and disaster recovery runbooks
- ✓Pair with your internal developers for a clean handover
What the one-week audit includes
- • Code inspection across repository (up to 50,000 LOC)
- • Database schema health, indexing, and connection pool review
- • Security vulnerability scan for RLS, secrets, IDOR, and auth flow
- • Cloud infrastructure and LLM token expense audit
- • 60-minute findings presentation call with senior engineers
- • Written report, executive scorecard, and prioritized 30-day backlog
Audit boundaries and guarantees
- • Mutual Non-Disclosure Agreement (NDA) signed before repo access
- • Read-only repository and infrastructure access
- • Zero disruption to ongoing development or active users
- • Fixed scope and fixed fee without billing surprises
- • Delivered within five business days