Guide
Is vibe coding secure? The risks and the controls enterprise teams need
Updated
Short answer
Vibe coding is safe enough for throwaway prototypes and risky in production. Two things go wrong: the code the model writes can be insecure, and the agent writing it can run commands, install packages and touch real systems with the developer's credentials. Enterprise teams need both checked: scan the code before merge, and check each agent action before it runs.
Vibe coding has a code risk and an action risk#
Most vibe coding advice talks about the code. That's half of it.
The agent also acts. It runs shell commands, installs packages, edits config and pushes branches, using the developer's credentials. So you have a code risk (what it writes) and an action risk (what it does while writing).
The code is often insecure#
Veracode tested more than 100 large language models on 80 curated coding tasks. The models introduced security vulnerabilities in 45% of cases, and larger models didn't do significantly better than smaller ones.
That's a test set, not a measure of all production code. Still, a prototype that runs isn't a service that's safe to expose, and a bigger model won't close the gap for you.
Hallucinated packages#
Models invent package names. Researchers generated 2.23 million code samples with 16 popular code-generating models across Python and JavaScript, and 440,445 of them (19.7%) contained at least one hallucinated package name.
An attacker who registers one of those names can get code running on a developer laptop the moment the agent runs the install. See how to stop coding agents installing malicious packages.
Secrets and destructive commands#
A vibe coding session is a long chain of small actions. Somewhere in it, the agent reads a .env file, pastes a key into a config, or runs a cleanup command with a path wider than intended.
During a vibe coding session on Replit, the agent deleted a database containing live records for over 1,200 executives and nearly 1,200 companies. Replit's CEO called the incident unacceptable and said it should never be possible.
An instruction in a prompt isn't a control. If nothing checks the command before it runs, the database is one bad guess away.
What the built-in controls do and don't stop#
Claude Code and its peers ship real controls. Use them.
- Permission prompts. They put a human in front of each command, and Claude Code's docs say you're responsible for reviewing proposed code and commands for safety before approval. In Anthropic's study of 1,053 testers, people caught 13.6% of dangerous commands, and Claude Code users approve 93% of prompts. At that rate the prompt is a click, not a review.
- Allow and deny rules. A deny rule matches the command as written. The same delete written another way can slip past text matching.
- Sandbox. It bounds what the agent can reach. It doesn't judge whether an action inside that reach matches what the developer asked for.
- Managed settings. They enforce organizational standards across machines. They set the rules; they don't read each action in context.
- Scoped credentials. An agent holding a read-only token can't drop a production table, whatever it decides to do.
What enterprise teams change#
Prototype rules and production rules should be different, and written down.
- Draw the line. Prototypes run in a container or throwaway environment with no production credentials. Anything that ships goes through the normal pipeline.
- Keep review gates human. Agent-written code gets the same pull request review as any other code, and branch protection stays on. Volume goes up, so reviewers need help, not a looser bar.
- Scan before merge. Run SAST, SCA and secret scanning on every agent-authored change.
- Scope credentials. Short-lived, narrow tokens. No production access from a laptop session.
- Lock agent config. Make rules files and agent settings read-only and watch them for changes, so a poisoned file can't re-infect every future session.
- Check actions where they happen. Commands, file edits and pushes need a check before they run, not a log after.
Checklist#
- Prototype and production environments are separate, and agents in the first get no production credentials.
- Every agent-authored change goes through scanning and human review before merge.
- Package installs are checked against lockfiles and an approved registry before they run.
- Secrets are judged by content, not filename, and can't reach a network call.
- Agent rules and config files are read-only and monitored.
- Irreversible actions (publish, shared push, deploy, live migration) are gated. See irreversible coding agent actions.
- One policy applies across every agent your developers use.
- You start watch-only, read what agents actually do, then enforce.
Where Harden fits#
Harden Agentic Integrity Foundation (AIF) runs on the developer laptop, outside the agent, at the agent's pre-execution hook. Every command, file edit and push is checked against the session's intent before it runs, decided locally in milliseconds, with nothing leaving the machine. One policy covers every agent, and it starts watch-only.
Harden AI Scanner (AIS) covers the code side: SAST, DAST, SCA and AI pen testing on what agents generate, running in your cloud. Together they make up Harden Ensō, the most complete protection for coding agents, covering every action the agent takes and the code it generates.
AIF is a layer, not a perimeter. It doesn't replace least privilege, scoped credentials or egress policy.
FAQ
Related questions
Is vibe coding safe for production code?
Only with the gates you'd apply to any other code: human review, scanning before merge, scoped credentials and a check on what the agent runs. In Veracode's tests, models introduced vulnerabilities in 45% of cases, so skipping those gates makes that your risk.
What is slopsquatting?
It's when an attacker registers a package name that models tend to hallucinate, so an agent installing the suggested dependency pulls in malicious code. In research summarized by the Cloud Security Alliance, 19.7% of 2.23 million generated code samples contained at least one hallucinated package name.
Can I rely on permission prompts to keep vibe coding safe?
Not at scale. In Anthropic's study, people approved 93% of prompts, so the prompt stops being a review. Replace most clicks with an automatic check of each action, and keep humans for the real exceptions.
Do I need to ban vibe coding in my company?
Usually not. A ban you can't enforce gives you less visibility than a policy you can. Allow it for prototypes in isolated environments, and put checks on anything that touches real credentials or ships.
How do I start without slowing developers down?
Start watch-only. Log what agents try for a few weeks, read the results, then enforce a small set of rules for secrets, destructive commands and irreversible actions.
Sources
- AI-Generated Code Poses Major Security Risks in Nearly Half of All Development Tasks, Veracode Research Reveals
- Slopsquatting: AI Code Hallucinations Fuel Supply Chain Attacks (Cloud Security Alliance)
- Replit's AI agent wipes company's codebase during vibe coding session (Gizmodo)
- Security - Claude Code Docs