arXiv:2610.40735cs.CROct 2026

Manuscript Offprint

arXiv:2610.40735

RiskyPy: Toward Model-Calibrated Prompt Generation for Joint Security and Functionality Evaluation of LLM-Generated Code

Zacharie Chenail-Larcher, Daniele Lunghi, Melissa Tessa, Quentin Stiévenart, Jacques Klein, Tegawendé F. Bissyandé, Florent Avellaneda, Naouel Moha

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Zacharie Chenail-Larcher¹,* DANIELE LUNghi²,*

Melissa Tessa² QUENTIN STIÉVENART³

Jacques Klein² TEGAWENDÉ F. BISSYANDɲ

Florent Avellaneda³ NAOUEL MOHA¹

¹École de technologie supérieure, Montréal, Québec, Canada

²University of Luxembourg, Luxembourg, Luxembourg

³Université du Québec à Montréal, Montréal, Québec, Canada

*The first two authors contributed equally to this work and share first authorship.

Abstract—Evaluating approaches that improve the security of LLM code generation requires datasets that jointly assess security and functionality and remain adapted to the capabilities of the models being studied. However, existing benchmarks are costly to produce and are generally not calibrated to a chosen range of model capabilities. We introduce RiskyPy, an automated pipeline that generates security-oriented code-generation datasets calibrated to model proficiency using functionality and vulnerability canaries. We instantiate RiskyPy for Python using domains covering 18 CWEs from the 2025 CWE Top 25, producing 101 prompts. Experiments on Qwen3-4B and Seed-Coder-8B show that the generated tasks remain functionally accessible, with 57–72% of prompts yielding functional code, while only 5–10% of generations are free of Bandit findings, leaving room for joint evaluation of security and functionality of security improvement approaches.

Index Terms—Secure Code Generation, LLM Evaluation, Automated Benchmark Generation

I. INTRODUCTION

Large Language Models (LLMs) show strong aptitude in code generation [1]–[3]. Increasingly, they can handle complex tasks and produce functional code, i.e., code that completes the required task without errors. However, their implementations are not always secure and may include vulnerabilities [4]–[6]. To address this issue, it is essential to develop approaches to protect against vulnerabilities.

Evaluating these approaches requires benchmarks that jointly assess the security and functionality of generated code. Otherwise, an approach may improve security by breaking the implementation [7], [8]. Tasks where LLMs produce functional but insecure code are particularly useful, as they allow us to verify that approaches improve security while preserving functionality. Moreover, since such approaches are often evaluated across models of different strengths [9], [10], datasets should remain functionally accessible to weaker models while still exposing insecure implementations from stronger ones.

Creating such datasets remains difficult. Fixed benchmarks may eventually saturate [11] and producing new datasets is

costly. Writing tasks manually is time-consuming [12], [13], expanding expert-authored coding tasks still requires manual work [14], and mining repositories is limited by available vulnerabilities and risks data leakage [15], [16]. Furthermore, several datasets are derived from the same underlying coding tasks, potentially limiting their diversity [17], [18].

Existing dataset construction methods also rarely calibrate tasks to model capabilities, and use only frontier models to identify prompts (coding tasks expressed in natural language) that lead to vulnerable code [19] or validate the tasks [20]. To the best of our knowledge, none specifically selects tasks that weaker models can implement functionally while stronger models still tend toward insecure implementations. This is particularly relevant for research, as white-box approaches require open weights and larger models may be computationally inaccessible. For example, Qwen2.5 7B produces functional code for only about 5% of tasks in the subset of AutoBaxBench marked by the authors as Easy [20]. This highlights the need for an automated approach to generate security-oriented code generation datasets calibrated to a chosen range of model capabilities.

In this paper, we introduce RiskyPy, a configurable pipeline for automatically generating security-oriented code-generation benchmarks. RiskyPy (i) combines security-sensitive programming domains to generate realistic coding tasks without explicitly requesting insecure implementations, (ii) uses canary models to assess whether these tasks can be implemented functionally while eliciting potentially insecure code, and (iii) selects tasks based on these assessments to construct datasets tailored to a chosen range of model capabilities

As a proof of concept, we instantiate RiskyPy for single-file Python tasks, using programming domains covering 18 CWEs from the 2025 CWE Top 25 [21], and use Ministral 3B and GPT-4o-mini as canaries. This produces a dataset of 101 prompts designed for evaluating security-improvement approaches. We evaluate the dataset on Qwen3-4B and Seed-Coder-8B to assess its functional accessibility and ability to elicit insecure implementations.

In this paper, our contributions are fourfold:

  • RiskyPy, an automated pipeline for generating security-oriented code generation tasks calibrated to a chosen range of model capabilities.

  • A new dataset of 101 code tasks for joint security-functionality evaluation of code generation.

  • An evaluation of the generated dataset on two small code-generation models.

  • A manual validation study assessing prompt quality and the reliability of the functionality judge.

References (38)