Security-First Evaluation of Text-to-Terraform: Benchmarking LLMs and SLMs for Secure IaC Generation
summary
The gist
Cloud misconfiguration remains a leading cause of security incidents, yet whether LLMs and SLMs can generate security-compliant Infrastructure-as-Code is an open question.<ref:2608.02672#pg1,whether…
In short
This study benchmarks seven large language models (LLMs and SLMs) on generating AWS Terraform code to see if they can create secure Infrastructure-as-Code. The results show that while some models produce syntactically correct code, none reliably generate secure code without external scanning tools like Checkov or Trivy. Prompt engineering alone is not enough; automated multi-tool scanning is essential for security.
Key concepts
- Infrastructure-as-Code (IaC)
- IaC is a method of managing and provisioning computing infrastructure using configuration files written in code, rather than manual processes. Terraform is a popular tool used to define this infrastructure, making it possible to describe cloud resources like servers or networks in a readable text format.
- Syntactic Validity
- This refers to whether the generated code is grammatically correct and follows the rules of the programming language being used, such as Terraform's structure. It means the code can be parsed by the system without immediate syntax errors, but it doesn't guarantee that what it does is correct or secure.
- Security Compliance
- This measures whether the generated IaC configuration adheres to security best practices and avoids common misconfigurations (like open storage buckets or weak IAM permissions). It requires checking the code against known security standards, which is why tools like Checkov are used to verify this aspect.
Terminology used across episodes
This episode discusses
- Security-First Evaluation of Text-to-Terraform: Benchmarking LLMs and SLMs for Secure IaC Generation · Paper Radio
- TerraFormer: Automated Infrastructure-as-Code with LLMs Fine-Tuned via Policy-Guided Verifier Feedback
- Evaluating Large Language Models Trained on Code
- Multi-IaC-Eval: Benchmarking Cloud Infrastructure as Code Across Multiple Formats
- IaC Generation with LLMs: An Error Taxonomy and A Study on Configuration Knowledge Injection
- Deployability-Centric Infrastructure-as-Code Generation: Fail, Learn, Refine, and Succeed through LLM-Empowered DevOps Simulation
The paper
Security-First Evaluation of Text-to-Terraform: Benchmarking LLMs and SLMs for Secure IaC Generation · Read on arXiv
Francis Luis Santos Vargas, Rodrigo BrandΣo Mansilha, Diego Kreutz
AI Horizon Labs · University Federal do Pampa (UNIPAMPA)
Cloud misconfiguration remains a leading cause of security incidents, yet whether LLMs and SLMs can generate security-compliant Infrastructure-as-Code is an open question. We benchmark seven models, three closed LLMs (Claude Opus 4, GPT-5.4, Gemini 2.5 Pro) and four open SLMs (Qwen2.5-Coder-14B, WizardCoder-33B, CodeLlama-13B, Magicoder-S-CL-7B), on AWS Terraform generation across 17 scenarios, integrating Checkov and Trivy scanners into a GitLab CI/CD pipeline and evaluating two prompt strategies at three security levels (pass@5). Syntactic validity and security compliance are largely orthogonal properties in LLM-generated IaC, a model that reliably produces well-formed Terraform does not necessarily produce secure Terraform: WizardCoder-33B achieves 77.8% validate rate yet zero Checkov compliance, while Claude Opus 4 reaches 23.1% Checkov and 92.5% Trivy pass rates under detailed security prompting. Consequently, prompt engineering alone is insufficient: automated multi-tool scanning remains a necessary complement to LLM-assisted IaC generation regardless of model family or prompt strategy. All artifacts are publicly available.
Transcript
Introduction to the show: ident: Security Radio. Generated commentary on the latest security and cryptography papers.
Nadia: I'm Nadia.
Elias: And I'm Elias, here with Priya.
Nadia: We're looking at the paper: "Security-First Evaluation of Text-to-Terraform".
Paper summary: Nadia: So, this paper is about testing whether large language models and smaller language models can actually write Infrastructure as Code that is secure, or if they just write code that looks right but is dangerous. It sets up a benchmark for this question.
Elias: The core idea here is that we need to look at syntactic validity, plan executability, and security compliance as three separate dimensions in the output of these models when they generate Terraform code.
Priya: So what you're saying is that just getting the code to compile or be syntactically correct isn't enough for it to be trustworthy infrastructure.
Nadia: Exactly. The paper benchmarks seven different models, three big closed ones like Claude Opus four and GPT-five point four, and four smaller open ones like Qwen2 point 5-Coder and CodeLlama <ref:2608.02672#pg1>.
Elias: They test this generation across seventeen different scenarios using AWS Terraform code on a GitLab pipeline that includes Checkov and Trivy scanners as tools in the process.
Priya: And they look at this generation using two different prompting strategies, testing three security levels for each model output.
Nadia: The paper’s main point is that syntactic validity and security compliance are largely orthogonal properties. This means a model can produce code that looks perfectly formed Terraform but still be insecure infrastructure.
Conclusion: Elias: Looking at the title, "Security-First Evaluation of Text-to-Terraform: Benchmarking LLMs and SLMs for Secure IaC Generation," it really frames the whole project around security as the primary concern when we're talking about code generation.
Nadia: It moves beyond just asking if these models can write Terraform at all, to asking if they can write *secure* Terraform that passes automated security checks.
Priya: It highlights that the capability gap between functional correctness and generating secure infrastructure is actually widening when we compare these large language models and smaller ones.
Elias: The authors show that prompt engineering alone isn't enough to fix this, especially for the smaller models where detailed prompts actually hurt the syntactic validity without helping security compliance.
Nadia: The implication is that automated multi-tool scanning, like using both Checkov and Trivy together in a pipeline, is not optional anymore. It’s a prerequisite for using AI to generate IaC that you intend to deploy.
Priya: It also suggests that we shouldn't treat all security gates the same way; some tools, like Trivy findings, might be more actionable for model feedback than others like Checkov corrections which require bigger architectural changes.
Elias: So the paper shows us that for any practical application of these models in infrastructure generation today, you still need that extra layer of static analysis on top of the generated code.
More episodes
- The day in conversation for 2026-12-05
- Daily Summary for 2026-12-05
- 2607.15118-Automated Template-free Synthesis of Instruction-Centric Leakage Contracts for Black-Box CPUs
- 2610.37722-FVH-Bench: Evaluating Image Generator Safety Beyond Overtly Harmful Imagery
- 2512.23849-Security Without Detection: Economic Denial as a Primitive for Edge and IoT Defense
- 2605.05807-LCC-LLM: Leveraging Code-Centric Large Language Models for Malware Attribution
- 2607.02932-PromptPET: Prompt Obfuscation Against Profiling by AI Agents
- 2309.05646-A Novel Supervised Deep Learning Solution to Detect Distributed Denial of Service (DDoS) attacks on Edge Systems using Convolutional Neural Networks (CNN)
- The day in conversation for 2026-12-04
- Daily Summary for 2026-12-04