TRANSMISSION // 2608.02672v2

Valid Terraform Isn’t Necessarily Secure Terraform

Source published

A benchmark of seven AI models finds that producing valid AWS Terraform and meeting security checks are different challenges—and that scanner feedback helps unevenly.

AI-generated conceptual illustration for Valid Terraform Isn’t Necessarily Secure Terraform
AI-generated conceptual illustration; not documentary evidence.

AI can write infrastructure code that passes Terraform’s syntax checks without meeting security policies. A benchmark of seven models tested how far prompting and scanner feedback close that gap, and why automated review still matters.

Infrastructure-as-Code (IaC) lets teams describe cloud resources in files that can be reviewed and deployed repeatedly. But a configuration that Terraform accepts is not automatically a safe one. Can language models generate AWS Terraform that is both well-formed and compliant with security checks—and can better prompts or automated feedback help?

A preprint by Francis Luis Santos Vargas, Rodrigo Brandão Mansilha and Diego Kreutz examines that question. The authors tested seven models: three closed models—Claude Opus 4, GPT-5.4 and Gemini 2.5 Pro—and four open-weight, smaller language models (SLMs). They evaluated AWS Terraform across 17 scenarios involving S3, encryption keys and virtual private cloud (VPC) networking.

For each scenario, the researchers varied two prompt strategies—zero-shot instructions and a prompt with a security-compliant example—and three security levels. The most detailed level named specific security checks and required configuration attributes. Each combination was generated five times. The team first checked whether Terraform could format, validate and plan the output, then scanned validate-passing configurations with Checkov and Trivy. These tools examine overlapping but different security concerns. In a further stage, models received scanner findings and were asked to revise their configurations.

Passing validation is only one hurdle

The headline finding is that syntactic validity and security compliance did not reliably go together. WizardCoder-33B produced Terraform that passed validation in 77.8% of its 510 generations, but none of its configurations in the detailed-prompt comparison passed Checkov. Validation shows that code meets certain structural requirements; it does not certify that the infrastructure follows security policies.

The scanners also disagreed in meaningful ways. Claude Opus 4 passed Trivy on 92.5% of its validate-passing outputs under detailed security prompting, but passed Checkov on 23.1%. In this benchmark, passing Trivy did not mean passing Checkov. The result illustrates why one scanner—or Terraform’s own validation—cannot stand in for every security review.

Detailed security prompts helped some closed models, but did not solve the problem across the board. Claude’s Checkov and Trivy pass rates rose as prompts became more specific. Gemini also reached a high Trivy pass rate under detailed prompting, while its Checkov rate remained low. GPT-5.4’s Trivy results instead fell from the basic to the detailed security level. The authors link that pattern to complex resource configurations that the model generated but that Trivy penalised when it could not resolve them.

For the four SLMs, detailed prompting produced little evidence of improved security compliance. Their Checkov results were close to zero in the reported comparison, though the smallest models had especially small shared sets of scenarios and wide uncertainty intervals. This is not a test of every small model, prompt, or cloud configuration: it describes these particular models under the study’s setup.

Scanner feedback helps, but not uniformly

When models were shown scanner findings and asked to revise, Trivy pass rates increased for several models, including GPT-5.4 and WizardCoder-33B. Checkov gains were more limited: they appeared for Claude and Gemini, but were small or absent for GPT-5.4 and the SLMs. A single round of feedback therefore did not consistently resolve the policy failures.

The revision figures need careful interpretation. Configurations that had already passed both scanners were not revised, so some models’ post-revision results cover a more difficult subset than their original results. The authors caution that apparent Trivy declines for Claude and Gemini reflect this change in which outputs were counted, not necessarily worse revisions.

What the benchmark can—and cannot—show

The study is a useful demonstration that “Terraform-valid” and “secure” are distinct evaluation targets, not proof that models are generally safe or unsafe in every deployment. Its test set covers 17 scenarios across three AWS resource families, and its scanners perform static analysis: they do not capture every runtime-dependent risk. The researchers also report that the AWS provider version was not pinned, model outputs used default decoding settings, and some generations were truncated. They note that five generations per condition are too few for strong scenario-level conclusions, and that results concern specific model versions tested at one point in time.

The work is a preprint hosted on arXiv, not a peer-reviewed publication in the evidence supplied here. Its authors say the benchmark artifacts, prompts and pipeline are public, making independent scrutiny possible. Until broader testing establishes how well these results generalize, the practical lesson is narrower but important: passing code checks is not the same as meeting security requirements. Automated, complementary scanning can help identify gaps, but these results do not show that scanning alone guarantees deployment safety.

Automatically matched by shared topic keywords. These links do not imply that the sources agree or establish a consensus.