Vibe coding, letting an AI coding agent such as Cursor, Claude Code or GitHub Copilot write most of the implementation while you describe what you want and review the result, has become normal in many teams. It is genuinely productive. It also changes where security problems come from. Code arrives faster than anyone can review it carefully, agents read files and run commands with your permissions, and the model can be steered by content in the repository itself. This guide covers the main risks and the practical controls that keep them in check without giving up the speed.
Risk 1: Insecure code that looks correct
AI-generated code usually works, which makes its flaws easy to miss. Common problems include missing authorisation checks on new endpoints, SQL built by string concatenation, user input rendered without encoding, overly permissive CORS, weak or home-made cryptography, verbose error messages and outdated patterns copied from older code. The model optimises for the feature you asked for, not for the threat you did not mention.
Risk 2: Secrets in the wrong places
Agents read environment files, configuration and logs to understand a project, and may copy keys into code, tests, commit messages or chat history. They can also suggest hard-coding a credential to make something work quickly. Keep secrets in a secrets manager or excluded files the agent is told not to read, run secret scanning on every commit, and rotate any key that has been pasted into an AI session.
Risk 3: Invented and malicious packages
Models sometimes suggest package names that do not exist. Attackers have started registering such names on public registries, a tactic sometimes called slopsquatting, so an agent that installs a suggested package may pull in malware. Check that every new dependency is real, maintained and widely used before adding it, prefer packages already in your lockfile and run dependency scanning in CI. Our guide to software supply chain security covers the wider controls.
Risk 4: Prompt injection through the repository
Coding agents read README files, issues, documentation, comments and dependency source code. Any of these can contain instructions aimed at the agent, such as telling it to add a backdoor, weaken a check or send environment variables somewhere. Researchers have demonstrated attacks of this kind against agents connected to code hosting platforms. Be especially careful when an agent works on untrusted repositories, third-party code or issues filed by outsiders.
Risk 5: Agents with too much access
An agent that can run shell commands, push to branches and use your cloud credentials can do real damage if it misunderstands a task or is manipulated. Most tools offer permission settings: use them. Require approval for commands that change files outside the project, install packages, access the network or touch production. Run agents in a container or separate development environment without production credentials, and never give them long-lived cloud admin keys.
Risk 6: Data you send to the model
Everything an agent reads can be sent to the AI provider: source code, configuration, customer data in test fixtures and logs pasted for debugging. Check the plan you use, business plans usually offer stronger terms on retention and training, and agree what may be shared. Keep production data out of development environments, use synthetic test data and tell the agent which folders to ignore. For regulated data, confirm the provider's terms meet your obligations before anyone uses the tool on that code.
Controls that keep the speed
These controls add little friction once they are set up.
- Write a short security rules file for the agent: use parameterised queries, check authorisation on every endpoint, never hard-code secrets, no new dependencies without approval.
- Keep human code review for every merge, with extra attention to authentication, authorisation and data handling.
- Run static analysis, secret scanning and dependency scanning in CI on every pull request.
- Use the agent's permission system and sandbox it away from production credentials.
- Ask the agent to write tests, including tests for access control and invalid input, and review them.
- Periodically ask a second session to review the code for security issues, and treat its findings as leads, not proof.
Test what ships
Fast development means more change between tests. Scan applications continuously, and run a manual penetration test before major releases and at least yearly, focused on authentication, access control and business logic where AI-written code most often goes wrong. Our VAPT services cover web applications and APIs with the retest included, and Vexta provides scheduled scanning between tests. For how teams handle the fix backlog that fast AI coding creates, see our post on AI code security and remediation debt.
Frequently asked questions
Is code from AI coding agents less secure?
What is slopsquatting?
Can a coding agent be hijacked through a repository?
Should we ban AI coding tools?
Ship fast without shipping holes
We test web applications and APIs built with AI coding tools, focused on the access control and logic flaws that slip through fast reviews.

