Journal of Information Processing
Online ISSN : 1882-6652
ISSN-L : 1882-6652
 
Securing IaC: Detecting Terraform Security Smells with Fine-tuned LLMs
Quoc-Huy Vo, Ha Dao, Kensuke Fukuda
Author information
Keywords: IaC, code smell, LLM
JOURNAL FREE ACCESS

2026 Volume 34 Pages 886-897

Details
Abstract

Terraform is a widely used declarative Infrastructure-as-Code (IaC) platform, yet its configurations may include security-related code smells that lead to design flaws or vulnerabilities. Although prior work shows that zero-shot prompting with general-purpose Large Language Models (LLMs) can outperform traditional linters, these models lack domain specialization and often produce inconsistent results with high false-positive rates. This study investigates whether fine-tuned LLMs, both API-based and locally hosted, can provide more accurate, cost-efficient, and privacy-preserving detection of Terraform security smells. An analysis of 71 GitHub repositories shows that 85.9% contain at least one security smell, confirming their widespread presence. To support automated detection, we propose an end-to-end pipeline for fine-tuning LLMs for security code smell detection. We build a dataset of 1, 381 Terraform samples and fine-tune several LLMs specifically for security smell classification. Evaluation results show substantial gains: a fine-tuned GPT-4o-mini achieves 91.0% accuracy, outperforming larger base models, while a fine-tuned 7B Mistral model matches GPT-5 performance (82.0%) despite being significantly smaller. These findings demonstrate that compact, specialized models can surpass large general-purpose LLMs, underscoring the value of domain-focused fine-tuning for improving accuracy, reducing false positives, and enhancing IaC security analysis.

Content from these authors
© 2026 by the Information Processing Society of Japan
Previous article Next article
feedback
Top