Skip to main content
QUICK REVIEW

[논문 리뷰] DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoning

Yanlin Wang, Jiadong Wu|arXiv (Cornell University)|2026. 01. 28.
Adversarial Robustness in Machine Learning인용 수 0
한 줄 요약

DrainCode는 검색-증강 코드 생성(RAG) 기반의 코드 생성 공격으로 검색 맥락을 오염시켜 출력 길이를 현저히 늘리고, 대기 시간과 에너지 소비를 증가시키는 한편 기능적 정확도는 유지합니다.

ABSTRACT

Large language models (LLMs) have demonstrated impressive capabilities in code generation by leveraging retrieval-augmented generation (RAG) methods. However, the computational costs associated with LLM inference, particularly in terms of latency and energy consumption, have received limited attention in the security context. This paper introduces DrainCode, the first adversarial attack targeting the computational efficiency of RAG-based code generation systems. By strategically poisoning retrieval contexts through a mutation-based approach, DrainCode forces LLMs to produce significantly longer outputs, thereby increasing GPU latency and energy consumption. We evaluate the effectiveness of DrainCode across multiple models. Our experiments show that DrainCode achieves up to an 85% increase in latency, a 49% increase in energy consumption, and more than a 3x increase in output length compared to the baseline. Furthermore, we demonstrate the generalizability of the attack across different prompting strategies and its effectiveness compared to different defenses. The results highlight DrainCode as a potential method for increasing the computational overhead of LLMs, making it useful for evaluating LLM security in resource-constrained environments. We provide code and data at https://github.com/DeepSoftwareAnalytics/DrainCode.

연구 동기 및 목표

  • RAG 기반 코드 생성에서 에너지 및 대기 시간 집중형 공격의 보안 위험을 강조한다.
  • DrainCode를 검색 컨텍스트를 표적으로 하여 출력 길이를 증가시키되 코드 기능을 깨트리지 않는 돌연변이 기반 오염 프레임워크로 소개한다.
  • 기울기-유도 트리거 최적화 접근법을 제시하고 은밀성 제약 조건을 통해 토큰 수와 에너지 사용을 극대화한다.
  • 다양한 모델 간 및 프롬프트 전략 간 일반화 가능성을 시연하고 baselines 및 defenses와 비교한다.

제안 방법

  • 저장된 검색 코퍼스에 오염된 코드 맥락을 주입하여 LLM이 장황한 출력으로 유도한다.
  • 검색된 스니펫의 쿼리 독립적인 오염을 가능하게 하는 가상의 미완성 코드 질의를 생성한다.
  • EOS 손실과 KL 발산 제약을 가진 적대적 트리거에 대한 그래디언트-유도 돌연변이를 사용하여 비-트리거 동작을 보존한다.
  • 다중 위치 돌연변이 및 공격 버퍼 풀을 이용해 수렴 속도를 높여 오염 효율을 향상한다.
  • DrainCode를 여러 코드 모델 및 데이터셋에서 평가하고 RawRAG, Prompt Injection, LLMEffiChecker와 비교한다.

실험 결과

연구 질문

  • RQ1DrainCode가 RAG 기반 코드 생성에서 대기 시간, 에너지, 출력 길이를 얼마나 효과적으로 증가시키는가?
  • RQ2DrainCode의 어떤 구성 요소가 공격 효과에 가장 큰 기여를 하는가?
  • RQ3DrainCode는 프롬프트 전략 및 모델 간에 얼마나 잘 일반화되는가?
  • RQ4일반적인 탐지 방법이 DrainCode 오염 컨텍스트를 식별할 수 있는가?
  • RQ5드레인코드가 공격하에 코드의 가독성과 기능적 정확도에 미치는 영향은 무엇인가?

주요 결과

  • DrainCode는 출력 길이를 3배~10배 증가시키고 대기 시간을 최대 85% 증가시키며 에너지 소비를 49% 증가시킨다.
  • 상당한 오버헤드에도 불구하고 기능적 정확도는 여전히 높다(95–99% 범위).
  • DrainCode는 이전 공격들보다 최대 3.5배 빠른 오염을 달성하고 오버헤드 측면에서 베이스라인을 능가한다.
  • 공격 효율성은 프롬프트 전략에 대해 일반적으로 강인하며 블랙박스 설정으로의 전이도 잘 된다.
  • 이 접근 방식은 분류기 또는 perplexity 기반 방어에 대해 은밀성을 유지하면서 자원 제약 환경에서 처리량을 저하시킨다.

더 나은 연구,지금 바로 시작하세요

연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.

카드 등록 없음 · 무료 플랜 제공

이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.