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.

Anthony Akpan Anthony Akpan Developer with 8 years of experience building softwares fro startups Dor Yaloz Dor Yaloz SW engineer with 6+ years of experience, I worked with React/Node/Python did projects with React+Capacitor.js for ios Supabase expert Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Luca Liberati Luca Liberati I work on monoliths and microservices, backends and frontends, manage K8s clusters and love to design apps architecture rayush33 rayush33 JavaScript (React.js, React Native, Node.js) Developer with demonstrated industry experience of 4+ years, actively looking for opportunities to hone my skills as well as help small-scale business owners with solutions to technical problems Omar Faruk Omar Faruk As a Product Engineer at Klasio, I contributed to end-to-end product development, focusing on scalability, performance, and user experience. My work spanned building and refining core features, developing dynamic website templates, integrating secure and reliable payment gateways, and optimizing the overall system architecture. I played a key role in creating a scalable and maintainable platform to support educators and learners globally. I'm enthusiastic about embracing new challenges and making meaningful contributions. Bastien Labelle Bastien Labelle Full stack dev w/ 20+ years of experience Rudra Bhikadiya Rudra Bhikadiya I build and fix web apps across Next.js, Node.js, and DBs. Comfortable jumping into messy code, broken APIs, and mysterious bugs. If your project works in theory but not in reality, I help close that gap. Meïr Ankri Meïr Ankri Full-stack developer specializing in React / Next.js / Node.js with 6+ years of experience. I've worked across various sectors including automotive (Reezocar/Société Générale), healthcare (Medical Link SaaS), and e-commerce (Glasman). I build web apps end-to-end, from architecture to production, with a focus on scalability, performance, and code quality. I also mentor junior developers and contribute to technical decisions and code reviews. hanson1014 hanson1014 Full-stack developer experienced in fixing and deploying AI-generated apps from Lovable, Bolt.new, Cursor, and Replit. I specialize in debugging Supabase integration issues (auth flows, RLS policies, database connections), fixing broken deployments, resolving routing/blank screen problems, and cleaning up messy React/Vite codebases. I also build production apps with the Claude API and have shipped a Mac desktop dev tool (Nexterm from scratch. Based in Hong Kong, fast turnaround.

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