A security audit reveals that an agent tasked with generating configuration files has committed API keys, database connection strings with passwords, and private key material directly into a public repository. The agent had no secret detection configured and treated configuration values the same as any other file content. What guardrail was missing and what is the remediation?
Select an answer to reveal the explanation.
Short Explanation
If your agent writes config files without secret scanning, it's taping the alarm code to the door. Put a secret scanner between the agent's output and the repo, and block any commit that contains secrets before it lands.
Full Explanation
Secret detection is a mandatory security guardrail for any agent that generates or modifies configuration files, environment files, or any content that might include credentials. Without it, an agent that is correctly following its instructions to generate a working configuration file will produce files containing secrets, because it has no mechanism to distinguish between values that are safe to commit and values that must never enter version control. The correct guardrail is a pre-commit or pre-push secret scanning gate: the agent prepares its commit; before the commit is sent to the git remote, a secret scanner such as GitHub secret scanning, TruffleHog, GitLeaks, or detect-secrets scans the staged content for patterns matching known secret formats, including API key patterns, private key headers, and connection string patterns; if secrets are detected, the commit is rejected and the agent is instructed to replace the detected values with environment variable references, template placeholders, or a secrets manager call. If secrets have already been committed, immediate remediation requires rotating all exposed credentials, because the only safe assumption is that exposed credentials are compromised, removing the commit from history via git filter-branch or git filter-repo, then force-pushing with team coordination, and notifying the security team. Making the repository private reduces exposure but does not eliminate it. Private repositories can be accessed by anyone with organization access, and the credential history persists. The commit must be removed from history; privacy alone is insufficient. Lowering the agent's autonomy so humans review all commits before they are pushed adds a human checkpoint, but humans routinely miss credentials embedded in large configuration files. Automated scanning is more reliable at pattern-matching for credential formats. Replacing the agent's LLM model with one fine-tuned to avoid generating secrets is not a reliable safety mechanism. Models can generate secrets unexpectedly, as interpolated values, as test data, or as copied examples. Scanning is the verification layer that catches what generation-time avoidance misses. Secret scanning as a pre-commit gate is the non-negotiable guardrail for AI-generated configuration content.