Bolt security

Insecure Cookie Configuration in Bolt Application

Your Bolt.new application stores authentication tokens or session data in cookies without proper security attributes. Missing HttpOnly, Secure, and SameSite flags leave your users' sessions vulnerable to theft through XSS attacks, man-in-the-middle interception, and cross-site request forgery.

When Bolt generates authentication code, it may set cookies using basic document.cookie assignments or use a cookie library with default (insecure) settings. This means session tokens can be read by JavaScript (enabling XSS-based theft), transmitted over unencrypted HTTP connections, and sent along with cross-site requests.

An attacker who steals a session cookie can impersonate any user on your platform, access their data, make purchases on their behalf, or escalate privileges to admin accounts. This is a silent vulnerability that leaves no trace until it's exploited.

Error Messages You Might See

Warning: Cookie set without HttpOnly flag Cookie rejected due to SameSite=None without Secure Set-Cookie header ignored: must be Secure when SameSite=None Mixed Content: cookie will be blocked in future browser versions
Warning: Cookie set without HttpOnly flagCookie rejected due to SameSite=None without SecureSet-Cookie header ignored: must be Secure when SameSite=NoneMixed Content: cookie will be blocked in future browser versions

Common Causes

  • Missing HttpOnly flag — Cookies are readable by JavaScript via document.cookie, so any XSS vulnerability can steal session tokens
  • Missing Secure flag — Cookies are sent over unencrypted HTTP connections, allowing interception on public WiFi networks
  • SameSite not set to Strict or Lax — Cookies are sent with cross-site requests, enabling CSRF attacks
  • Cookies set from client-side JavaScript — Using document.cookie or js-cookie instead of setting cookies from the server with proper flags
  • Overly broad cookie domain or path — Cookies scoped to a parent domain or root path, making them accessible to other subdomains or paths that may be compromised

How to Fix It

  1. Set cookies from the server — Use Set-Cookie headers from your API routes instead of document.cookie: res.setHeader('Set-Cookie', `token=${value}; HttpOnly; Secure; SameSite=Lax; Path=/; Max-Age=86400`)
  2. Enable HttpOnly — This prevents JavaScript from accessing the cookie, blocking XSS-based theft entirely
  3. Enable Secure flag — Ensures cookies are only sent over HTTPS connections, preventing interception
  4. Set SameSite to Lax or Strict — Lax allows cookies on top-level navigations (links), Strict blocks all cross-site cookie sending
  5. Use a session library — Install iron-session or next-auth which handle secure cookie configuration by default
  6. Set proper expiration — Use Max-Age or Expires instead of session cookies for persistent login, and set reasonable timeouts

Real developers can help you.

legrab legrab I'll fill this later Simon A. Simon A. I'm a backend developer building APIs, emulators, and interactive game systems. Professionally, I've developed Java/Spring reporting solutions, managed relational and NoSQL databases, and implemented CI/CD workflows. MFox MFox Full-stack professional senior engineer (15+years). Extensive experience in software development, qa, and IP networking. Daniel Vázquez Daniel Vázquez Software Engineer with over 10 years of experience on Startups, Government, big tech industry & consulting. Jaime Orts-Caroff Jaime Orts-Caroff I'm a Senior Android developer, open to work in various fields Jacek Rozanski Jacek Rozanski Senior PHP/Symfony developer and DevOps engineer with 20+ years of professional experience, running opcode.pl (web development agency, est. 2004). Day job: I'm the sole backend developer at merketing company where I own and maintain 11 PHP/Symfony microservices on AWS (ECS Fargate, RDS, S3, CloudFront), handle the full CI/CD pipeline (Bitbucket Pipelines, Docker), and manage monitoring with Sentry and CloudWatch. These services handle high request volumes in production every month. What I bring to AI-built apps: - I audit and fix security issues (OWASP methodology), performance bottlenecks, and architectural problems in codebases generated by Cursor, Claude Code, Lovable, Bolt, and v0 - I refactor AI-generated prototypes into production-grade applications with proper error handling, testing, and clean architecture (SOLID, DDD, hexagonal architecture) - I set up the infrastructure AI tools don't touch: AWS hosting, CI/CD pipelines, automated deployments, database optimization, monitoring, and alerting - I integrate external services: payment providers, email systems, partner APIs, SSO/auth Tech stack: PHP 8.x, Symfony, React, Next.js, PostgreSQL, MySQL, Docker, AWS (ECS, RDS, S3, SQS/SNS, CloudFront), Terraform, Supabase. I also use AI tools daily (Claude Code, Cursor) in my own workflow, so I understand both the strengths and the gaps in AI-generated code. Based in Poland (CET timezone). Available for async work and calls during EU/US business hours. Costea Adrian Costea Adrian Embedded Engineer specilizing in perception systems. Latest project was a adas camera calibration system. Victor Denisov Victor Denisov Developer Franck Plazanet Franck Plazanet I am a Strategic Engineering Leader with over 8 years of experience building high-availability enterprise systems and scaling high-performing technical teams. My focus is on bridging the gap between complex technology and business growth. Core Expertise: 🚀 Leadership: Managing and coaching teams of 15+ engineers, fostering a culture of accountability and continuous improvement. 🏗️ Architecture: Enterprise Core Systems, Multi-system Integration (ERP/API/ETL), and Core Database Structure. ☁️ Cloud & Scale: AWS Expert; architected systems handling 10B+ monthly requests and managing 100k+ SKUs. 📈 Business Impact: Aligning tech strategy with P&L goals to drive $70k+ in monthly recurring revenue. I thrive on "out-of-the-box" thinking to solve complex technical bottlenecks and am always looking for ways to use automation to improve business productivity. 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

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 HttpOnly, Secure, and SameSite?

HttpOnly prevents JavaScript access to the cookie (blocks XSS theft). Secure ensures the cookie is only sent over HTTPS. SameSite controls whether cookies are sent with cross-site requests (blocks CSRF). You need all three for proper security.

Should I use localStorage or cookies for auth tokens?

Cookies with HttpOnly and Secure flags are safer for auth tokens because JavaScript cannot access them, making XSS attacks ineffective. localStorage is readable by any script on the page, so a single XSS vulnerability exposes all tokens.

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