Skip to main content
QUICK REVIEW

[논문 리뷰] DeceptPrompt: Exploiting LLM-driven Code Generation via Adversarial Natural Language Instructions

Fangzhou Wu, Xiaogeng Liu|arXiv (Cornell University)|2023. 12. 07.
Software Engineering Research인용 수 6
한 줄 요약

DeceptPrompt는 기능적으로 올바른 코드를 유도하지만 취약한 코드를 생성하도록 유도하는 위장된 자연어 지시어를 생성하는 새로운 대비 공격 프레임워크를 제안한다. 분할 제어 손실을 사용한 유전적 진화 기반 최적화를 통해, 의미를 유지하면서도 특정 취약성을 유발하는 유사한 자연어 접두사/접미사를 삽입함으로써 공격 성공률(ASR)을 평균 50% 향상시켰다. 이는 여러 코드 LLM에 걸쳐 적용 가능하다.

ABSTRACT

With the advancement of Large Language Models (LLMs), significant progress has been made in code generation, enabling LLMs to transform natural language into programming code. These Code LLMs have been widely accepted by massive users and organizations. However, a dangerous nature is hidden in the code, which is the existence of fatal vulnerabilities. While some LLM providers have attempted to address these issues by aligning with human guidance, these efforts fall short of making Code LLMs practical and robust. Without a deep understanding of the performance of the LLMs under the practical worst cases, it would be concerning to apply them to various real-world applications. In this paper, we answer the critical issue: Are existing Code LLMs immune to generating vulnerable code? If not, what is the possible maximum severity of this issue in practical deployment scenarios? In this paper, we introduce DeceptPrompt, a novel algorithm that can generate adversarial natural language instructions that drive the Code LLMs to generate functionality correct code with vulnerabilities. DeceptPrompt is achieved through a systematic evolution-based algorithm with a fine grain loss design. The unique advantage of DeceptPrompt enables us to find natural prefix/suffix with totally benign and non-directional semantic meaning, meanwhile, having great power in inducing the Code LLMs to generate vulnerable code. This feature can enable us to conduct the almost-worstcase red-teaming on these LLMs in a real scenario, where users are using natural language. Our extensive experiments and analyses on DeceptPrompt not only validate the effectiveness of our approach but also shed light on the huge weakness of LLMs in the code generation task. When applying the optimized prefix/suffix, the attack success rate (ASR) will improve by average 50% compared with no prefix/suffix applying.

연구 동기 및 목표

  • 기능적으로 올바르지만 취약한 코드를 생성하도록 유도하는 의미를 유지하는 자연어 지시어에 대해 코드 LLM의 견고성 여부를 조사하는 것.
  • 실제 사용자 입력을 모방하는 실용적인 레드팀 기법을 개발하여 코드 LLM의 최악의 보안 행동을 테스트하는 것.
  • 일반적인 코드 LLM(예: CodeLlama, WizardCoder)이 의미적으로 양호해 보이지만 악성으로 설계된 프롬프트를 통해 취약한 코드를 생성하는지 평가하는 것.
  • 프롬프트 구조(예: 접두사/접미사 위치, 길이, 그룹 크기)가 대비 프롬프팅의 효과성에 미치는 영향을 이해하는 것.
  • 기능적으로 올바른 코드가 미세한 자연어 조작을 통해 체계적으로 심각한 취약성을 내포하게 될 수 있음을 입증하는 것.

제안 방법

  • DeceptPrompt는 의미적으로 양호한 자연어 접두사 및 접미사를 생성하기 위해 유전적 진화 기반 최적화 과정을 사용한다. 이는 생성된 코드에 특정 취약성을 유도한다.
  • 기능적 정확성과 목표 취약성(예: CWE-79, CWE-200)을 동시에 유도하는 새로운 분할 제어 손실 함수를 도입한다.
  • 최적화된 접두사가 의미적으로 일관되며 악성 입력으로서 탐지되지 않도록 하기 위해, GPT-2와 같은 기준 언어 모델을 사용해 난이도를 평가한다.
  • 접두사/접미사 길이, 위치(접두사 대비 접미사), 인구집단 그룹 크기와 같은 핵심 하이퍼파라미터에 대한 분석을 위해 분할 실험을 수행한다.
  • 다양한 취약성 타겟과 프롬프트 구성에서 CodeLlama-7B, StarChat-15B, WizardCoder 변형 등 여러 코드 LLM에 대해 평가한다.
  • 코드 스니펫이나 소프트 프롬프트에 의존하지 않고 순수 자연어 지시어를 사용함으로써 실제 배포 환경을 시뮬레이션한다.

실험 결과

연구 질문

  • RQ1의미를 유지하면서도 악성으로 조작된 자연어 지시어를 통해 코드 LLM이 기능적으로 정확한 코드이지만 취약한 코드를 생성하도록 유도할 수 있는가?
  • RQ2DeceptPrompt는 악성 접두사/접미사를 포함하지 않은 기준 프롬프트 대비 공격 성공률(ASR) 향상에 얼마나 효과적인가?
  • RQ3프롬프트 구조(예: 길이, 위치(접두사 대비 접미사), 그룹 크기)가 대비 공격의 성능에 어떤 영향을 미치는가?
  • RQ4DeceptPrompt가 생성한 악성 접두사는 표준 메트릭(예: 난이도)을 통해 의미적으로 일관되고 탐지되지 않을 수 있는가?
  • RQ5CodeLlama 및 WizardCoder와 같은 인기 있는 코드 LLM이 다양한 취약성 유형(CWE-79, CWE-200 등)에 대해 이와 같은 공격에 얼마나 취약한가?

주요 결과

  • DeceptPrompt는 악성 접두사나 접미사를 포함하지 않은 기준 프롬프트 대비 평균 공격 성공률(ASR)을 50% 향상시켰다.
  • 10토큰 시드 접두사 템플릿을 사용할 경우 DeceptPrompt는 ASR 62.5%를 달성했으며, 6토큰 템플릿에서는 55%로 감소하고, 3토큰 템플릿에서는 35%로 감소하여 더 긴 템플릿이 성능 향상에 기여함을 시사한다.
  • 악성 컨텍스트를 접미사로 배치할 경우 ASR는 62.5%에서 52.5%로 감소하고, 잘못된 功能률(WFR)은 0%에서 5%로 증가하여, 작업 설명에 가까운 위치에 배치할수록 공격 효과가 높아짐을 보여준다.
  • 인구집단 그룹 크기를 100에서 64로 줄이면 ASR는 45%로 감소하고, 더 줄여 40으로 하면 42.5%로 감소하여 더 넓은 탐색 공간이 최적화 성공률 향상에 기여함을 확인했다.
  • 최적화된 접두사의 난이도는 낮게 유지되어 있어 DeceptPrompt가 의미적 일관성을 유지하고 표준 언어 품질 메트릭으로서의 탐지 회피를 성공적으로 수행함을 입증한다.
  • 평가된 모든 코드 LLM—CodeLlama-7B, StarChat-15B, WizardCoder-3B, WizardCoder-15B—모두 성공적으로 공격당했으며, 이는 이와 같은 대비 프롬프팅에 광범위하게 취약함을 드러낸다.

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

논문 읽기부터 검토까지, 연구 시간을 획기적으로 줄여보세요.

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

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