AI Tools & Technology

AI-Generated Code Is Fast, but Security Needs Humans

Cursed Code
Cursed Code

AI-generated code can speed up software development, but it can also reproduce security mistakes or introduce new ones. A programme that compiles and appears to work is not necessarily safe. Developers still need to examine how it handles data, permissions and unexpected inputs, particularly when generated code is used in services that people rely on.

The UK’s National Cyber Security Centre has published guidelines for secure AI system development covering design, development, deployment and maintenance. The guidance addresses organisations building AI systems, but its principle is relevant more widely: security should be part of the development process rather than an afterthought added once a demonstration works.

Why AI-generated code security is difficult to guarantee

A coding assistant predicts text that is likely to fit the prompt and its training. It may produce a useful function, suggest a test or explain an unfamiliar library. But its apparent fluency does not mean it has proved that the code is secure in every context.

Security depends on assumptions that may not appear in the prompt. A function that safely processes one kind of input may fail when exposed to unexpected data. Code that works for a local demonstration may lack the authentication, logging or error handling required in a public service.

A developer who accepts the generated output without checking those conditions can create a vulnerability. That risk does not mean the tool is always wrong. It means automated assistance should be evaluated against the same engineering standards as code written by a person.

What researchers have measured

A 2026 empirical study of AI-assisted secure coding examined real developer interactions and compared results at different points in time. The research found that models could identify and repair many security problems, but also showed cases where generated code introduced flaws. The methods and selected test conditions limit how far the measured percentages can be generalised.

These results are more informative than blanket claims that AI always writes unsafe code or that the newest model has solved the problem. Performance varies with the task, the codebase, the prompt and the method used to assess vulnerabilities. A useful model can still be wrong in a case that matters.

Researchers often assess code with static-analysis tools or known sets of security weaknesses. Those methods can find important problems, but they do not detect every vulnerability or establish how a system would behave under real attack. Human review, integration testing and operational monitoring remain necessary.

Why a working demo can be misleading

AI-generated software may look polished after only a few instructions. A user can build an interface and connect a database quickly, making the project appear nearly finished. Yet the parts that separate a demonstration from a dependable product are often invisible: access control, secure storage, updates, input validation and recovery after failure.

The speed of generation may encourage developers to skip design decisions they would otherwise make explicitly. If a tool produces a login feature, for example, the team still needs to establish which security rules apply and how identity is checked. Copying generated code into a production system without understanding it can leave nobody able to explain how it works.

The distinction matters to businesses buying software as well as to the people building it. A product advertised as developed rapidly with AI should still be assessed for resilience, privacy and ongoing support. The method of writing the code does not lower the customer’s need for a secure system.

Security review is not the same as asking the model again

A developer might ask an AI assistant whether its own code contains vulnerabilities. That can be useful for brainstorming, but it is not an independent audit. A model may repeat its earlier assumption or miss a problem because the relevant context was never supplied.

Strong review combines several techniques. Automated tools can look for known classes of errors, tests can check expected behaviour and people can examine architectural decisions. Independent specialists may be appropriate when software handles sensitive information or controls an important service.

Any identified weakness also needs to be fixed and retested. A warning in a report offers little protection if the affected code remains in operation. Teams should record which issues were resolved, which remain open and who is responsible for monitoring them.

The supply chain grows more complicated

AI-generated code often relies on existing packages and services. A suggestion may use a library because it appeared in training examples, without confirming whether its version is current or maintained. Developers need to examine dependencies and avoid importing components simply because the model recommended them.

Licensing can also matter. Reusing code or examples without understanding their origin can create obligations that are easy to overlook. Organisations should maintain a clear inventory of components and be able to replace or update them when vulnerabilities are disclosed.

LiveAIWire’s coverage of AI supply-chain and model-security incidents illustrates why dependencies deserve scrutiny. A system is only as resilient as the components and processes on which it depends.

What organisations should require from AI coding tools

A company should define which code may be generated, which information staff may enter into an external tool and what review is required before deployment. Commercial secrets, customer records and security-sensitive material may need stronger safeguards than a public example programme.

Teams also need training. Developers should understand common security mistakes and know how to challenge generated answers. A beginner may need more supervision when using a powerful assistant because the speed of production can exceed their ability to recognise defects.

The best policy is not necessarily to prohibit AI-assisted coding. It is to make responsibility clear and ensure that tools fit within established development and security processes. The same standards should apply regardless of whether a line of code was typed manually or suggested by a model.

Why the risk changes with the task

A small script used to rename local files has different consequences from software that processes payments, health information or passwords. Security controls should reflect that difference. A prototype can be tested in an isolated environment without being trusted to handle live customer data.

When software interacts with external systems, the potential damage from an error increases. An AI-generated automation may call services or change records in ways the developer did not anticipate. Least-privilege access, logs and approval steps can help limit the impact of mistakes.

Our reporting on AI-assisted security research shows another side of the technology. Models can help specialists analyse and find problems, but the findings still need careful validation before they are treated as confirmed vulnerabilities.

How to measure genuine productivity

Counting lines of code or time to first draft gives an incomplete picture. A fair evaluation measures the work needed to produce a secure, maintainable result, including tests, documentation, reviews and future fixes. A tool that generates a large amount of code quickly may create more work if the output is difficult to understand.

Teams should compare projects under realistic conditions and account for how experienced the developers are. The outcome may be different for routine code, complex integrations and security-critical components. Publishing those differences would help companies adopt the tools where they offer a genuine advantage.

AI may also change what developers do. More time may be spent on reviewing decisions, specifying requirements and checking generated changes. Those skills become more valuable, not less, when creating the first draft is easier.

What safer AI-assisted programming looks like

Developers can use models to explore options, write tests and suggest improvements while treating every suggestion as untrusted until checked. Source control, automated security scanning, peer review and deployment safeguards remain central. When uncertainty is high, a simpler design that engineers understand may be preferable to a complicated generated solution.

Organisations should also monitor failures after release. Security is not a one-time property granted by a clean test report. New weaknesses can be discovered, dependencies change and usage may expose situations that were not anticipated during development.

LiveAIWire has covered the limits of AI alignment and control, a broader reminder that a system producing an apparently helpful answer has not necessarily understood every requirement. In software development, the practical response is rigorous validation rather than blind trust.

AI-generated code can be an important productivity tool when used by people who understand the risks. The evidence supports neither panic nor unconditional confidence. Secure software still comes from careful design, review and maintenance, whatever produced the first draft.

About the Author

Stuart Kerr is Technology Correspondent at LiveAIWire, covering artificial intelligence, cybersecurity and the social impact of emerging technology. LiveAIWire is an independent, human-led technology publication using AI-assisted research, editorial production and original AI-assisted editorial illustrations under his direction.