When "Correct" Is Not Safe: Can We Trust Functionally Correct Patches Generated by Code Agents?

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Peng, Yibo, Song, James, Li, Lei, Yang, Xinyu, Christodorescu, Mihai, Mangal, Ravi, Pasareanu, Corina, Zheng, Haizhong, Chen, Beidi
Formato: Preprint
Publicado: 2025
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866912662422552576
author Peng, Yibo
Song, James
Li, Lei
Yang, Xinyu
Christodorescu, Mihai
Mangal, Ravi
Pasareanu, Corina
Zheng, Haizhong
Chen, Beidi
author_facet Peng, Yibo
Song, James
Li, Lei
Yang, Xinyu
Christodorescu, Mihai
Mangal, Ravi
Pasareanu, Corina
Zheng, Haizhong
Chen, Beidi
contents Code agents are increasingly trusted to autonomously fix bugs on platforms such as GitHub, yet their security evaluation focuses almost exclusively on functional correctness. In this paper, we reveal a novel type of threat to real-world code agents: Functionally Correct yet Vulnerable (FCV) patches, which pass all test cases but contain vulnerable code. With our proposed FCV-Attack, which can be deliberately crafted by malicious attackers or implicitly introduced by benign developers, we show that SOTA LLMs (e.g., ChatGPT and Claude) and agent scaffolds (e.g., SWE-agent and OpenHands) are all vulnerable to this FCV threat; across 12 agent-model combinations on SWE-Bench, the attack only requires black-box access and a single query to the code agent to perform the attack. For example, for CWE-538 (information exposure vulnerability), the FCV-Attack attains an attack success rate of $40.7\%$ on GPT-5 Mini + OpenHands. Our results reveal an important security threat overlooked by current evaluation paradigms and urge the development of security-aware defenses for code agents.
format Preprint
id arxiv_https___arxiv_org_abs_2510_17862
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle When "Correct" Is Not Safe: Can We Trust Functionally Correct Patches Generated by Code Agents?
Peng, Yibo
Song, James
Li, Lei
Yang, Xinyu
Christodorescu, Mihai
Mangal, Ravi
Pasareanu, Corina
Zheng, Haizhong
Chen, Beidi
Cryptography and Security
Software Engineering
Code agents are increasingly trusted to autonomously fix bugs on platforms such as GitHub, yet their security evaluation focuses almost exclusively on functional correctness. In this paper, we reveal a novel type of threat to real-world code agents: Functionally Correct yet Vulnerable (FCV) patches, which pass all test cases but contain vulnerable code. With our proposed FCV-Attack, which can be deliberately crafted by malicious attackers or implicitly introduced by benign developers, we show that SOTA LLMs (e.g., ChatGPT and Claude) and agent scaffolds (e.g., SWE-agent and OpenHands) are all vulnerable to this FCV threat; across 12 agent-model combinations on SWE-Bench, the attack only requires black-box access and a single query to the code agent to perform the attack. For example, for CWE-538 (information exposure vulnerability), the FCV-Attack attains an attack success rate of $40.7\%$ on GPT-5 Mini + OpenHands. Our results reveal an important security threat overlooked by current evaluation paradigms and urge the development of security-aware defenses for code agents.
title When "Correct" Is Not Safe: Can We Trust Functionally Correct Patches Generated by Code Agents?
topic Cryptography and Security
Software Engineering
url https://arxiv.org/abs/2510.17862