Skip to main content
QUICK REVIEW

[논문 리뷰] LLM-Powered Code Vulnerability Repair with Reinforcement Learning and Semantic Reward

Nafis Tanveer Islam, Joseph Khoury|arXiv (Cornell University)|2024. 01. 07.
Software Engineering ResearchComputer Science인용 수 5
한 줄 요약

SecRepair는 CodeGen2-7B와 강화학습 및 의미적 보상을 활용하여 취약점을 자동으로 식별, 수정, 설명하고 간결한 코드 주석을 생성하며, InstructVul라는 지시 기반 취약점 데이터셋을 제공한다.

ABSTRACT

In software development, the predominant emphasis on functionality often supersedes security concerns, a trend gaining momentum with AI-driven automation tools like GitHub Copilot. These tools significantly improve developers' efficiency in functional code development. Nevertheless, it remains a notable concern that such tools are also responsible for creating insecure code, predominantly because of pre-training on publicly available repositories with vulnerable code. Moreover, developers are called the "weakest link in the chain" since they have very minimal knowledge of code security. Although existing solutions provide a reasonable solution to vulnerable code, they must adequately describe and educate the developers on code security to ensure that the security issues are not repeated. Therefore we introduce a multipurpose code vulnerability analysis system exttt{SecRepair}, powered by a large language model, CodeGen2 assisting the developer in identifying and generating fixed code along with a complete description of the vulnerability with a code comment. Our innovative methodology uses a reinforcement learning paradigm to generate code comments augmented by a semantic reward mechanism. Inspired by how humans fix code issues, we propose an instruction-based dataset suitable for vulnerability analysis with LLMs. We further identify zero-day and N-day vulnerabilities in 6 Open Source IoT Operating Systems on GitHub. Our findings underscore that incorporating reinforcement learning coupled with semantic reward augments our model's performance, thereby fortifying its capacity to address code vulnerabilities with improved efficacy.

연구 동기 및 목표

  • AI 지원 개발 도구에서 기능성 외 보안 코드 수정을 촉진한다.
  • 취약점을 식별, 수정 및 설명하는 엔드 투 엔드 시스템을 C/C++ 코드에 대해 개발한다.
  • 보안 이슈에 특화된 지시 기반 취약점 데이터셋(InstructVul)을 만든다.
  • 커밋 메시지로서의 간결한 코드 주석 생성을 가능하게 한다.
  • 실제 오픈 소스 IoT 운영 체제에서 제로데이 및 N-데이 취약점 분석을 시연한다.

제안 방법

  • 보안 분석에 맞춰 미세조정된 CodeGen2 기반 LLM을 활용하여 취약점을 식별, 수정 및 설명한다.
  • 취약점 식별, 수정, 설명 및 코드 주석 생성 작업으로 구성된 지시 기반 데이터셋(InstructVul)으로 학습한다.
  • 입력-출력 단계를 단일 LM 유사 시퀀스로 만들어 인코더를 삭제하고 더 긴 코드 시퀀스를 가능하게 하도록 인코더-디코더 아키텍처를 수정한다.
  • 연쇄적인 맥락 의존 생성을 보장하기 위해 인과 디코더를 사용하여 취약점 설명(코드→텍스트)을 미세조정한다.
  • 의미적으로 인지 가능한 보상(BERTScore 기반)과 PPO를 이용한 강화학습으로 간결하고 의미 보존이 강한 코드 주석 생성을 최적화한다.
  • BLEU, Rouge-L 및 인간 평가를 통해 평가하고, 취약점 탐지에 크로스 엔트로피를 사용하여 수정 품질의 안정화를 도모한다.

실험 결과

연구 질문

  • RQ1RQ1: 시스템이 자동으로 취약점을 식별하고 코드를 정확하게 수정할 수 있는가?
  • RQ2RQ2: 시스템이 개발자에게 포괄적인 취약점 설명을 제공할 수 있는가?
  • RQ3RQ3: 시스템이 설명을 최적화하고 요약하며 간결한 코드 주석을 생성할 수 있는가?

주요 결과

  • SecRepair (7B)는 취약점 식별/수정 작업에서 F1 0.82, 정밀도 0.80, 재현율 0.70, 정확도 0.88을 달성한다(표 1).
  • InstructVul 데이터셋에서 SecRepair (7B)는 수리 작업에 대해 BLEU 0.82 및 Rouge-L 0.80을 달성하며 동등한 파라미터 규모의 여러 베이스라인을 능가한다.
  • 개발자 대면 작업의 취약점 설명 품질에 대해 SecRepair (7B)는 BLEU 0.76, Rouge-L 0.98, 인간 점수 5를 달성한다.
  • 의미적 보상을 갖춘 강화학습은 일반적인 미세조정보다 코드 주석 생성의 품질을 향상시키며( SecRepair 7B: BLEU 0.60, Rouge-L 0.72, 인간 5 ), 더 간결하고 의미를 보존하는 주석을 생성한다.
  • 온도와 빔 크기가 성능에 영향을 미치는 차이가 있으며, 온도 0.5 근처의 스위트 스팟과 더 큰 빔 크기가 추론 비용이 증가하더라도 이득을 제공한다.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.