Adversarial Code Generation Steering
Description
Adversary Behavior: Adversaries influence AI code generation systems to systematically produce source code containing known vulnerability patterns while maintaining functional correctness.
AI/IDE Mechanism: AI code generation systems produce code based on contextual input including project files, comments, and instruction files. Through prompt injection or context manipulation, the generation model can be directed to prefer insecure coding patterns — such as string-concatenated SQL queries, deprecated cryptographic algorithms, disabled certificate validation, insecure deserialization, or missing input sanitization — without affecting the functional correctness of the output.
Execution Path: The adversary injects instructions that bias the AI toward insecure code patterns. The generated code passes functional testing because it produces correct output for expected inputs, but contains exploitable vulnerabilities. The attack has been demonstrated through IDE plugins that inject malicious code comments as attack strings, increasing insecure code generation rates by over 50% across 16 CWEs in 5 programming languages.
Security Impact: The adversary introduces systematic security flaws at scale across any codebase where compromised AI suggestions are accepted. Vulnerabilities are distributed across the codebase and blend with developer-written code, making identification through conventional code review extremely difficult.
Platforms
Detection
Apply static application security testing to LLM-generated code before acceptance. Monitor for statistically anomalous patterns in generated code vulnerability rates. Compare generated code against the CWE top 25 and OWASP top 10 vulnerability catalogs.
Detecting Data Components (4)
Mitigations (1)
Data Sources
References
STIX Metadata
| type | attack-pattern |
| id | attack-pattern--4c1912c5-2f71-4e60-9588-e003fce42854 |
| spec_version | 2.1 |
| created | 2026-02-23T00:00:00.000Z |
| modified | 2026-02-23T00:00:00.000Z |
| created_by_ref | identity--f5b5ec62-ffbd-4afd-9ee5-7c648406e189 |
| x_mitre_is_subtechnique | False |
| x_mitre_version | 0.1 |
| x_mitre_status | candidate |