Vibe coding lets you build software by describing what you want in plain English instead of manually writing code. It’s fast and approachable, but that speed comes at a cost: AI-generated code frequently ships with security vulnerabilities that a human developer would normally catch.
In this article, I’ll break down what vibe coding is, the main vibe coding security risks you should know about, and how to keep your projects safe without giving up the convenience of AI-assisted development.
What is vibe coding?
Vibe coding is a style of software development where you describe a feature or app in natural language, and an LLM (Large Language Model) turns that description into functional code. Instead of manually writing code line by line, you guide an AI tool through prompts, review what it produces, and refine it until it works the way you want.
The term was coined by AI researcher Andrej Karpathy in early 2025, who described it as a way of coding where you “fully give in to the vibes” and let AI tools handle most of the heavy lifting.
Since then, vibe coding has become shorthand for any workflow that leans heavily on generative AI to produce source code, from quick prototypes to full production systems.
How vibe coding works and why developers use it
Vibe coding relies on AI coding agents, which are tools that interpret your prompts, generate code, and sometimes even test or deploy it on your behalf. Some of these agents work inside a chat window, while others are built directly into a code editor.
The Cursor AI editor is one of the most popular examples.
It integrates a large language model directly into your development environment, so you can ask it to write a function, fix a bug, or refactor an entire file without leaving your workspace.
Here’s why developers and most teams use vibe coding now:
- Speed: prototypes that used to take days can come together in hours;
- Easier prototyping: you can test an idea before committing engineering resources to it;
- Lower friction: less boilerplate and repetitive setup work;
- Better access: non-experts and small teams can build functional software without a full engineering staff.
Understanding vibe coding security risks and common vulnerabilities
Because AI models optimize for functional code over secure code, they routinely generate output that works but isn’t safe to run in production.
In fact, 45% of AI-generated code comes with security vulnerabilities, and that figure jumps to over 70% for LLM-generated Java code specifically. Other analyses put the range even wider, with around 62% of AI-generated code containing security flaws depending on the language and tool.
Research also shows AI-co-authored code had roughly 1.7 times as many major issues as human-written code, including higher rates of logic errors and security vulnerabilities.
Common vibe coding security risks
Some common security risks of vibe coding include:
- Insecure code patterns: AI tools often reproduce insecure patterns straight from their training data, which includes repeating mistakes found across public repositories;
- Hidden vulnerabilities: AI agents can produce complex logic that looks functional but contains flaws that only show up under specific conditions;
- Unsafe dependency choices: AI-generated code frequently pulls in open-source packages, frameworks, and libraries automatically, which can introduce vulnerable or inappropriate dependencies;
- Weak authentication or authorization logic: critical elements like access control are sometimes skipped unless the prompt explicitly asks for them;
- Secrets exposure: AI-generated code can include placeholder API (Application Programming Interface) keys, API tokens, or database passwords that end up committed to a repository by accident;
- Poor input validation: unsanitized user prompts and untrusted input are a common source of injection flaws in AI-generated applications;
- Hallucinated functions or libraries: AI tools sometimes suggest outdated or non-existent packages, which attackers can exploit by publishing malware under those fabricated names;
- Overreliance on unreviewed code: the casual nature of vibe coding can lead to uncritical acceptance of AI-generated code, letting vulnerabilities move downstream without real validation.
Vulnerability types to watch for
AI-generated code may repeat the same handful of vulnerability categories:
SQL injection
SQL (Structured Query Language) injection is a flaw where unsanitized input reaches a database query, letting an attacker inject their own commands instead of the data the form was expecting.
For example, an AI-generated login page that builds a query directly from a username field, without validation, could let someone bypass authentication just by typing extra characters into that field.
Cross-site scripting
Cross-site scripting is a defect where untrusted input gets rendered as executable code in a browser instead of being treated as plain text.
A common example is an AI-generated comment section that displays visitor input exactly as submitted, allowing an attacker to inject a script that steals other users’ session data.
Insecure deserialization
Insecure deserialization is a flaw that lets an attacker manipulate application data or logic by tampering with serialized objects before an app processes them.
For instance, an AI-generated API that deserializes user-supplied data without checking it first could end up running code the developer never intended.
Broken access control
Broken access control is a fault where a feature doesn’t properly check who’s allowed to do what.
Suppose an AI-generated admin panel only hides sensitive buttons in the interface, without a matching server-side check; that’s broken access control. Why? Because anyone who guesses the right URL can still reach it.
Hardcoded credentials
Hardcoded credentials are database passwords, API keys, or environment variables left in plain text inside the code instead of a secrets manager.
This is especially common in vibe coding, where a quick prototype can ship with a placeholder key that never gets swapped out before launch.
Unsafe API calls
Unsafe API calls are API endpoints that lack rate limiting or authentication checks, or that return more data than they should.
For example, an AI-generated endpoint that returns an entire user record instead of just the fields the app actually needs can leak far more data than intended.
Outdated packages
Outdated packages are dependencies that carry known CVEs (Common Vulnerabilities and Exposures), which AI tools pull in without checking their patch status.
An AI coding assistant might suggest an older library version simply because it showed up more often in its training data, even when a newer, patched version already exists.
Secure vibe coding: best practices to reduce risk
None of this means you have to give up on AI-assisted development — it means treating AI-generated code the same way you’d treat any other untrusted input: review it, test it, and validate it before it reaches production.
Here are some best practices to ensure security:
- Review every AI-generated change: don’t rely on AI alone for anything security-sensitive. Make sure humans review it to vet architectural data flows and authentication modules;
- Run automated security scans: use static code analysis to catch insecure patterns before code runs, dependency scanners to flag vulnerable or malicious packages, and secret-scanning tools to catch hardcoded API keys and credentials;
- Scope agent permissions to the task: give AI coding assistants only the access they need, not admin or broad system privileges by default;
- Validate every suggested library or package: confirm it actually exists and comes from a legitimate source before merging;
- Write security-focused prompts: spell out requirements for input validation, authentication, and secure coding standards instead of assuming the AI will apply them;
- Test authentication, authorization, and input handling: these are the areas most likely to have gaps in AI-generated code, including form submissions and file uploads, so make sure to verify them on your own;
- Run new AI-generated code in a sandboxed environment: a sandbox is an isolated testing space that mimics your production systems without connecting to real user data, live databases, or production credentials. Try out new dependencies, prompts, or features there first, so any mistakes stay contained instead of shipping straight to users.
Quick tip: Turn on SCA (Software Composition Analysis), a tool that automatically checks every open-source package or library your code pulls in against known vulnerability databases. Set it to run at the pull request stage, meaning the point where new code is proposed for review before it gets merged into the main project, so risky dependencies get caught before they ever reach production. This one step closes off one of the most common ways vibe coding security risks get past you.
What’s the most secure vibe coding platform?
There’s no single tool that’s automatically the most secure vibe coding platform for everyone. The right choice depends on who’s using it, how sensitive your data is, and how much oversight you’re able to build into your workflow.
Someone coding a project on their own has different needs than an engineering team shipping to production, so the most secure setup looks a little different for each.
The Cursor AI editor is a good example of how these tools differ. It offers configurable permissions and integrates with existing development environments, but like any AI coding assistant, its output still needs review. The platform doesn’t make insecure code disappear; it just changes how that code gets written.
Instead of chasing a single tool winner, evaluate any vibe coding platform against these criteria:
- Access control: can you limit what the AI tool is allowed to access, including admin access to production systems?
- Local vs. cloud processing: does your code and data stay on your infrastructure, or does it get sent to an external server?
- Logging and audit trails: can you trace what the AI generated, when, and in response to which prompt?
- Policy enforcement: does the platform let you set coding standards or security rules the AI has to follow?
- Enterprise admin controls: can a security team manage permissions and monitor usage across an organization?
- SDLC (Secure Software Development Lifecycle) compatibility: does the tool fit into your existing SDLC, including code review and static code analysis?
Should you avoid vibe coding altogether?
While vibe coding isn’t something you need to reject outright, it shouldn’t replace secure development practices either. Use it as a productivity tool, not a substitute for a security review.
Vibe coding works well for brainstorming, early prototyping, and exploring ideas before you commit real engineering time to them. It’s less suited to writing production-ready authentication systems or handling sensitive data without a human checking the details.
The developers who get the most out of vibe coding treat AI-generated code the way they’d treat a first draft: a helpful starting point that still needs editing, testing, and a second pair of eyes before it ships.
Moving forward: vibe coding is part of a bigger AI shift
Vibe coding isn’t going away, and neither is the need to stay alert as AI takes on more of the technical workload. Treat every AI-generated shortcut, in code or anywhere else, as something worth double-checking before you trust it with something that matters.
If you’re curious about the broader risks of relying on AI tools, we’ve also covered how generative AI is changing cybersecurity, how chatbots collect your data, and whether ChatGPT is safe to use.
FAQ
How does vibe coding change the developer’s role?
Vibe coding shifts developers from writing every line of code themselves to reviewing, testing, and steering an AI tool’s output. The job leans more toward review and quality control and less toward manual coding.
Who is responsible when AI-generated code causes a security breach?
The team or individual who deployed the code is generally responsible, not the AI tool itself, because they must review the AI-generated code before deploying it.
Can AI coding agents write secure code?
Sometimes, but not consistently. AI coding agents can produce functional code that also happens to be secure, especially with a well-written prompt and explicit instructions. Without human review, though, they’re just as likely to reproduce insecure patterns from their training data.
Is vibe coding just coding with AI?
Not exactly, because traditional AI-assisted coding usually means a developer writes most of the code and uses AI for autocomplete or small suggestions. Vibe coding flips that relationship: the AI generates the bulk of the code, and the person mostly reviews, tests, and steers it through follow-up prompts.
Can anyone do vibe coding?
In theory, yes. Vibe coding lowers the barrier to entry for people who aren’t trained programmers, which is part of why it has grown so quickly. In practice, getting a working app is easy, but building one that’s secure and maintainable still benefits from hands-on experience in software development.
How much do vibe coders make?
Vibe coders make between $50,000 and $100,000 per year. However, pay varies widely and depends more on a person’s overall development and security skills than on vibe coding specifically.
