논문 해설
A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code
A.S.E 2.0: 저장소 컨텍스트가 LLM 생성 코드의 보안에 미치는 영향 이해
- 연구 문제 LLM 코딩 에이전트가 만드는 보안 코드는 저장소에서 어떤 맥락을 받느냐에 따라 달라지지만, 기존 연구는 이 영향을 체계적으로 분리하지 못했습니다.
- 연구 방법 CASE-Bench에서 과제와 오라클을 고정하고 맥락 구성 방법과 단일 요소 편집만 바꾸어, 기능 정확성과 보안 판정을 함께 측정합니다.
- 주요 결과 기능 지향 맥락은 보안을 크게 높이지 못했고, 안전장치를 주면 보안이 올라가며 취약 예시를 넣으면 익스플로잇 가능한 코드가 늘었습니다.
저장소 맥락이 보안을 바꾸는 문제
LLM 코딩 어시스턴트와 에이전트는 코드를 생성하기 전에 저장소에서 맥락을 모읍니다. 보안에 민감한 코드에서는 이 맥락이 프로젝트의 안전장치를 보여 주는지, 아니면 모방할 취약한 코드를 보여 주는지를 결정합니다. 그런데 기존 맥락 구성은 거의 기능 정확성만을 위해 설계되었고, 보안 벤치마크는 맥락을 고정된 입력으로 취급해 왔습니다. 그래서 저장소 맥락이 생성 코드의 보안에 어떤 영향을 주는지는 명확하지 않았습니다. 이 논문은 이 공백을 메우기 위해 CASE-Bench를 구성하고, 같은 과제와 프롬프트, 오라클을 유지한 채 맥락만 바꾸어 비교합니다.

Table 8 : Repository-level benchmarks for the security of LLM-generated code. “Func. ”: tests check functionality; “Exploit”: an executable exploit checks security; “Context”: context is the controlled variable (SecRepoBench and RealSec-bench compare a few retrievers secondarily); “Annot. ”: security-relevant code annotated.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 13쪽에서 그림 영역을 추출했습니다.CASE-Bench와 맥락 조건의 구성
CASE-Bench의 각 과제는 마지막 취약 커밋의 저장소, 제거된 취약 영역인 masked region, 그리고 기능을 설명하는 요구사항으로 이루어집니다. 모델은 이 영역을 다시 생성하며, 보안과 관련된 과제라는 사실은 알려지지 않습니다. 맥락 구성 방법은 요구사항과 마스크된 대상 파일과 함께 제공할 저장소 단위를 고르고, 공통 파이프라인에서 8K 토큰 상한으로 잘립니다. 비교 기준인 Local-only는 대상 파일만 보여 주며, 각 맥락 효과는 Δ(s,t)=SecRate(s,t)−SecRate(Local-only,t)로 정의됩니다. 여기서 SecRate는 과제 t에서 방법 s가 보안 구현을 만든 실행의 비율입니다.

Figure 2 : Overview ofCASE-Bench: construction (top), the model–evaluation information barrier (middle), and controlled evaluation (bottom).⋆marks properties compared with prior benchmarks in §7.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.
Table 2 : Context construction methods and conditions. “Gen.-dep. ”: the context depends on the generator model. “Tokens”: mean context size beyond the masked target file, at the 8K retrieval cap (Repo-128K: 128K). “Fix-API”: mean fraction of fix-relevant APIs whose definitions are in the prompt, including the masked target file (hence non-zero for Local-only).
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 6쪽에서 그림 영역을 추출했습니다.실행 오라클과 설정 비교 검증
생성 코드는 빌드, 기능 테스트, PoC 익스플로잇의 순서로 평가되며 Unbuildable, Incorrect, Correct but exploitable, Secure 중 하나로 분류됩니다. 오라클 검증에서는 취약 버전과 패치 버전, 독립 작성된 대안 구현, 거부-전부 구현, 결정성, 수작업 감사를 확인합니다. 방법 비교에서는 Source-sink slicing이 소스에서 싱크까지의 경로와 가드를 찾고, CodeGuarder는 외부 보안 지식을 주입합니다. 두 보안 인식 방법은 Local-only 및 두 가지 priming 대조군과 함께 비교됩니다. 이 검증은 과제의 테스트와 익스플로잇이 보안 속성을 얼마나 반영하는지를 확인하는 근거이며, PoC가 취약점을 배제하지는 못한다는 한계도 함께 남습니다.

Table 1 : Oracle validation (all 145 tasks unless stated otherwise).
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 4쪽에서 그림 영역을 추출했습니다.기능 지향 맥락과 보안의 차이
기능 지향 맥락 방법들은 Local-only에 비해 FuncPass@1을 −4.8에서 +8.2pp까지 바꾸었지만, SecPass@1은 −1.1에서 +3.7pp의 범위에 머물렀습니다. 이 범위는 기능 지향 방법 11개를 대상으로 한 결과입니다. 보안 인식 방법인 CodeGuarder와 Source-sink slicing은 각각 4.2pp와 5.5pp를 더했습니다. Reference context는 Local-only 대비 SecPass@1을 12.2pp 높였고, 이는 최적의 기능 지향 방법보다 8.5pp 큰 값입니다. 다만 이 비교의 최적 방법은 같은 데이터에서 선택되었으므로 차이는 보수적으로 읽어야 합니다.

Table 3 : RQ1: Outcomes per method and condition (rates in %, 6 models, 3 runs, 145 tasks). Context methods use the 8K retrieval cap. Δ: change relative to Local-only in pp; bold: at least the 3 pp practical-relevance threshold; †: Holm-adjusted 𝑝<. 05against Local-only. Best-of-methods selects, per task and model, the best functionality-oriented method on two runs and evaluates it on the third (cross-fitted, not deployable).
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.
Figure 4 : RQ1: (a) Outcome partition per condition (number:SecPass@1). (b) Change inFuncPass@1 versus change in SecPass@1 relative to Local-only; the shaded band marks changes below the 3 pp practical-relevance threshold.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 8쪽에서 그림 영역을 추출했습니다.
Table 4 : RQ1:SecPass@1 (%) by CWE family for selected conditions. “Best func. ” is the best functionality-oriented method (ClaudeCode-Ret); “Best-of” is the cross-fitted oracle.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.안전장치 제거와 취약 예시 삽입의 효과
RQ2에서는 Reference context의 한 역할을 제거하거나 취약한 예시를 하나 삽입하는 단일 요소 편집을 수행했습니다. 안전장치 역할을 제거하면 SecPass@1이 3.9에서 8.1pp 낮아졌고, 최대 감소는 안전 API 제거에서 나타났습니다. 취약한 예시를 하나 넣으면 안전장치가 남아 있어도 CbE@1이 6.3pp 올랐습니다. 길이와 위치를 맞춘 무관 코드는 CbE@1을 0.6pp만 올렸습니다. 따라서 이 결과는 맥락의 내용이 길이보다 보안 결과에 더 크게 작용한다는 관찰을 지지합니다. 다만 이 편집은 74개 과제 중 취약 예시가 있는 경우에 한정됩니다.

Figure 5 : RQ2 (amount): (a)SecPass@1 by retrieval cap on the three RQ2 models (cap 0: Local-only; shaded: the 8K cap of RQ1). (b) Content of the ReACC-Hybrid context over all 145 tasks.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.
Figure 6 : RQ2 (content and presentation): (a) Effects of context interventions onSecPass@1 (filled) andCbE@1 (hollow) relative to the unmodified base context on the same tasks and three models, with 95% intervals; the shaded band marks changes below 3 pp. “(best)”: applied to the context of the best functionality-oriented method. (b)SecPass@1 of the Reference context by the relative position of the safeguard and the total context length.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 9쪽에서 그림 영역을 추출했습니다.코딩 에이전트의 맥락 수집
에이전트 실험은 SWE-agent와 Claude Code를 사용해 수행되었습니다. 에이전트는 기능 지향 검색 방법보다 FuncPass@1을 2.7에서 7.1pp 높였지만, SecPass@1은 −1.3에서 +0.5pp 범위에 머물렀습니다. 안전장치는 27에서 36%의 궤적에서만 관찰되었고, 검색 질의의 대부분은 기능 개체를 가리켰습니다. 안전장치를 관찰하고 사용한 궤적은 34.5% SecPass@1을 보였고, 관찰하지 않은 궤적은 12.7%였습니다. 이 관계는 관찰 연구이므로 인과로 단정하지 않습니다.

Figure 7 : RQ3: (a) Share of search queries that name functional entities, security concepts, or other entities. (b)SecPass@1 andCbE@1 of agent trajectories by whether the safeguard was observed and used (bars: pooled; markers: agents; parentheses: share of trajectories). (c)CbE@1 by whether an insecure exemplar was observed, on the 74 tasks that contain one.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 11쪽에서 그림 영역을 추출했습니다.측정의 한계와 적용 범위
PoC는 취약점을 입증할 수는 있지만 배제할 수는 없으므로, SecPass@1은 저자들의 테스트와 익스플로잇에 상대적인 값입니다. 익스플로잇 변형은 기본 PoC에 저항한 생성 코드 중 7.3%의 판정을 바꾸었고, 수작업 감사는 생성 결과의 95.7%에서 오라클과 일치했습니다. 정적 분석 오라클은 PoC와 36.8%의 판정에서 불일치했으며, 이는 방법들의 순위가 오라클에 따라 달라질 수 있음을 뜻합니다. 과제는 51개 프로젝트에서 왔고 그중 여섯 개가 67개 과제를 차지하므로 외부 타당성에도 주의가 필요합니다.

Figure 3 : Distribution of the 145 tasks. (a) CWE families (inner ring) and CWEs (outer ring). (b) Languages by family. (c) Year of the CVE identifier; hatched: 2024 or later.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 5쪽에서 그림 영역을 추출했습니다.
Table 7 : Static analysis versus the PoC oracle on all 28,984 functionally correct RQ1 generations, and the base PoC versus exploit variants on 40 tasks.
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 11쪽에서 그림 영역을 추출했습니다.
Figure 8 : Rankings of the 13 methods by security under the static and the base-PoC oracle on the same 145 tasks (top: most secure).
원문 · CC BY 4.0 · Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang · A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code · 원문 그림 인용 · 원본 PDF 12쪽에서 그림 영역을 추출했습니다.논문 정보
- 저자
- Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang
- 학회·저널
- arXiv · 프리프린트
- 최초 공개일
- 2026년 11월 4일
- 등록일
- 2026년 11월 6일
- 수정일
- 2026년 11월 4일
- 버전
- v1
- arXiv
- 2611.06294
- 분류
- cs.CR · cs.AI · cs.SE
- 원문 이용 조건
- CC BY 4.0
- 제공 범위
- 논문 정보, 해설, 허용된 원문 그림
AI 해설은 논문 원문과 별개의 설명이며 오류가 있을 수 있습니다. 원문과 그림은 각 출처의 이용 조건과 따로 표시된 권리를 따릅니다.
초록
Large language model (LLM) coding assistants and agents construct a repository context before generating code. For security-sensitive code, this context decides whether the model sees the project's safeguards (e.g., authorization checks) or insecure code to imitate. However, context construction is designed almost exclusively for functional correctness, and secure-code benchmarks treat the context as fixed, so how repository context affects the security of generated code remains unclear. We construct CASE-Bench, a benchmark of 145 repository-level tasks from real CVEs in 51 projects. Each task runs in Docker, has functional tests and a proof-of-concept exploit validated in both directions, and is annotated with the repository code that enforces or undermines its security. Using CASE-Bench, we compare 13 context construction methods and six controls with six LLMs, edit single context elements, and analyze coding-agent trajectories. We find that (1) functionality-oriented context raises the functional pass rate by up to 8.2 percentage points (pp) but the secure pass rate by at most 3.7 pp, (2) withholding a safeguard lowers the secure pass rate by up to 8.1 pp, while one inserted insecure exemplar raises correct-but-exploitable code by 6.3 pp, and (3) coding agents observe the relevant safeguard in only 27-36% of trajectories. These findings inform security-aware context construction and secure-code evaluation.
원문 인용
Jiongchi Yu, Keke Lian, Junqing Wang, Zhikang Fan, Zhaoxuan Li, Yongheng Huang, Ziming Zhao, Dong Zhang (2026). A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code. arXiv:2611.06294v1. https://arxiv.org/abs/2611.06294v1
BibTeX
@misc{yu2026understanding,
title = {{A.S.E 2.0: Understanding How Repository Context Impacts the Security of LLM-Generated Code}},
author = {Jiongchi Yu and Keke Lian and Junqing Wang and Zhikang Fan and Zhaoxuan Li and Yongheng Huang and Ziming Zhao and Dong Zhang},
year = {2026},
eprint = {2611.06294},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2611.06294v1}
}