La artificial intelligence-assisted programming It has ceased to be a future promise and has become the daily reality for thousands of development teams. In a matter of seconds, an AI assistant can produce complete functions, scripts, and even entire applications, and this is boosting productivity, but also increasing risks.
What many organizations still fail to grasp is that AI assumes no responsibilityWhen code fails, it's the technical team that has to face the music. And the problem isn't just that the code might be poorly designed or difficult to maintain; the real challenge is that, in a huge percentage of cases, it reaches production with serious security vulnerabilities.
AI-generated code: record productivity and runaway attack surface
In a very short time we have moved to a scenario where A very high percentage of production code already originates from AI models.Studies indicate that a third of developers acknowledge that more than 60% of what they write comes from intelligent assistants, and that companies are already seeing spectacular productivity increases thanks to so-called "vibe coding," prompt-based programming.
The flip side of that coin is that Around half of the automatically generated code has some vulnerabilityThese range from SQL injections to cryptographic errors and poorly designed access controls. In some languages, such as Java, it has been found that more than 70% of the code proposed by AI contained security flaws.
This situation is causing Many organizations send software to production that they already suspect is not perfect.There are reports that more than 80% of teams admit to having deployed code knowing that it was not fully mature, and almost all of them have suffered some cybersecurity incident linked to vulnerabilities in said code.
To make matters worse, the phenomenon of Shadow AIEmployees using generative AI tools without organizational oversight, copying and pasting code snippets or even pasting sensitive information into prompts. This opens the door to data leaks and the silent proliferation of insecure components, impossible to trace afterward.
Many of these risks are exacerbated by the massive influx of “citizen developers”Staff without a solid background in software engineering rely on AI to create automations, small internal apps, or integrations. The code does generate functional results, but it often lacks even the most basic guarantees of security and quality.
The main security risks in AI-generated code
The emergence of AI in software development has not invented new vulnerabilities, but has multiplied the speed and volume with which old weaknesses appearSeveral cybersecurity company analyses agree on a number of particularly critical risks when the team relies too heavily on generative tools.
One of the most visible is the “vibe coding” without a battery of tests or serious reviewsComplete functions or services are generated at the point of a prompt, superficially tested to ensure they "work," and then integrated without security testing, peer review, or automated analysis. This allows basic vulnerabilities to slip through, vulnerabilities that any minimally rigorous audit would have detected.
Also of concern are attacks on the software supply chainAI models tend to recommend third-party dependencies to solve common problems. If these dependencies are not monitored and analyzed with Software Composition Analysis (SCA) tools, it opens the door to introducing malicious libraries or compromised versions into thousands of projects with a single action.
La Lack of continuous monitoring and auditing of external packages It allows modules with obfuscated code or suspicious behavior to run within systems without raising alerts. When AI suggests and integrates these components so easily, the risk of malware slipping in disguised as a "harmless" library skyrockets.
Another delicate front is the Integration of language models with databases and internal systemsConnecting an LLM to corporate information without adequate controls opens the door to prompt injection and prompt poisoning attacks: malicious instructions hidden in data or messages that force the model to reveal secrets, bypass policies, or perform improper actions.
In addition, they have been detected thousands of active credentials and secrets in public datasets used to train models from AI. API keys, passwords, and tokens end up embedded in repositories, forums, or code samples, and can reappear in a model's responses or be exploited by attackers analyzing those datasets.
We must not forget the root of the problem: Safety by design remains largely absentA majority of developers admit to spending more time patching bugs than incorporating security requirements from the design phase. In environments where speed of delivery is paramount, business pressure pushes developers to "release the functionality now" and leave security for later... if that time ever comes.
The vision of CISOs, architects, and experts: accept AI, but with control
In various professional meetings and roundtables, cybersecurity managers from banking, industry, technology consulting, and service companies agree that AI in code development is no longer optionalIt is being used massively and no sensible CISO would consider banning it outright.
What they are considering is How to mitigate risks without blocking innovationMany are promoting secure development strategies based on the "shift left" approach: bringing security testing, SAST analysis, and dependency review to the earliest phases of the software lifecycle, right when the developer—or AI—is writing the first lines.
This change assumes that Cybersecurity teams no longer arrive at the end, when everything is developed and in production.Instead of simply saying it needs to be scrapped and rebuilt, they support development from the very first commit, integrating tools that analyze code in real time and offer immediate recommendations.
In organizations where development is outsourced or the volume of proprietary code is not enormous, security managers demand visibility into how that code is generatedThey want assurances that vendors use secure practices, do not blindly rely on AI assistants, and put code through scanners and formal reviews before delivery.
Other CISOs are beginning to see developers as “validators” of what AI generatesRather than as authors of each line, the role changes: it's no longer just about producing code, but about understanding it, questioning it, reviewing it, and improving what the model proposes, especially in sensitive areas such as authentication, authorization, encryption, or the processing of personal data.
In companies with a large amount of legacy software, the focus is on control vulnerabilities that appear in third-party libraries and in legacy layers that no one dares to touch. Here, automated analysis tools and AI agents specializing in security are starting to help map risks and prioritize what needs to be patched first.
AI as a defensive ally: detection, prioritization, and response
The same technology that makes it easier to write insecure code is also radically changing how we defend against it. In security operations centers (SOCs), SIEM platforms, and code analysis tools, Generative AI and deep learning models are becoming key components.
AI-based detection engines They do not limit themselves to looking for static signatures or patternsThey are capable of analyzing code behavior, execution flows, and semantic relationships between functions. Trained with massive repositories and real-world threat data, they identify vulnerabilities and malicious logic even when code is written in unconventional styles or using a mix of languages.
In addition, these models offer threat context and intelligent prioritizationNot all vulnerabilities warrant the same effort: an exploitable flaw in a critical service exposed to the internet carries far more weight than a bug in an internal tool. AI can cross-reference exposure information, asset criticality, exploitation history, and actual configuration to prioritize alerts and focus the team on what is truly dangerous.
Another strong point is the continuous learning and adaptation skillsAs attackers' tactics evolve and coding styles change, the models are adjusted, incorporating new attack vectors and rules gleaned from real-world incidents. This makes defenses a living organism that grows alongside the software ecosystem itself.
In the field of incident response, generative AI enables automate a large part of the initial actionsEvent categorization, response script generation, isolation of affected systems, mitigation recommendations, and creation of clear reports for technical and management teams. All of this reduces response times, prevents errors, and relieves analysts of repetitive tasks.
Generative models are also being used for simulate cyberattacks and train the teams with realistic scenarios. AI produces plausible phishing campaigns, complex attack sequences, or anomalous behavior patterns that force analysts to react and improve their decision-making capabilities under pressure.
Malware and AI: hype, current limitations and possible evolution
Alongside the rise of defensive AI, other technologies have emerged malware prototypes that integrate language models or that leverage AI services to dynamically change. Experiments such as BlackMamba, EyeSpy, or the Morris II worm have demonstrated that it is technically possible to use an LLM to generate malicious code at runtime, evaluate targets, or propagate attacks through injected instructions.
However, several experts in reverse engineering and red teaming point out that, For now, these examples are more technical curiosities than insurmountable threats.The capabilities they exhibit—polymorphism, in-memory execution, obfuscation, or target selection—already existed in advanced malware and can still be detected with current defenses.
One of the reasons is that Code generated by models trained on public data tends to be less sophisticated than code custom-written by an expert attacker.LLMs rely on learned patterns; they don't usually invent entirely new malware architectures from scratch, and often produce mediocre, redundant, or easily signed fragments.
Furthermore, For AI-based malware to be worthwhile, it has to offer a clear return on investment. to those who develop it. Just as happened with ransomware or cryptojacking, we won't see widespread use of certain techniques until they are seamlessly integrated into legitimate software and a mature infrastructure exists to support them.
That said, experts agree that, if the models continue to improve at the current rateThere will come a point where they can indeed help create more complex and adaptive threats. In that scenario, it will be necessary to further strengthen human oversight, protect models from manipulation, and ensure the security of the entire AI pipeline.
Ensuring the complete AI lifecycle: data, models, and pipeline
When discussing cybersecurity in AI-generated code, simply looking at the repository is not enough: The entire AI pipeline must be protected from end to end.from data collection to model deployment and maintenance.
The first pillar is the protection of training data and promptsand the choice of secure platforms such as free operating systemsIf datasets contain sensitive, unanonymized information, or if users paste secrets and personal data into queries, there is a risk of information leaks, credentials reappearing in responses, or even massive data breaches if the AI provider is compromised.
The second pillar is integrity of models and algorithmsAttacks such as data poisoning can contaminate training data to skew the outputs; other vectors seek to exploit vulnerabilities in inference APIs to extract the model or modify its behavior. Maintaining strict access controls, encryption, monitoring, and continuous evaluation is essential.
The third piece is the governance and oversight of the entire pipelineThis includes tracking who uses AI, for what purposes, what types of code it generates, what reviews it undergoes, and how its results are integrated into production systems. Without this visibility, Shadow AI proliferates, and risk management becomes impossible.
Good practices in this area include robust data policies, strong encryption, multi-factor authentication, least privilege principles to access the models, guardrails at the prompts, mandatory manual reviews and constant monitoring of inputs, outputs and real effects on the environment.
SHIELD Framework: Setting Clear Limits on AI-Assisted Programming
To translate all of the above into practical controls, some security consultancies have proposed specific frameworks for reduce the risk of “vibe coding”One of the most comprehensive is the SHIELD framework, which summarizes in six letters the basic principles for using AI responsibly in development.
The "S" in SHIELD refers to the Separation of dutiesThe goal is to prevent AI agents from having mixed permissions that reach production environments. The sensible approach is to limit their scope to development and testing, without powerful credentials or direct access to real databases.
The “H” corresponds to Human in the circuitThis means that AI-generated code must always be reviewed and approved by qualified personnel, especially when used by non-professional developers. No significant changes should be merged without a supervised pull request.
The “I” points to the Input and output validationIt is necessary to clearly separate reliable instructions from unreliable data, sanitize prompts, control what is asked of the model, and submit the result to tools like SAST before integrating it into the codebase.
The “E” focuses on Safety-oriented auxiliary modelsInstead of relying on a single all-purpose assistant, it is advisable to complement it with specific tools for secret scanning, control verification, SCA, phantom dependency detection, and infrastructure-as-code configuration verification.
The “L” refers to the principle of “Least Agency” or minimum agencyAI agents should operate with the minimum possible permissions: no access to sensitive files, strict limits on destructive commands, and no ability to automatically execute changes in critical environments.
Finally, the “D” refers to the Defensive technical controlsBefore deploying, it is essential to run SCA, disable any auto-deployment mechanisms that prevent human intervention, force pipelines with security stages, and thoroughly record every action that results from an AI suggestion.
These types of frames aim for something very simple: Take advantage of the acceleration offered by AI without giving up controlOr, to put it more directly, the assistant should write more lines per minute, but the responsibility, criteria, and decisions should remain in the hands of the human team.
This entire new ecosystem—with AI generating code at high speed, model-driven defenses, frameworks like SHIELD, and a culture torn between haste and prudence—is forcing organizations to mature. Those that manage to combine sound engineering practices, continuous cybersecurity training, rigorous human oversight, and intelligent use of artificial intelligence will be the ones that make their code... fast to produce, robust, secure and aligned with business objectiveswithout falling into the trap of becoming mere prompt operators or constantly putting out security fires.