Pith. sign in

REVIEW 8 cited by

Can We Trust Large Language Models Generated Code? A Framework for In-Context Learning, Security Patterns, and Code Evaluations Across Diverse LLMs

Not yet reviewed by Pith; the record is open.

This paper has not been read by Pith yet. Machine review is queued; the pith claim, tier, and objections will appear here once it completes.

SPECIMEN: schema-true, not a live event

T0 review · schema-true

One-sentence machine reading of the paper's core claim.

pith:XXXXXXXX · record.json · timestamp

arxiv 2406.12513 v1 pith:PK4BG3TB submitted 2024-06-18 cs.CR

Can We Trust Large Language Models Generated Code? A Framework for In-Context Learning, Security Patterns, and Code Evaluations Across Diverse LLMs

classification cs.CR
keywords codellmssecuritygeneratedgenerationlearningresearchsoftware
verification ladder T0 review T1 audit T2 compute T3 formal T4 reserved
0 comments
read the original abstract

Large Language Models (LLMs) such as ChatGPT and GitHub Copilot have revolutionized automated code generation in software engineering. However, as these models are increasingly utilized for software development, concerns have arisen regarding the security and quality of the generated code. These concerns stem from LLMs being primarily trained on publicly available code repositories and internet-based textual data, which may contain insecure code. This presents a significant risk of perpetuating vulnerabilities in the generated code, creating potential attack vectors for exploitation by malicious actors. Our research aims to tackle these issues by introducing a framework for secure behavioral learning of LLMs through In-Content Learning (ICL) patterns during the code generation process, followed by rigorous security evaluations. To achieve this, we have selected four diverse LLMs for experimentation. We have evaluated these coding LLMs across three programming languages and identified security vulnerabilities and code smells. The code is generated through ICL with curated problem sets and undergoes rigorous security testing to evaluate the overall quality and trustworthiness of the generated code. Our research indicates that ICL-driven one-shot and few-shot learning patterns can enhance code security, reducing vulnerabilities in various programming scenarios. Developers and researchers should know that LLMs have a limited understanding of security principles. This may lead to security breaches when the generated code is deployed in production systems. Our research highlights LLMs are a potential source of new vulnerabilities to the software supply chain. It is important to consider this when using LLMs for code generation. This research article offers insights into improving LLM security and encourages proactive use of LLMs for code generation to ensure software system safety.

discussion (0)

Sign in with ORCID, Apple, or X to comment. Anyone can read and Pith papers without signing in.

Forward citations

Cited by 8 Pith papers

Reviewed papers in the Pith corpus that reference this work. Sorted by Pith novelty score.

  1. Insecure Coding Preferences in Long-Term Memory: Security Risks for LLM-based Code Generation

    cs.CR 2026-07 conditional novelty 7.0

    Injected insecure coding preferences in LLM long-term memory raise vulnerability rates by 2.7-50.3 pp and suppress warnings; memory-level filtering restores safe behavior in the tested set.

  2. A Large-Scale Comprehensive Measurement of AI-Generated Code in Real-World Repositories

    cs.SE 2026-03 unverdicted novelty 7.0

    A large-scale study of real-world repositories finds that AI-generated code differs from human-written code in complexity, structural traits, defect indicators, and commit-level activity patterns.

  3. DeepGuard: Secure Code Generation via Multi-Layer Semantic Aggregation

    cs.SE 2026-04 unverdicted novelty 6.0

    DeepGuard aggregates multi-layer representations in code LLMs to raise the secure-and-correct generation rate by 11.9% on average over baselines like SVEN while preserving correctness and generalizing to new vulnerabi...

  4. A Large-Scale Comprehensive Measurement of AI-Generated Code in Real-World Repositories

    cs.SE 2026-03 conditional novelty 6.0

    In real-world repositories, AI-assisted and human-written code differ only modestly on code-level metrics, while commit size, stability, duplication, and language-specific security show clearer patterns.

  5. A Study of LLMs' Preferences for Libraries and Programming Languages

    cs.SE 2025-03 unverdicted novelty 6.0

    Empirical study of eight LLMs finds overuse of popular libraries like NumPy in up to 45% of unnecessary cases and strong default preference for Python even when suboptimal.

  6. The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Reprompting

    cs.CR 2026-07 conditional novelty 5.5

    Across five coding assistants, authentication code is insecure under basic or generic-secure prompts; single-shot NIST help improves it, but only iterative reprompting approaches defense-in-depth.

  7. A Causal Perspective on Measuring, Explaining and Mitigating Smells in LLM-Generated Code

    cs.SE 2025-11 conditional novelty 5.0

    A probabilistic score of code-smell propensity in LLM output is validated, used in a causal analysis, and shown to drop when prompts explicitly discourage known smells.

  8. R+R: Reassessing Java Security API Misuse in Current LLMs: A Replication on JCA and JSSE APIs with External Security Knowledge

    cs.CR 2026-05 unverdicted novelty 4.0

    Replication finds Java security API misuse persists in current LLMs but is reduced by external knowledge in a model-dependent manner.