Evaluating and Improving the Robustness of Security Attack Detectors Generated by LLMs

Samuele Pasini, Jinhan Kim, Tommaso Aiello, Rocio Cabrera Lozoya, Antonino Sabetta +1 more
11/27/2024
cs.SEcs.CRcs.LG

No official code found. Best implementation: PasiniSamuele/Robust-Attack-Detectors-LLM (5 stars, MIT, last commit 2025-12-05).

Abstract

Large Language Models (LLMs) are increasingly used in software development to generate functions, such as attack detectors, that implement security requirements. A key challenge is ensuring the LLMs have enough knowledge to address specific security requirements, such as information about existing attacks. For this, we propose an approach integrating Retrieval Augmented Generation (RAG) and Self-Ranking into the LLM pipeline. RAG enhances the robustness of the output by incorporating external knowledge sources, while the Self-Ranking technique, inspired by the concept of Self-Consistency, generates multiple reasoning paths and creates ranks to select the most robust detector. Our extensive empirical study targets code generated by LLMs to detect two prevalent injection attacks in web security: Cross-Site Scripting (XSS) and SQL injection (SQLi). Results show a significant improvement in detection performance while employing RAG and Self-Ranking, with an increase of up to 71%pt (on average 37%pt) and up to 43%pt (on average 6%pt) in the F2-Score for XSS and SQLi detection, respectively.

View on arXivView PDF

Code Implementations(1)

MIT

This work addresses the critical issue of evaluating and improving the robustness of LLM-generated security attack detectors using novel approach that integrates RAG and Self-Ranking into the LLM pipeline.

51Python, DockerfileNov 30, 202310 months agoMIT

Similar Papers

Cite this paper

@article{pasini2024evaluating,
  title  = {Evaluating and Improving the Robustness of Security Attack Detectors Generated by LLMs},
  author = {Samuele Pasini and Jinhan Kim and Tommaso Aiello and Rocio Cabrera Lozoya and Antonino Sabetta and Paolo Tonella},
  year   = {2024},
  eprint = {2411.18216},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2411.18216v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2411.18216.svg)](https://codeofpaper.com/paper/2411.18216)

Discussion