Windsurf security

Windsurf Committed API Keys and Secrets to Git Repository

Windsurf's Cascade assistant hardcoded API keys, database credentials, JWT secrets, or other sensitive values directly into your source code, and those files were committed to your Git repository. Even if you delete the secrets now, they remain in your Git history and may already be compromised.

This is one of the most common and dangerous security issues with AI-generated code. Cascade focuses on making things work, so when it needs an API key or connection string, it may place the value directly in the code rather than referencing environment variables.

GitHub, GitLab, and other platforms actively scan for leaked credentials, and automated bots scrape public repos for secrets within minutes of them being pushed. If your repo is public, assume any committed secrets have been compromised.

Error Messages You Might See

GitHub push protection blocked: API key detected GitGuardian alert: Secret detected in commit [gitleaks] Detected hardcoded secret WARNING: Potential secret found in src/config/database.ts
GitHub push protection blocked: API key detectedGitGuardian alert: Secret detected in commit[gitleaks] Detected hardcoded secretWARNING: Potential secret found in src/config/database.ts

Common Causes

  • Hardcoded connection strings — Cascade wrote database URLs with username and password directly in config files
  • API keys in source files — Third-party API keys (Stripe, SendGrid, OpenAI) placed directly in service files instead of environment variables
  • JWT secret in auth code — The JWT signing secret was hardcoded in the authentication middleware
  • Missing .gitignore entries — Cascade created .env files but didn't add them to .gitignore, or placed secrets in files that aren't typically ignored
  • Config files with real values — Configuration files contain production credentials instead of placeholder values

How to Fix It

  1. Rotate ALL exposed secrets immediately — Generate new API keys, change passwords, and create new tokens for every credential that was committed. The old ones must be considered compromised
  2. Move secrets to environment variables — Replace every hardcoded value with process.env.VARIABLE_NAME or the equivalent for your framework
  3. Create proper .env and .gitignore — Add a .env file for local development and ensure .env* is in .gitignore. Create a .env.example with placeholder values
  4. Clean Git history — Use git-filter-repo or BFG Repo Cleaner to remove secrets from past commits if the repo is private. For public repos, assume the secrets are already compromised
  5. Install pre-commit hooks — Add tools like git-secrets, detect-secrets, or gitleaks as pre-commit hooks to prevent future credential commits
  6. Enable GitHub secret scanning — Turn on GitHub's secret scanning alerts in your repository settings to get notified of exposed credentials

Real developers can help you.

BurnHavoc BurnHavoc Been around fixing other peoples code for 20 years. 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 : ) Tejas Chokhawala Tejas Chokhawala Full-stack engineer with 5 years experience building production web apps using React, Next.js and TypeScript. Focused on performance, clean architecture and shipping fast. Experienced with Supabase/Postgres backends, Stripe billing, and building AI-assisted developer tools. 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. prajwalfullstack prajwalfullstack Hi Im a full stack developer, a vibe coded MVP to Market ready product, I'm here to help legrab legrab I'll fill this later 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. Stanislav Prigodich Stanislav Prigodich 15+ years building iOS and web apps at startups and enterprise companies. I want to use that experience to help builders ship real products - when something breaks, I'm here to fix it. 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. Pratik Pratik SWE with 15+ years of experience building and maintaining web apps and extensive BE infrastructure

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

Can I just delete the file with secrets and push again?

No. Deleting the file only removes it from the latest commit. The secrets remain in your Git history. Anyone with access to the repo can find them in previous commits. You must rotate the credentials and optionally rewrite Git history.

How do I prevent Cascade from hardcoding secrets in the future?

Include instructions in your Cascade prompts to use environment variables. Create a .env.example file early in the project, and add a pre-commit hook like gitleaks that blocks commits containing credential patterns.

Related Windsurf 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