AI Vibing

Protect Your Vibe-Coded App from SQL Injection in 3 Steps

Skill level
Intermediate
Time to implement
60 min
Cost
Free
Platform
Instagram
Tools
Claude, ChatGPT
Outcomes
Saves time
Last verified
Nov 14, 2026
PS

Peter A Surowski

@petersurowskiIG

Original strategy by Peter A Surowski. Watch the original on Instagram.

Summary

SQL injection is one of the oldest and most destructive attacks: someone types database code into a username, password, or search field, and a badly built server runs it, exposing or even deleting your data. If you build apps with AI and have never checked, you may not know whether you are exposed. The good news is that it is also one of the easiest attacks to prevent. This playbook covers the creator's three defenses and adds a quick AI-assisted audit so you can check an existing app.

Set upWhat you need

  • Access to your app's code, especially anything that talks to the database (API routes, server functions, backend files)

  • An AI coding assistant such as Claude, Cursor, or ChatGPT to help audit and fix queries

  • A test account or local copy of your app, never production data, for trying fixes

  • The free OWASP SQL Injection Prevention Cheat Sheet for reference

  • About 60 minutes for a first audit

ToolsClaudeChatGPT

Do thisStep by step

  1. 1

    Validate user input on the client

    Check that every field looks like what it should be. If it is a username field, make sure it looks like a username, with no curly braces or anything that looks like computer code. Reel Playbooks addition: use an allow-list pattern, for example usernames matching ^[a-zA-Z0-9_]{3,30}$, and set length limits. Client-side checks improve the user experience, but attackers can skip them, so never rely on them alone.

  2. 2

    Validate and sanitize again on the server

    Do the same checks on the server side in case something slips through, removing code-looking characters such as curly braces and semicolons. Reel Playbooks addition: on the server, prefer rejecting input that fails your allow-list over trying to strip characters out; stripping is easy to get wrong and is not a reliable defense by itself. Treat this step as a second layer, not the fix.

  3. 3

    Use parameterized queries everywhere

    Make sure your SQL queries are parameterized. Never paste the username (or any user input) straight into the query text. Reel Playbooks addition: this is the primary defense recommended by OWASP. Unsafe: "SELECT * FROM users WHERE name = '" + username + "'". Safe: SELECT * FROM users WHERE name = $1 with the username passed separately as a parameter. Most ORMs and database clients (Prisma, Drizzle, Supabase client, SQLAlchemy) parameterize for you, as long as you avoid their raw SQL functions with string-built queries.

  4. 4

    Have your AI assistant audit the codebase

    Reel Playbooks addition: paste this into your coding assistant: "Find every place in this project that builds a database query. List any that combine user input into SQL with string concatenation, template literals, or raw query functions. For each one, show the file and line, explain the risk, and rewrite it as a parameterized query. Do not change anything else." Review each fix, then test the affected forms.

  5. 5

    Test your fixes safely

    Reel Playbooks addition: on a local or test copy, try typing a classic test value such as ' OR '1'='1 into your login and search fields. A protected app treats it as plain text and simply fails to log in or returns no results. Never run tests like this against apps you do not own.

Heads upCommon mistakes & tips

  • Parameterized queries are the real fix. Validation and sanitizing help, but they are backups, not replacements.

  • Watch for raw SQL escape hatches in ORMs (functions with names like raw, unsafe, or execute that accept a string); AI assistants often reach for them.

  • Give your app's database user only the permissions it needs, so even a successful attack cannot drop tables.

  • Keep regular database backups so a worst-case deletion is recoverable.

  • Re-run the audit prompt after every major AI-built feature; new code can reintroduce old mistakes.

MeasureHow to know it worked

Your AI audit returns no remaining string-built queries, every database call passes user input as a parameter, and test values like ' OR '1'='1 are treated as ordinary text in your login and search forms. Server logs show rejected inputs from validation rather than database errors.

ProvenanceSource & adaptation notes

Original

The reel explains SQL injection (database code typed into a username or password field that a badly built server runs) and gives three defenses: validate user input so fields only contain what they should, sanitize input again on the server by removing code-looking characters like curly braces and semicolons, and use parameterized queries instead of pasting the username into the query.

Reel Playbooks additions

Reel Playbooks additions: allow-list validation examples, the note that rejecting beats stripping and that sanitizing is a second layer, unsafe vs safe query examples and ORM guidance, an AI audit prompt, a safe local test, least-privilege database users, backups, raw SQL warnings, re-auditing after new features, and a link to OWASP's prevention cheat sheet.

AttributionCredit

Original tip by Peter A Surowski (@petersurowski) on Instagram (watch the original reel).

Adapted from @petersurowski's video; steps expanded by Reel Playbooks.

Watch the original video

Reel Playbooks credits and links to the original creator. See For creators to request changes or removal.

BG