[논문 리뷰] Understanding the Effectiveness of Large Language Models in Detecting Security Vulnerabilities
요약: 이 논문은 사전 학습된 LLM(GPT-4, GPT-3.5, CodeLlama)을 다섯 개의 취약점 데이터셋에서 벤치마킹하고, 자바와 C/C++에 걸쳐 취약점을 탐지하고 설명을 제공하기 위한 프롬프트 전략을 개발하며, 정적 분석 및 딥 러닝 도구와의 비교를 수행하고, 적대적 코드에 대한 강건성과 미세 조정 효과를 분석한다.
While automated vulnerability detection techniques have made promising progress in detecting security vulnerabilities, their scalability and applicability remain challenging. The remarkable performance of Large Language Models (LLMs), such as GPT-4 and CodeLlama, on code-related tasks has prompted recent works to explore if LLMs can be used to detect vulnerabilities. In this paper, we perform a more comprehensive study by concurrently examining a higher number of datasets, languages and LLMs, and qualitatively evaluating performance across prompts and vulnerability classes while addressing the shortcomings of existing tools. Concretely, we evaluate the effectiveness of 16 pre-trained LLMs on 5,000 code samples from five diverse security datasets. These balanced datasets encompass both synthetic and real-world projects in Java and C/C++ and cover 25 distinct vulnerability classes. Overall, LLMs across all scales and families show modest effectiveness in detecting vulnerabilities, obtaining an average accuracy of 62.8% and F1 score of 0.71 across datasets. They are significantly better at detecting vulnerabilities only requiring intra-procedural analysis, such as OS Command Injection and NULL Pointer Dereference. Moreover, they report higher accuracies on these vulnerabilities than popular static analysis tools, such as CodeQL. We find that advanced prompting strategies that involve step-by-step analysis significantly improve performance of LLMs on real-world datasets in terms of F1 score (by upto 0.18 on average). Interestingly, we observe that LLMs show promising abilities at performing parts of the analysis correctly, such as identifying vulnerability-related specifications and leveraging natural language information to understand code behavior (e.g., to check if code is sanitized). We expect our insights to guide future work on LLM-augmented vulnerability detection systems.
연구 동기 및 목표
- 다중 데이터셋과 언어에 걸쳐 사전 학습된 LLM이 코드의 보안 취약점을 탐지할 수 있는지 평가한다.
- LLM의 취약점 탐지를 위한 추론 및 설명을 유도하는 프롬프트 전략을 설계한다.
- LLM 성능을 정적 분석(CodeQL) 및 딥 러닝(LineVul) 접근 방식과 비교한다.
- 데이터 누출 및 적대적 코드 공격에 대한 강건성과 성능에 대한 미세 조정 효과를 평가한다.
- LLM을 취약점 탐지에 활용하기 위한 인사이트와 권고를 제공한다.
제안 방법
- 다섯 개의 데이터셋(OWASP, Juliet Java, Juliet C/C++, CVEFixes Java, CVEFixes C/C++)에 대해 GPT-4, GPT-3.5, CodeLlama-7B, CodeLlama-13B를 평가한다.
- 네 가지 프롬프트 전략을 개발한다: Basic, CWE-specific, Dataflow 분석 기반, Dataflow with Self Reflection.
- LLM 결과를 CodeQL(정적 분석) 및 LineVul(딥 러닝)과 비교한다.
- 의미를 보존하는 적대적 공격을 통한 데이터 누출 여부를 평가하고 성능 영향력을 측정한다.
- 더 작은 모델의 미세 조정과 그것이 합성 데이터와 실제 데이터 세트에 미치는 영향을 조사한다.
실험 결과
연구 질문
- RQ1사전 학습된 LLM이 다양한 데이터셋과 언어에 걸쳐 코드의 보안 취약점을 탐지할 수 있는가?
- RQ2프롬프트 전략이 LLM의 취약점 탐지 성능과 설명가능성에 어떻게 영향을 미치는가?
- RQ3LLMs는 표준 취약점 벤치마크에서 CodeQL 및 LineVul과 어떻게 비교되는가?
- RQ4LLMs는 적대적 코드 수정 및 데이터 누출에 대해 강건한가?
- RQ5작은 LLM의 미세 조정이 성능을 향상시키고 데이터셋 간 일반화가 보존되는가?
주요 결과
- Dataflow 분석 기반 프롬프트 + Self Reflection을 사용한 GPT-4는 합성 데이터세트에서 F1 점수 0.79(OWASP), 0.86(Juliet Java), 0.89(Juliet C/C++)를 달성한다.
- 동일 프롬프트를 사용한 실제 데이터세트에서 GPT-4는 CVEFixes Java에서 최대 0.48, CVEFixes C/C++에서 최대 0.62의 F1에 도달한다.
- CodeLlama 모델은 합성 데이터에서 0.69–0.77의 F1 등급을 보이는 반면, CVEFixes C/C++에서 최대 0.65로 더 낮은 F1 점수를 보인다.
- Self Reflection은 실제 데이터세트에서 GPT-4가 '취약하지 않다(Not vulnerable)'로 예측하도록 밀어붙이는 경향이 있어 성능을 감소시키며, CodeLlama는 이러한 경우에 더 나은 탄력성을 보인다.
- LineVul은 대규모 데이터로 학습된 데이터로 Juliet C/C++에서 1.0의 F1을 달성하지만 CWE 수준의 해석 가능한 설명은 부족하다; GPT-4는 더 해석 가능한 추론을 제공한다.
- 적대적 코드 공격은 특정 공격에서 평균 최대 12.67%의 경미한 열화를 야기한다; 미세 조정으로 작은 모델의 합성 결과는 개선되지만 실제 데이터에서의 이익은 제한적이다.
더 나은 연구,지금 바로 시작하세요
연구 설계부터 논문 작성까지, 연구 시간을 획기적으로 줄여보세요.
카드 등록 없음 · 무료 플랜 제공
이 리뷰는 AI가 만들고, 인간 에디터가 검토했습니다.