Secure Software Development with AI: How to Keep AI-Generated Code Verifiable

The Short Answer
AI-generated code is not inherently less secure than handwritten code. But it is produced faster, in greater volume, and with less human attention per line. Secure software development with AI therefore means setting up the development process so that every change goes through the same checks, regardless of its origin: mandatory review, automated tests and security scans, controlled dependencies, clean secrets management, and a person who is accountable for the result. Teams with this process can use AI tools safely. Teams without it had the problem before, AI just makes it visible faster.
What AI Changes About Security Risk
The classic vulnerabilities have stayed the same: missing input validation, insecure authentication, incorrectly set permissions, outdated libraries. What changes is the dynamic.
- Volume. With AI support, a team produces significantly more code in the same time. Review capacity does not grow automatically with it.
- Plausibility instead of correctness. AI-generated code almost always looks right. That lowers attention in the review, even though it is needed most here.
- Outdated patterns. Models learn from existing code, including examples with known weaknesses or superseded methods.
- Invented dependencies. AI tools occasionally suggest packages that do not exist or are not maintained. Installing them unchecked opens a door into the supply chain.
- New attack surface. As soon as the software itself contains AI features, topics such as prompt injection and uncontrolled data leakage come into play.
- Speed as a temptation. When a feature is created in an hour, a day of review seems disproportionate. But the follow-up costs of an overlooked vulnerability are out of all proportion to that hour.
Secure SDLC: The Process Carries Security
A secure software development life cycle distributes security work across all phases instead of packing it into a penetration test at the end. With AI in the team, nothing changes about the phases, but a lot changes in how they are shaped:
- Requirements. Stays: define protection needs and threat model. New: clarify which data may flow into AI tools.
- Design. Stays: access concept, data flows, interfaces. New: do not delegate architecture decisions to AI.
- Implementation. Stays: secure coding, four-eyes principle. New: mandatory review for every change, label AI-generated parts.
- Testing. Stays: unit, integration, and security tests. New: tests check against the specification, not against the generated code.
- Release. Stays: approval, documentation, acceptance. New: an accountable person is named for each release.
- Operations. Stays: monitoring, patching, incident handling. New: continuously check dependencies for origin and maintenance.
If you follow established frameworks, such as the German BSI guideline on the secure software life cycle (TR-03185) or the development requirements of ISO 27001, you will already find the structure there. AI tools need to be integrated into this structure as a tool with its own rules.
Code Review for AI-Generated Code
Code review is the single most important measure. The same rules apply to AI-generated code as to any other code, with four additions:
- No exception for AI. Every change is read by a second person before it reaches the main branch. The fact that a tool generated the code is no reason to shorten the review.
- Focus on the critical areas. Authentication, authorization, input processing, data access, error handling, and anything to do with credentials are read with particular care.
- Small units. AI tempts you into large changes at once. Large pull requests get reviewed poorly. Small steps keep the review realistic.
- AI review as a supplement. An AI-assisted review finds patterns that people miss. It does not replace human review because it can have the same blind spots as the tool that wrote the code.
It helps to label AI-generated parts in the commit or pull request so that reviewers know where careful reading pays off most.
Automating Tests and Security Scans
Whatever can be checked automatically belongs in the pipeline. With AI, this applies more than ever, because the volume of changes overwhelms manual review alone:
- Tests. Unit and integration tests run with every change. AI can write tests, but the tests must check the specification, not confirm the behavior of the code that was just generated. A human has to ensure this difference. An example: an AI assistant adds a login endpoint and supplies a test case that passes. But the test only checks that the endpoint responds, not that a locked account is rejected. This only gets noticed if someone reads the test against the requirement.
- Static analysis (SAST). Finds typical vulnerabilities in the code before it runs.
- Dependency scanning. Known vulnerabilities in libraries are reported automatically.
- Secret scanning. Credentials that accidentally end up in the code are detected before they reach the repository.
- Dynamic testing (DAST). The running application is tested for vulnerabilities, regularly and before every major release.
The established term for this is DevSecOps: security runs along in the pipeline instead of waiting as a check at the end. For AI-assisted development, this is the prerequisite for keeping up with the pace.
Controlling Dependencies and Licenses
AI tools suggest libraries because they appeared frequently in the training data. They do not reliably check whether a library exists, is maintained, is secure, and has a suitable license. Therefore:
- Every new dependency is deliberately checked before it is added: origin, maintenance status, known vulnerabilities, license.
- Versions are pinned (lockfiles) so that builds remain reproducible.
- A software bill of materials (SBOM) makes visible what is in the software and makes it easier to respond to new vulnerabilities.
- License checks are part of the process, not a topic for the end of the year. An unsuitable license in a commercial app is a legal problem, not a technical one.
Secrets and Data: What Never Belongs in a Prompt
Two data flows need clear rules before AI tools are used in the team.
Secrets in code. API keys, passwords, and certificates belong in a secrets manager, not in source code, configuration files, or prompts. AI tools like to generate sample code with keys filled in. Secret scanning in the pipeline is the technical safeguard, the team rule the organizational one.
Data in the tools. AI coding tools read code, configurations, and often entire repositories to get context. It must be clear which tools are allowed, which operating model they run in, whether inputs are used for training, and whether customer data or production data may be within reach of the tools at all. Without this clarity, every prompt is a potential data leak.
Accountability for the Result
A person is always responsible for software, never a tool. For this to hold in everyday work, it has to be anchored in the process:
- A definition of done that includes review, tests, scans, and documentation applies to every change.
- For each release, it is named who is responsible for the approval.
- Governance rules define which AI tools may be used with which data and who approves exceptions.
- When working with a provider, the contract should state that warranty and liability apply to the overall result, without special rules for AI-generated parts.
Our article on the vibe coding setup for enterprises describes how guardrails, tooling, and responsibilities for AI-assisted development are set up organizationally. This article focuses on the security process itself.
Conclusion
Secure software development with AI follows the same rules as before, just applied more consistently: secure SDLC, mandatory reviews, automated tests and scans, controlled dependencies, secrets outside the code, and clear accountability. AI tools increase the pace and with it the pressure on each of these points. With this process, the pace becomes a gain. Without it, you just get unreviewed code faster. In Vienna, we develop software for industries where security is non-negotiable, and this is exactly how we use AI: with a process. Our page on security at allaboutapps describes how we organize security in the company. Learn more about our work in AI-assisted development and backend and API development.
FAQ
Is AI-generated code less secure than handwritten code?
Not inherently. It has the same typical vulnerabilities but is produced faster and looks more plausible, which makes review harder. What matters is that every change goes through the same review and testing process, regardless of its origin.
Is an AI-assisted code review sufficient?
No. AI review is a useful supplement because it reliably finds patterns. Approval by a second person remains necessary because the tool and the reviewing tool can have the same blind spots.
What is the most important first step for secure software development with AI?
Rules for tool use: which tools are allowed, which data may go into them, and whether mandatory review applies without exception. After that comes automating tests and scans in the pipeline.
Who is responsible if AI-generated code contains a security vulnerability?
In our view, the team or provider that delivers the code: using AI is a working method and no reason for a special rule. The extent to which warranty and liability apply is defined in the contract. That is why the question needs to be raised before commissioning.




