Bolt security

SQL Injection in Bolt AI-Generated Database Queries

Your Bolt.new application contains SQL injection vulnerabilities in its database queries. The AI-generated code concatenates user input directly into SQL strings instead of using parameterized queries, allowing attackers to manipulate your database.

An attacker can exploit this by entering specially crafted input into form fields, search boxes, or URL parameters. For example, entering ' OR 1=1 -- into a login form could bypass authentication entirely, or entering '; DROP TABLE users; -- could delete your entire users table.

This vulnerability is particularly dangerous because it can go completely unnoticed during normal use. The app works perfectly with legitimate input, but an attacker with basic SQL knowledge can read, modify, or delete any data in your database.

Error Messages You Might See

Error: syntax error at or near "'" PrismaClientKnownRequestError: Raw query failed ERROR: unterminated quoted string at or near "' OR" Database query returned unexpected number of rows
Error: syntax error at or near "'"PrismaClientKnownRequestError: Raw query failedERROR: unterminated quoted string at or near "' OR"Database query returned unexpected number of rows

Common Causes

  • String concatenation in queries — Bolt generated code like `SELECT * FROM users WHERE id = '${userId}'` instead of using parameterized queries
  • Raw SQL with template literals — Using Prisma's $queryRawUnsafe or Supabase's rpc with unsanitized user input
  • Dynamic table or column names — Building queries with user-controlled table names or sort columns without whitelisting
  • Search functionality with LIKE — Search queries built by concatenating user input: WHERE name LIKE '%${searchTerm}%'
  • Filter parameters passed directly — URL query parameters inserted into WHERE clauses without sanitization

How to Fix It

  1. Use parameterized queries everywhere — Replace string concatenation with parameterized queries: prisma.$queryRaw`SELECT * FROM users WHERE id = ${userId}`
  2. Use Prisma's query builder — Let Prisma handle parameterization: prisma.user.findMany({ where: { name: { contains: searchTerm } } })
  3. Whitelist dynamic identifiers — If you need dynamic column names, validate them against an allowlist: const allowed = ['name', 'date', 'price']; if (!allowed.includes(sortBy)) throw new Error('Invalid sort')
  4. Use Supabase client safely — The Supabase JS client automatically parameterizes: supabase.from('users').select().eq('id', userId)
  5. Test with SQLi payloads — Enter ' OR 1=1 -- into your form fields and search boxes to check if they return unexpected results
  6. Add input validation — Validate and sanitize all user inputs with a library like zod or validator.js before they reach any query

Real developers can help you.

Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Antriksh Narang Antriksh Narang 5 years+ Experienced Dev (Specially in Web Development), can help in python, javascript, react, next.js and full stack web dev technologies. Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience zipking zipking I am a technologist and product builder dedicated to creating high-impact solutions at the intersection of AI and specialized markets. Currently, I am focused on PropScan (EstateGuard), an AI-driven SaaS platform tailored for the Japanese real estate industry, and exploring the potential of Archify. As an INFJ-T, I approach development with a "systems-thinking" mindset—balancing technical precision with a deep understanding of user needs. I particularly enjoy the challenge of architecting Vertical AI SaaS and optimizing Small Language Models (SLMs) to solve specific, real-world business problems. Whether I'm in a CTO-level leadership role or hands-on with the code, I thrive on building tools that turn complex data into actionable value. Yovel Cohen Yovel Cohen I got a lot of experience in building Long-horizon AI Agents in production, Backend apps that scale to millions of users and frontend knowledge as well. Jen Jacobsen Jen Jacobsen I’m a Full-Stack Developer with over 10 years of experience building modern web and mobile applications. I enjoy working across the full product lifecycle — turning ideas into real, well-built products that are intuitive for users and scalable for businesses. I particularly enjoy building mobile apps, modern web platforms, and solving complex technical problems in a way that keeps systems clean, reliable, and easy to maintain. Matt Butler Matt Butler Software Engineer @ AWS Jared Hasson Jared Hasson Full time lead founding dev at a cyber security saas startup, with 10 yoe and a bachelor's in CS. Building & debugging software products is what I've spent my time on for forever Kingsley Omage Kingsley Omage Fullstack software engineer passionate about AI Agents, blockchain, LLMs. Matthew Jordan Matthew Jordan I've been working at a large software company named Kainos for 2 years, and mainly specialise in Platform Engineering. I regularly enjoy working on software products outside of work, and I'm a huge fan of game development using Unity. I personally enjoy Python & C# in my spare time, but I also specialise in multiple different platform-related technologies from my day job.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help

Frequently Asked Questions

Is Prisma safe from SQL injection by default?

Prisma's query builder (findMany, create, etc.) is safe by default. However, Prisma's $queryRaw requires tagged template literals for safety. Using $queryRawUnsafe or string concatenation with $queryRaw bypasses protection.

How can I test my app for SQL injection?

Enter these payloads in text fields: ' OR 1=1 --, '; DROP TABLE test; --, and ' UNION SELECT null, null --. If the app behaves unexpectedly (returns all records, errors with SQL syntax), you have a vulnerability.

Related Bolt Issues

Can't fix it yourself?
Real developers can help.

You don't need to be technical. Just describe what's wrong and a verified developer will handle the rest.

Get Help