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.

Target:B2B AI Workflow PlatformNext.js 14SupabaseOpenAIStripe

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

Overall Score
54/ 100
Launch Blocked (High Risk)

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.

Security & Permissions35/100

Permissive RLS and leaked client OpenAI secret

Performance & Database45/100

N+1 query cascades on dashboard overview

Architecture & Code Hygiene58/100

Business logic coupled inside React components

Reliability & Webhooks62/100

Missing Stripe idempotency check and retry handling

Deployment & Infrastructure70/100

Vercel deploy works; temporary SQLite files wiped

Automated Test Coverage12/100

No integration tests on critical payment paths

02Risk Register

Detailed findings and fixes

SEC-01·CriticalSecurity
CVSS: 9.1 (Critical)

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.

Defective Code / Vulnerability
// Vulnerable policy generated by AI prototype:
CREATE POLICY "Allow public read"
ON public.profiles
FOR SELECT
USING (true);
Remediation
// 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);
Estimated Remediation Effort0.5 engineering days
SEC-02·CriticalSecurity
CVSS: 8.9 (Critical)

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.

Defective Code / Vulnerability
// 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,
});
Remediation
// 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
}
Estimated Remediation Effort1.0 engineering day
REL-01·HighReliability

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.

Defective Code / Vulnerability
// 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 } } });
  }
}
Remediation
// 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
}
Estimated Remediation Effort1.0 engineering day
PERF-01·HighPerformance

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.

Defective Code / Vulnerability
// 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!
  }))
);
Remediation
// 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;
Estimated Remediation Effort1.5 engineering days
OPS-01·MediumOperations

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.

Defective Code / Vulnerability
// Dangerous local path in containerized deployment:
import Database from "better-sqlite3";
const db = new Database("/tmp/preview-cache.db");
Remediation
// Remediated: Centralized Redis or Postgres cache table
import { Redis } from "@upstash/redis";
const redis = Redis.fromEnv();
Estimated Remediation Effort0.5 engineering days

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.

Sprint 1: Days 1 to 5

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
Outcome: Security vulnerabilities resolved; safe for alpha testers.
Sprint 2: Days 6 to 15

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
Outcome: Concurrency sustained up to 500 RPS without timeouts.
Sprint 3: Days 16 to 30

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
Outcome: Platform operated independently by in-house team.

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
Ready to find out what blocks your prototype?Schedule an Introductory Call