Towards Behavior Tree-Guided Vulnerability Detection with Lightweight LLMs
Enna Basic, Alberto Giaretta
Abstract
Large Language Models (LLMs) are increasingly used for software vulnerability detection, but their performance depends on how source code is represented in the input. Most prompting approaches use source code in its original form, while some works propose the use of structured representations. Abstract Syntax Trees (ASTs) are one of the most popular approaches, but AST verbosity increases input size relative to source code, making them hard to fit within some LLMs context windows. This paper investigates Behavior Trees (BTs) as an alternative intermediate representation for LLM-based vulnerability detection. BTs encode control flow, conditions, and executable actions more compactly than ASTs, making them a natural candidate when token count is a constraint. First, we propose a preprocessing stage that parses Java source code into ASTs and then converts them into BT representations. We then compare vulnerability detection performance across 460 Java samples from the Juliet Java test suite, using three input representations: raw source code, AST, and BT. All experiments use a single quantized local LLM, Mistral Small 3.2 24B (Q4KM). Our results show that using BT representations improves recall on short code samples, while raw source code achieves higher precision. On longer samples, BTs improve overall performance over the original representation and fit within the context window, whereas many ASTs exceed the context limit. These findings suggest that BTs can provide a compact and useful structured representation for vulnerability detection with quantized, locally deployable LLMs.
Create a lesson
Related papers
Overcoming the Randomness-Utility Trade-off in Answering Differentially Private Linear Queries
Surendra Ghentiyala, Pritish Kamath, Ravi Kumar et al.
When Does Authorization End? Effect Closure at Provider Boundaries
Igor Santos-Grueiro
CodePoisonRAG: Knowledge Poisoning Attacks on Retrieval-Augmented Code Generation
Varun Gadey, Ziad Marey, Alexandra Dmitrienko
SPADE: SPaT Attack Detection from the Connected Vehicle's Perspective
James Di Novo, Hany Ragab, Sylvain P. Leblanc
Card-Based Computation in the Virtual Player Simulation Model
Suthee Ruangwises
ACLE-MCP: Attested Capability Leases for Execution-Time Trust in Remote LLM Tool Use
Zhiyang Ding, Yang Luo, Guangpu Chen et al.