LLM Models and Coding Security Risks
Large Language Models (LLMs) have revolutionized software development, generating functional code quickly and efficiently. However, this technology introduces new security risks that development teams must systematically manage.
How LLM Models Work
LLMs generate code through a statistical process: they predict the most likely next token based on the context of the prompt and patterns learned during training. This method is effective for producing functional code but has structural limitations when it comes to security.
Vulnerabilities in Generated Code
Code generated by LLMs can contain subtle vulnerabilities, dependencies on problematic libraries, or insecure coding patterns that bypass superficial reviews and sneak into production. These vulnerabilities are often the result of statistical patterns learned during training on historical code or reflecting bad practices present in vast public code corpora.
Obsolescence Issues
LLMs are trained on code corpora that include public repositories, technical documentation, and forums like Stack Overflow. This creates an obsolescence problem: models can generate code that uses deprecated APIs, libraries with known vulnerabilities, or cryptographic patterns considered insecure, such as MD5 for password hashing or ECB mode for AES encryption.
Hallucinations and Package Hallucination
Hallucinations, i.e., the tendency of LLMs to generate plausible but false information, represent a specific and particularly insidious category of risk. The phenomenon of "package hallucination" involves generating plausible but non-existent package names in the import instructions of the generated code. This can lead developers to install malicious packages specifically created to exploit LLM hallucinations.
OWASP LLM AI Security Top 10
OWASP, the Open Web Application Security Project, published in 2023 the first version of the LLM AI Security Top 10 framework, updated in 2025, which identifies the ten most significant security threats associated with the integration of LLM models in applications.
| Main Categories | Description |
|---|---|
| LLM01 - Prompt Injection | Manipulation of the model's behavior through malicious input in the prompt. |
| LLM02 - Insecure Output Handling | Unvalidated use of LLM output in critical operations (DB queries, system commands, HTML rendering). |
| LLM03 - Training Data Poisoning | Alteration of training data to modify the model's behavior. |
| LLM04 - Model Denial of Service | Input designed to consume excessive computational resources. |
| LLM05 - Supply Chain Vulnerabilities | Compromised dependencies in LLM components (pre-trained models, plugins, datasets). |
| LLM06 - Sensitive Information Disclosure | Exposure of sensitive data present in the context or training data. |
| LLM07 - Insecure Plugin Design | LLM plugins with excessive permissions or unvalidated input. |
| LLM08 - Excessive Agency | LLMs with access to functions or resources not necessary for the assigned task. |
| LLM09 - Overreliance | Excessive trust in LLM output without adequate human verification. |
| LLM010 - Model Theft | Unauthorized access to the model or its parameters through APIs or model extraction techniques. |
Prompt Injection: The Main Threat
Prompt injection is the most critical and most studied vulnerability in the context of LLM models integrated into applications. Unlike SQL injection, which inserts malicious commands into a structured query, prompt injection inserts malicious instructions into the natural text passed to the model as part of the context or user input.
The most dangerous forms of prompt injection in applications that integrate LLMs for code generation or review are those that cause the model to generate code with deliberate backdoors, modify security instructions received from the system, or exfiltrate information contained in the conversation context.
LLMs offer enormous advantages in terms of productivity, but they introduce new security risks that must be managed. While tools continue to evolve, the ultimate responsibility lies with development teams: adopting secure practices is no longer an option but a fundamental necessity in a rapidly changing development ecosystem.
For further information, consult the OWASP Cheat Sheet Series dedicated to LLM security and the NIST CSF guidelines for integrating AI into business processes.
For additional resources, explore:
- Black Hat Conference for the latest research
- USENIX Security Symposium for technical insights
- NIST Cybersecurity Resource Center for official documentation
Editorial Note and Disclaimer
The guides and content published on GoYou are the result of independent research and analysis activities, for informational, educational, and in-depth purposes.
GoYou does not constitute a journalistic publication or an editorial product pursuant to Law No. 62/2001 and does not engage in real-time information activities.
The GoYou project does not provide professional, technical, legal, or financial advice and disclaims any liability for the improper use of the information published.
In the Crypto sector, every investment involves risks: readers are invited to always inform themselves independently before making any decision.