Bolt security

Missing Input Sanitization in Bolt App Forms

Your Bolt.new application accepts user input from forms, URL parameters, and API requests without validating or sanitizing it. This leaves your app vulnerable to cross-site scripting (XSS), HTML injection, data corruption, and other attacks that exploit unfiltered input.

When Bolt generates form handling code, it often passes user input directly to the database or renders it on the page without checking for malicious content. A user could submit a script tag in a comment field, an extremely long string that breaks your layout, or special characters that corrupt your data.

The consequences range from cosmetic issues (broken layouts) to critical security breaches (stolen user sessions, defaced pages, or unauthorized data access). This is one of the most common security gaps in AI-generated applications.

Error Messages You Might See

Warning: Each child in a list should have a unique key prop Content Security Policy violation: inline script blocked Unhandled Runtime Error: Objects are not valid as a React child XSS payload detected in input field
Warning: Each child in a list should have a unique key propContent Security Policy violation: inline script blockedUnhandled Runtime Error: Objects are not valid as a React childXSS payload detected in input field

Common Causes

  • No server-side validation — Form data is accepted and stored without checking type, length, or format on the backend
  • Using dangerouslySetInnerHTML — Bolt generated React components that render user content as raw HTML, enabling XSS
  • Client-only validation — Validation exists in the form component but not in the API route, so it can be bypassed with a direct API call
  • No Content Security Policy — Missing CSP headers allow injected scripts to execute freely
  • Rich text editors without sanitization — WYSIWYG editors that save and display raw HTML from users
  • URL parameters used directly — Query string values rendered on the page without escaping

How to Fix It

  1. Add server-side validation with Zod — Define strict schemas: const schema = z.object({ name: z.string().min(1).max(100), email: z.string().email() }); and validate every API input
  2. Never use dangerouslySetInnerHTML with user data — Replace it with regular JSX text rendering: {userComment} instead of dangerouslySetInnerHTML={{__html: userComment}}
  3. Install DOMPurify for HTML content — If you must render HTML, sanitize it: DOMPurify.sanitize(htmlContent, { ALLOWED_TAGS: ['p', 'b', 'i', 'a'] })
  4. Add Content-Security-Policy headers — Configure CSP to block inline scripts: Content-Security-Policy: default-src 'self'; script-src 'self'
  5. Validate on both client and server — Share Zod schemas between frontend forms and backend API routes for consistent validation

Real developers can help you.

Richard McSorley Richard McSorley Full-Stack Software Engineer with 8+ years building high-performance applications for enterprise clients. Shipped production systems at Walmart (4,000+ stores), Cigna (20M+ users), and Arkansas Blue Cross. 5 patents in retail/supply chain tech. Currently focused on AI integrations, automation tools, and TypeScript-first architectures. 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. legrab legrab I'll fill this later Krishna Sai Kuncha Krishna Sai Kuncha Experienced Professional Full stack Developer with 8+ years of experience across react, python, js, ts, golang and react-native. Developed inhouse websearch tooling for AI before websearch was solved : ) Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Sage Fulcher Sage Fulcher Hey I'm Sage! Im a Boston area software engineer who grew up in South Florida. Ive worked at a ton of cool places like a telehealth kidney care startup that took part in a billion dollar merger (Cricket health/Interwell health), a boutique design agency where I got to work on a ton of exciting startups including a photography education app, a collegiate Esports league and more (Philosophie), a data analytics as a service startup in Cambridge (MA) as well as at Phillips and MIT Lincoln Lab where I designed and developed novel network security visualizations and analytics. I've been writing code and furiously devoted to using computers to make people’s lives easier for about 17 years. My degree is in making computers make pretty lights and sounds. Outside of work I love hip hop, the Celtics, professional wrestling, magic the gathering, photography, drumming, and guitars (both making and playing them) 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. 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. prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help 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

What is the difference between validation and sanitization?

Validation checks that input meets your requirements (correct format, length, type) and rejects bad input. Sanitization modifies input to remove dangerous content while keeping the data. You should do both: validate first, then sanitize what passes.

Does React protect against XSS automatically?

React's JSX auto-escapes content in curly braces ({variable}), which prevents most XSS. However, using dangerouslySetInnerHTML, creating elements via DOM APIs, or setting href/src attributes with user data can still introduce XSS vulnerabilities.

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