Pre-launch security audit
Run a six-layer pre-publish security audit across secrets, row-level privacy, admin routes, uploads, Stripe webhooks, and privacy compliance before launch.
Why every founder needs a pre-launch security audit
ExaSpark secures the platform foundation automatically: automatic HTTPS/TLS certificates, encrypted server-side secret configuration, isolated Preview vs Live environments, managed authentication across 19+ providers, and Stripe-hosted checkouts where payment card numbers never touch your database. See Security & data ownership.
Yet application-level business rules belong uniquely to your product. Only your app knows whether Member A should read Invoice #104, which file types clients are allowed to upload, or whether a discount coupon can stack.
Running this concrete six-layer security audit in Preview takes twenty minutes and catches the vast majority of real-world web vulnerabilities before a single customer creates an account on Live.
The six-layer pre-launch audit matrix
Review all six layers against your app before publishing to customers or running paid traffic.
| Audit layer | Classic startup vulnerability | How to verify in Preview | Pass criterion |
|---|---|---|---|
| 1. Server-side secrets | Private API keys or Stripe secrets pasted into client code or public repos | Search Code and DevTools Sources for sk_, whsec_, or vendor tokens | Zero private secrets appear in browser bundles or public copy |
| 2. Row-level privacy (IDOR) | Member A changes /bookings/104 to /bookings/105 and views Member B's data | Copy Member B's record URL and open it signed in as Member A | Server returns 403 or 404 with zero leaked fields |
| 3. Admin routes & RBAC | Admin UI button is hidden, but /api/admin/... still accepts member cookies | Call admin endpoints or visit /admin signed in as a standard member | Server enforces role === 'admin' and returns 403 Forbidden |
| 4. Upload validation | Guests upload executable scripts, oversized files, or read private PDFs publicly | Upload invalid file types and open private file URLs in Incognito | Strict MIME/size limits enforced; private files require owner/admin session |
| 5. Stripe webhook & pricing | Frontend sends price=1 or unlocks access purely from /checkout/success | Probe /checkout/success directly and inspect webhook signature handler | Prices load server-side; unlocks happen only after signed webhook verification |
| 6. Privacy & GDPR hygiene | Missing Privacy Policy, over-collected fields, or Preview dummy data in Live | Click legal footer links, inspect forms, and audit Cloud → Live tables | Live policies accurate, minimal fields collected, zero test PII in Live |
Layer 1: Server-side secrets and client bundle hygiene
Anything shipped to a visitor's browser is inspectable in DevTools. Confirm a clean wall between public configuration and private credentials:
- Keep secrets strictly server-side: Stripe secret keys (
sk_live_...), webhook secrets (whsec_...), email keys, and vendor tokens belong strictly in server-side configuration — never in React code or page copy. See Secrets & env vars. - Proxy third-party APIs on the server: Route external authenticated requests through your own backend endpoint so private headers never reach browser DevTools.
- Audit GitHub exports: Before pushing via the Official GitHub App, confirm zero
.envfiles, hardcoded keys, or sample customer CSVs sit inside exported source files.
Layer 2: Row-level data privacy and IDOR checks
The most frequent vulnerability in multi-user apps is IDOR (Insecure Direct Object Reference) — omitting ownership checks on detail, edit, or delete routes.
Because every customer shares the member role, every member-scoped route must enforce record.user_id === session.user.id (unless the caller is staff or admin). See Row-level data privacy.
Also enforce field projection on public lists: return only safe display fields (display_name, avatar_url), never email, phone, or stripe_customer_id.
Layer 3: Admin routes, RBAC, and mass-assignment hardening
Hiding an Admin button in navigation improves usability, never security. Verify three server-side controls on every write endpoint:
- Server-enforced admin gates: Every
/api/admin/*route (exports, role edits, pricing, refunds) must verifysession.user.role === 'admin'and return401or403. - Safe default registration: Public sign-up always assigns
role = 'member'server-side and ignores client-supplied role fields. Promote admins inside Cloud. See Authentication & roles. - Strict field allowlists: Profile update routes (
PATCH /api/profile) must explicitly pick editable fields (full_name,phone,timezone) instead of blindly writing raw JSON keys likeroleorplan.
Server-Side Route Audit Checklist
------------------------------------------------------------------
[ ] Every private route reads user_id strictly from verified server session
[ ] Detail routes (/api/orders/:id) enforce owner OR staff/admin check
[ ] Every /api/admin/* route rejects non-admin sessions with HTTP 403
[ ] Registration ignores client role and defaults strictly to "member"
[ ] Update routes whitelist allowed fields (no blind req.body spread)
[ ] Public endpoints strip email, phone, tokens, and Stripe IDsLayer 4: File upload validation and storage scoping
Untrusted uploads and sensitive customer documents require four concrete server-side rules:
- Strict MIME allowlists: Allow only safe formats (
image/jpeg,image/png,image/webp, orapplication/pdf) and reject scripts, HTML, or unsanitized SVGs. - Server-side size limits: Enforce explicit byte caps (
5 MBavatars,10 MBPDFs) on the server, not just browser inputs. - Randomized storage keys: Generate unpredictable UUID paths rather than sequential numbers or raw user filenames (
../../). - Scoped bucket access: Keep public catalog photos public-read, while requiring owner or admin sessions for private invoices, IDs, or intake uploads. See File storage and Media uploads & limits.
Layer 5: Stripe webhook verification and server-side pricing
Never trust prices, discounts, or paid=true parameters sent from the browser:
- Server-side price lookup: Send only the plan or item ID from the browser; look up authoritative cents amounts or Stripe Price IDs on the server.
- Signed webhook verification: Validate the
Stripe-Signatureheader against the exact raw request body using your server-side signing secret before mutating Cloud. - Webhook-driven unlocks with idempotency: Never unlock access from
/checkout/successalone, and store processed Stripe event IDs so duplicate deliveries never double-credit balances. See Testing & subscriptions.
Layer 6: GDPR, privacy notices, and data hygiene
Clean privacy practices build buyer trust, satisfy Google Play Data Safety checks, and keep your app aligned with GDPR and CCPA expectations:
- Live Privacy Policy and Terms: State plainly what personal data you collect, which processors handle payments (Stripe), and a working privacy contact email.
- Data minimization: Collect only fields your workflow genuinely needs — fewer stored fields reduce breach risk and raise conversion.
- Deletion, export, and consent: Provide a clear path for users to delete accounts or request data exports, keep transactional receipts separate from marketing mail, honor unsubscribes immediately, and include an unticked opt-in box where local law requires prior consent.
- Clean Live database: Verify Cloud → Live holds zero dummy test accounts or test PII before announcing launch. See Preview vs Live.
Running the 20-minute Preview security walkthrough
Execute this six-step test in Preview before clicking Publish:
Probe as a signed-out Guest
Visit
/dashboard,/admin, and private/api/...routes in Incognito; confirm pages redirect to/loginand APIs return401.Test Member A vs Member B (IDOR)
Open a record ID owned by Member B while signed in as Member A; confirm the server returns
403or404.Probe admin routes and field tampering
Try opening
/adminand modifyingrolefrom a standard member session; confirm strict403enforcement.Test disallowed uploads and private URLs
Upload an unsupported file type and paste a private file URL into Incognito to confirm both fail cleanly.
Test Stripe checkout manipulation
Visit
/checkout/successunpaid and run a declined test card (4000 0000 0000 0002); confirm zero paid rows appear in Cloud.Verify Live DevTools and legal links
After Publish, inspect Live Network and Sources for zero leaked keys, verify footer legal pages, and review ExaSpark's commitments on Security, Privacy Policy, and Terms of Service.
Copyable pre-launch security audit prompt
Run this focused audit prompt in Preview before shipping a major user-facing release:
Run a pre-launch security audit across all backend API routes, database queries, file uploads, and Stripe webhooks. Verify and fix: (1) zero secret keys in frontend code, (2) server-side ownership (`record.user_id === session.user.id`) or role checks on every private read/write route, (3) server-enforced `role === 'admin'` on `/api/admin/*` and strict field allowlists on updates, (4) MIME/size limits and owner-scoped reads on private uploads, (5) server-side pricing plus signed, idempotent Stripe webhooks, and (6) no email or billing IDs leaked in public responses. Summarize every route audited and fixed.