Skip to content

Guard: Robust Detection of Hardcoded Secrets in Ansible Playbooks

Matteo Grella, Willem Jonker, Andrea Continella, Luca Mariot

cs.CR

Abstract

The adoption of DevOps practices and Infrastructure as Code (IaC) has transformed IT and cloud infrastructure management, but it also introduces new security challenges, as entire infrastructures are now defined in code. Existing detection tools for security smells are rule-based, matching configuration keys against keyword lists that must be curated and maintained by hand, or are learned models that operate on module-level metadata rather than on the configuration as written. In this paper we present GUARD, a learned classifier for hardcoded secrets that relies only on the key names found in IaC playbook files. Unlike regex-based approaches, GUARD does not depend on a fixed vocabulary, as it identifies variants of known secret key names and continues to flag keys whose tokens never appear in its training set. We compare GUARD against GLITCH, the state-of-the-art regex-based detector for Ansible, and three zero-shot large language models, namely Sonnet 4.6, Fable 5, and Mistral 7B. On F1 and precision, Sonnet 4.6 and Fable 5 significantly outperform GUARD, while GUARD in turn significantly outperforms GLITCH and Mistral 7B; on recall, however, GUARD is statistically indistinguishable from Sonnet 4.6 and Fable 5. Unlike commercial LLMs, GUARD attains this recall parity at a negligible inference cost with fully deterministic predictions, and without transmitting potentially sensitive IaC data to a third-party service. We further conduct an ablation study that incrementally strips the vocabulary GLITCH relies on: GLITCH's detection collapses once the list is exhausted (F1 from 0.662 to 0.000), whereas GUARD, retrained on the remaining key names, retains an F1 of 0.287 at a precision that never leaves [0.783, 0.868]. Losing keyword coverage therefore induces a trade-off for GUARD on recall, but not on reliability.

Create a lesson

Metadata

Comments
25 pages, 10 figures, 5 tables