Large Language Models for In-File Vulnerability Localization Can Be "Lost in the End"
Not on the map. Why?
Abstract (arXiv)
Recent advancements in artificial intelligence have enabled processing of larger inputs, leading everyday software developers to increasingly rely on chat-based large language models (LLMs) like GPT-3.5 and GPT-4 to detect vulnerabilities across entire files, not just within functions. This new development practice requires researchers to urgently investigate whether commonly used LLMs can effectively analyze large file-sized inputs, in order to provide timely insights for software developers and engineers about the pros and cons of this emerging technological trend. Hence, the goal of this paper is to evaluate the effectiveness of several state-of-the-art chat-based LLMs, including the GPT models, in detecting in-file vulnerabilities. We conducted a costly investigation into how the performance of LLMs varies based on vulnerability type, input size, and vulnerability location within the file. To give enough statistical power to our study, we could only focus on the three most common (as well as dangerous) vulnerabilities: XSS, SQL injection, and path traversal. Our findings indicate that the effectiveness of LLMs in detecting these vulnerabilities is strongly influenced by both the location of the vulnerability and the overall size of the input. Specifically, regardless of the vulnerability type, LLMs tend to significantly (p < .05) underperform when detecting vulnerabilities located toward the end of larger files, a pattern we call the 'lost-in-the-end' effect. Finally, to further support software developers and practitioners, we also explored the optimal input size for these LLMs and presented a simple strategy for identifying it, which can be applied to other models and vulnerability types. Eventually, we show how adjusting the input size can lead to significant improvements in LLM-based vulnerability detection, with an average recall increase of over 37% across all models.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Builds on 22 of its 49 references that are in the map. First posted on arXiv 9 Feb 2025.
Builds on
22 of 49 references.
References · 22
- 2023Lost in the Middle: How Language Models Use Long Contextscited by 3,455
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
- 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
- 2023Using an LLM to Help With Code Understandingcited by 228
- 2024Make Your LLM Fully Utilize the Contextcited by 119
- 2023DiverseVul: A New Vulnerable Source Code Dataset for Deep Learning Based Vulnerability Detectioncited by 102
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 97
- 2024Arithmetic Without Algorithms: Language Models Solve Math With a Bag of Heuristicscited by 97
- 2023Prompt-Enhanced Software Vulnerability Detection Using ChatGPTcited by 51
- 2024Large Language Model for Vulnerability Detection: Emerging Results and Future Directionscited by 45
10 more
- 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
- 2023When ChatGPT Meets Smart Contract Vulnerability Detection: How Far Are We?cited by 42
- 2022Transformer-Based Language Models for Software Vulnerability Detectioncited by 39
- 2024ReposVul: A Repository-Level High-Quality Vulnerability Datasetcited by 36
- 2023Evaluation of ChatGPT Model for Vulnerability Detectioncited by 33
- 2023Giraffe: Adventures in Expanding Context Lengths in LLMscited by 33
- 2024LLM In-Context Recall is Prompt Dependentcited by 15
- 2024Just another copy and paste? Comparing the security vulnerabilities of ChatGPT generated code and StackOverflow answerscited by 13
- 2023A Comparative Study of Code Generation using ChatGPT 3.5 across 10 Programming Languagescited by 12
- 2024Comparing large language models and human programmers for generating programming codecited by 9
Built on by
Citing papers per year: 2025: 3; 2026: 2.
5 papers.
- 2025A Systematic Literature Review on Detecting Software Vulnerabilities with Large Language Modelscited by 8
- 2025From Trace to Line: LLM Agent for Real-World OSS Vulnerability Localizationcited by 4
- 2026From SFT to RL: Demystifying the Post-Training Pipeline for LLM-based Vulnerability Detectioncited by 4
- 2025A Blueprint for AI-Driven Software Quality: Integrating LLMs with Established Standardscited by 1
- 2026Security and Privacy in Agentic AI: Grand Challenges and Future Directionscited by 0
- 2026Security and Privacy in Agentic AI: Grand Challenges and Future Directions7 Jul 2026
- 2026From SFT to RL: Demystifying the Post-Training Pipeline for LLM-based Vulnerability Detection15 Feb 2026
- 2025From Trace to Line: LLM Agent for Real-World OSS Vulnerability Localization30 Sep 2025
- 2025A Systematic Literature Review on Detecting Software Vulnerabilities with Large Language Models30 Jul 2025
- 2025A Blueprint for AI-Driven Software Quality: Integrating LLMs with Established Standards19 May 2025