← Lab /Security & privacy

AI-generated code poses security risks that vary by task, with input processing highest

AI-generated code introduces security vulnerabilities across tools, and risk levels differ by task type

Security & privacy arXiv 16 Sep 2026 Measurement Prototype evidence Threat model

Published as “A Security Risk Assessment Framework for AI-Powered Development Tools”

Why it matters

Developers should not assume AI-generated code is secure and must apply validation, especially for tasks that handle external input or file operations.

Summary

AI-generated code poses security risks that depend more on the programming task than on the specific tool, with input handling and file processing tasks showing the highest risk. DeepSeek’s code had the highest average risk (5.50) while ChatGPT was lowest (2.00). Small prompt variations also affect risk. The evidence comes from a controlled experiment on 54 generated Python files evaluated with static analysis, but the study is limited to a narrow task set and static analysis only.

What they found 5

  1. DeepSeek generated code with the highest average risk among the three tools.

    “Overall, DeepSeek exhibited the highest average risk, followed by Gemini, while ChatGPT showed the lowest average risk.”

  2. Tasks involving input processing and file handling produced the highest risk values across all tools.

    “At the category level, tasks related to input processing and file handling produced the highest risk values across all tools.”

  3. Authentication and account recovery tasks showed consistently low risk across all tools.

    “In contrast, tasks associated with authentication and account recovery showed consistently low risk across all tools.”

  4. Prompt wording can influence the security of generated code.

    “The figure also indicates that prompts belonging to the same task did not always produce similar outcomes, suggesting that small prompt differences can influence the security of the generated code.”

  5. Observed risk levels depend more on task type than on the AI tool used.

    “Overall, the results suggest that the observed risk levels depend more on the type of task rather than the tool.”

Caveats 4

  • static analysis may not detect context-dependent issues.
  • the evaluation was based on a predefined set of programming tasks... they do not cover the full diversity of real-world applications.
  • the experiments were conducted using a fixed set of prompts... variations in prompt design, model versions, or system configurations could lead to different results.
  • risk quantification... does not explicitly capture other dimensions of risk, such as likelihood of occurrence or potential impact in real-world deployment scenarios.

What’s new here 4

  • Provides a structured, quantitative risk assessment framework (SRF) for AI-generated code.
  • Combines severity-weighted vulnerability scoring to produce task-, category-, and tool-level risk values.
  • Enables reproducible, comparative evaluation across multiple AI code generation tools using fixed prompts and tasks.
  • Integrates threat modeling specific to code-level vulnerabilities introduced by AI tools.

Threat model stated by the source

Adversaryexploits vulnerabilities present in applications that originate from insecure code produced by AI-powered development tools
Capabilityleverages code-level flaws (e.g., input validation failures, insecure cryptographic usage) to compromise software
AssumesAI-generated code may be integrated into software systems without formal security verification; Generated outputs may vary across different prompts and task instances; Tool configurations and analysis environments can be fixed and reproduced during evaluation