Skip to main content
QUICK REVIEW

[논문 리뷰] CodeLMSec Benchmark: Systematically Evaluating and Finding Security Vulnerabilities in Black-Box Code Language Models

Hossein Hajipour, Hassler, Keno|arXiv (Cornell University)|2023. 02. 08.
Software Engineering Research인용 수 6
한 줄 요약

이 논문은 블랙박스 코드 언어 모델이 악성 코드를 생성하도록 유도하는 프롬프트를 체계적으로 식별할 수 있는 자동화된 방법인 CodeLMSec 벤치마크를 소개한다. 소수의 프롬프트를 사용한 모델 역행사고를 통해 저자들은 CodeGen과 ChatGPT와 같은 모델들 사이에서 보안 취약점을 드러내는 교차 적용 가능한 비보안 프롬프트를 생성하였으며, 이는 공개된 벤치마크로 이어져 2,000개가 넘는 악성 코드 샘플을 포함하게 되었다. 이는 보안 평가에 활용될 수 있다.

ABSTRACT

Large language models (LLMs) for automatic code generation have achieved breakthroughs in several programming tasks. Their advances in competition-level programming problems have made them an essential pillar of AI-assisted pair programming, and tools such as GitHub Copilot have emerged as part of the daily programming workflow used by millions of developers. The training data for these models is usually collected from the Internet (e.g., from open-source repositories) and is likely to contain faults and security vulnerabilities. This unsanitized training data can cause the language models to learn these vulnerabilities and propagate them during the code generation procedure. While these models have been extensively assessed for their ability to produce functionally correct programs, there remains a lack of comprehensive investigations and benchmarks addressing the security aspects of these models. In this work, we propose a method to systematically study the security issues of code language models to assess their susceptibility to generating vulnerable code. To this end, we introduce the first approach to automatically find generated code that contains vulnerabilities in black-box code generation models. To achieve this, we present an approach to approximate inversion of the black-box code generation models based on few-shot prompting. We evaluate the effectiveness of our approach by examining code language models in generating high-risk security weaknesses. Furthermore, we establish a collection of diverse non-secure prompts for various vulnerability scenarios using our method. This dataset forms a benchmark for evaluating and comparing the security weaknesses in code language models.

연구 동기 및 목표

  • 코드 생성 대규모 언어 모델의 보안 취약성에 대한 체계적인 평가 방법의 부족을 해결하기 위해.
  • 특정 보안 결함을 유발하는 프롬프트를 자동으로 식별하는 접근법을 개발하기 위해.
  • 모델 보안 평가 및 비교를 위한 이식 가능한 확장 가능한 비보안 프롬프트 벤치마크를 만들기 위해.
  • 높은 위험도의 취약성을 생성하는 데에 취약한 코드 LLM의 성향을 대규모로 재현 가능한 방식으로 평가하기 위해.
  • 공개된 데이터셋을 통해 향후 연구에서 AI 기반 코드 생성의 보안성을 향상시키는 데에 기여하기 위해.

제안 방법

  • 소수의 프롬프트를 사용해 블랙박스 코드 생성 모델의 역행사고를 근사함으로써, 목표 취약점을 유발하는 프롬프트를 생성하는 방법.
  • 악성 코드와 해당 프롬프트의 인라인 예시를 사용해 모델이 스스로의 역함수 역할을 하도록 이끌기.
  • CodeQL을 통한 정적 분석을 적용해 생성된 코드 내 보안 취약점을 자동으로 탐지함.
  • 다양한 CWE와 프로그래밍 언어에서 유래한 비보안 프롬프트의 다양성 있는 데이터셋을 수집하고 정제함.
  • CodeGen과 ChatGPT와 같은 모델들 간 프롬프트의 이식 가능성 평가를 통해 일반화 능력 검증.
  • 편향을 줄이기 위해 다양한 출처에서 유래한 각 CWE에 대해 다수의 악성 코드 샘플을 사용함.

실험 결과

연구 질문

  • RQ1자동으로 체계적으로 코드 언어 모델이 악성 코드를 생성하도록 유도하는 프롬프트를 생성할 수 있는가?
  • RQ2소수의 프롬프트를 사용한 방법이 블랙박스 코드 생성 모델의 역함수를 얼마나 효과적으로 근사하는가?
  • RQ3생성된 비보안 프롬프트는 다양한 코드 LLM 간에 이식 가능한가?
  • RQ4제안된 방법은 다양한 종류의 보안 취약점을 식별하고 벤치마크화하는 데에 확장 가능한가?
  • RQ5벤치마크가 모델 보안 평가의 재현 가능성과 체계성에 얼마나 기여하는가?

주요 결과

  • 자동으로 유도된 프롬프트를 사용해 CodeGen과 ChatGPT에서 모두 2,000개가 넘는 악성 코드 샘플을 성공적으로 생성하였다.
  • 비보안 프롬프트는 매우 높은 이식성 보유를 보였으며, 한 모델(예: ChatGPT)에서 유도된 프롬프트가 다른 모델(예: CodeGen)에서 악성 취약점을 효과적으로 유도하였다.
  • 벤치마크는 다양한 CWE와 프로그래밍 언어를 포함한 다양한 프롬프트를 포함하여 광범위한 보안 평가를 가능하게 하였다.
  • CodeQL을 통한 정적 분석은 짧고 독립적인 코드 스니펫에서 취약점을 신뢰성 있게 탐지하여 재현 가능성을 보장하였다.
  • 모델 내부 정보나 미세조정이 필요 없이도 확장 가능하고 자동화된 체계적인 보안 벤치마크가 가능하였다.
  • 공개된 데이터셋은 향후 모델의 안전한 코드 생성 향상에 대한 지속적인 평가 및 개선을 지원한다.

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

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

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

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